# CLensRimVision: A Novel Computer Vision Algorithm for Detecting Rim Defects in Contact Lenses
## 4 Methodology
### Defect Detection
#### 4.4.2 Correction of Criteria
This is because the pixel thickness can be easily

Figure 14: A comparison between the results of using or not using correction criterion function in the algorithm. (**a**) A result from the algorithm using correction of criterion; (**b**) A result from the algorithm without correction of criterion. converted into the physical length, thanks to standardized quality control processes. In the premium contact lens industry, the thickness-based method has proven to be effective in quality control, as it uses micron units to precisely identify the required thickness adjustments, whether for shrinking or extending. Therefore, it can be concluded that the thickness-based method is more straightforward and suitable for most cases. Conversely, the area-based approach may not exhibit a direct correlation with physical contact lenses. This approach relies heavily on sensitivity when configuring parameters, especially when setting the window size in the window-sliding process. This sensitivity arises from the fact that the area of black pixels in the counting method is relatively proportional to the size of the split image in the window-sliding technique. To illustrate, if the area of the split image changes from 10 to 60 pixels while assuming a constant thickness, the area difference between a 10-pixel split image and a 60-pixel split image would be six-fold. As mentioned earlier, this highlights the importance of a deep understanding of the algorithm when using the area-based method. However, it is worth noting that, in certain scenarios, the area-based method can deliver slightly superior results compared to the other approach. ### Optimal Value of Pixels Size of Split Image

According to the results presented in Table 2, it is evident that the overall performance is significantly better with a split image pixel size of 60 pixels compared to that of 10 pixels. This leads to the conclusion that the 10-pixel size is limited in its ability to detect larger defects, resulting in a lower accuracy compared to that of the 60-pixel size. To conclude, our experiments have demonstrated that the optimal choice for the pixel size of split images is 60 pixels. This selection has been substantiated by the fact that it can effectively encompass defects of varying sizes. On the other hand, smaller sizes, such as a size of 10 pixels, do not enhance the accuracy since they are incapable of detecting larger burrs. ## 7 Conclusions

This research aims to provide a comprehensive understanding of the intricate technique required to detect burr defects on contact lenses. These defects may manifest as variations in thickness along the rim circle of the contact lens. Building upon these observations and our research findings, we introduce CLensRimVision, an algorithm specifically designed for detecting defects on the rims of contact lenses--an essential part that is in contact with the human eye. The proposed algorithm consists of three main components: image processing, circle detection, and defect detection. In defect detection, we developed a thoughtful window-sliding technique that overcomes the limitations posed by having an uneven thickness. Additionally, a correction criteria method was employed to reevaluate the correct average value, which is crucial for determining the acceptable range. This range calculation involves variables for shrinkage and extension, making the algorithm adaptable to various parameter inputs. Furthermore, we introduced two criteria for different detection purposes: the area-based and thickness-based approaches. As a result, we have generated prediction accuracy results based on different parameter settings and the use of these two criteria. The results of the contact lens defect detection algorithms under different parameter settings are shown, showcasing their performance in terms of precision, recall, and average precision (AP of 0.5). Notably, the \"thickness-based\" algorithm consistently demonstrates competitive levels of precision and recall across various settings.