# CLensRimVision: A Novel Computer Vision Algorithm for Detecting Rim Defects in Contact Lenses
## 4 Methodology
### Defect Detection
#### 4.4.2 Correction of Criteria
However, the 60-pixel split image can perform well under all of the criteria settings. Figure 11: Results from a sample using the thickness-based method with different settings. (**a**) 10-pixel image splitting combined with a 6-pixel extended and shrink thickness criterion; (**b**) 10-pixel image splitting combined with an 8-pixel extended and shrink thickness criterion; (**c**) 10-pixel image splitting combined with a 10-pixel extended and shrink thickness criterion; (**d**) 60-pixel image splitting combined with a 6-pixel extended thickness criterion; (**e**) 60-pixel image splitting combined with an 8-pixel extended and shrink thickness criterion; and (**f**) 60-pixel image splitting combined with a 10-pixel extended and shrink thickness criterion. ### Area-Based Approach

For the \"area-based\" algorithm, we examined different factor correction values (0.3, 0.4, and 0.5) and two different pixel sizes for split images (10 and 60). Notably, the algorithm consistently demonstrated a robust performance with precision values above 0.9 for various factor correction values. This suggests that the \"area-based\" method maintains its efficacy across different configurations. Figure 12 shows a sample of the results of the area-based approach with the same samples as the thickness-based approach. This method also can adjust the parameters for the change criterion and split image size. In this method, the split image size is not set as a high value because this will affect the percentage of the area of the criteria for detection. Therefore, this parameter value is set to 10 pixels and 60 pixels, while the percentage of the area in the criteria is set as three values: 0.3, 0.4, and 0.5. Figure 12: Results from a sample using the area-based method with different settings. (**a**) 10-pixel image splitting combined with threshold of 0.3 extended and shrink area criterion; (**b**) 10-pixel image splitting combined with threshold of 0.4 extended and shrink area criterion;(c) 10-pixel image splitting combined with threshold of 0.5 extended and shrink area criterion; (d) 60-pixel image splitting combined with threshold of 0.3 extended and shrink area criterion; (e) 60-pixel image splitting combined with threshold of 0.4 extended and shrink area criterion; (f) 60-pixel image splitting combined with threshold of 0.5 extended and shrink area criterion. The lower split image size of 10 pixels has more prediction detection bounding boxes. It shows that the sensitivity of the model of the setting of the smaller split image is higher, as shown in the left part of the result in Figure 12a-c. Also, the top part of the result is split into two bounding boxes, but Figure 12d-f has the one bigger box in the top part of the predicted result. In the bigger size of the split image, the number of predicted bounding boxes is obviously lower than that of the smaller split image size. This shows that the precision of the setting in which the 60-pixel size is used is greater than that of the 10-pixel split image size. ## 6 Discussion

### Effectiveness of Window-Sliding Method

The window-sliding method is proposed with the objective of addressing the issue of uneven thickness around the entire circumference of the contact lens. The root cause of this uneven thickness on the contact lens rim stems from the imperfect placement of the contact lens in the contact lens holder. Tilt angles during its placement can lead to the conditions observed in the captured images as shown in Figure 7. Therefore, the window-sliding method is proposed to reevaluate the criteria defined by Equations (7) and (8) by calculating the average thickness within a specified local region of interest. This calculation is performed iteratively along the length of the circular rim. If the CLensRimVision algorithm is executed without the window-sliding method, the criteria defined by Equations (7) and (8) are calculated using the average value of the entire input of the contact lens.