# CLensRimVision: A Novel Computer Vision Algorithm for Detecting Rim Defects in Contact Lenses
## 4 Methodology
### Defect Detection
#### 4.4.2 Correction of Criteria
The \"Factor correction of criterion\" defaults to 0.5 to maintain proximity to the average value and mitigate excessive fluctuations. Regarding the \"Pixel size of split images\", we employed values of 10 and 60. This choice was informed by our preliminary study of burr defects, which indicated a statistical range spanning from 8 to 52 pixels for each burr's position. Given the considerable variability in the burr sizes, we set the pixel size of the split images to 60 to encompass the largest burrs. However, we also assessed the detection performance for smaller burrs using a smaller split image size of 10. By examining the results for these two pixel sizes, we can discern meaningful contrasts and draw further conclusions from the data. ### Thickness-Based Approach

The \"thickness-based\" algorithm was evaluated using three different shrink/extended thicknesses (6, 8, and 10) and two distinct pixel sizes of the split images (10 and 60). The results indicated that for the 10-pixel split images, the algorithm achieved a high precision of 0.950 and 0.911 for the thicknesses of 6 and 10, respectively. However, as the pixel size increased to 60, the precision remained high but slightly decreased. This trend showcases the algorithm's ability to adapt to varying image characteristics while maintaining a good balance between precision and recall. Figure 11 shows an example of the result of different split image sizes; for the pixel heights of 10 and 60, the thicknesses are between 6 and 10 in 2-unit increments (6, 8, and 10 pixels). So, there are six image results for this sample. The contact lens from the examples below has inconsistent edges. The algorithm can detect but cannot cover all of the inconsistent edges. The example below represents the results of detecting burr defects on a contact lens. \begin{table}
\begin{tabular}{c c c c c c c c} \hline \hline \multirow{2}{*}{**Algorithm**} & \multirow{2}{*}{\begin{tabular}{c} **Shrink/Extended** \\ **Criterion** \\ \end{tabular} } & \multicolumn{2}{c}{\begin{tabular}{c} **Number of** \\ **Images** \\ **Above/Below** \\ \end{tabular} } & \multicolumn{2}{c}{**Pixels Size of** **Split Image**} & \multicolumn{2}{c}{\
\begin{tabular}{c} **Factor** \\ **Correction of** \\ **Criterion** \\ \end{tabular} } & \multirow{2}{*}{**Precision**} & \multirow{2}{*}{**Recall**} & \multirow{2}{*}{**[EMAIL_ADDRESS]**} \\ \cline{2-2} \cline{6-7}  & & 6 & 20 & 10 & 0.5 & 0.870 & 0.955 & \\ \cline{2-2} \cline{6-7} Thickness & 8 & 20 & 10 & 0.5 & 0.918 & 0.924 & 0.913 \\ \cline{2-2} \cline{6-7}  & 10 & 20 & 10 & 0.5 & 0.951 & 0.911 & \\ \hline \multirow{2}{*}{
\begin{tabular}{c} Thickness \\ based \\ \end{tabular} } & 6 & 20 & 60 & 0.5 & 0.888 & 0.955 & \\ \cline{2-2} \cline{6-7}  & 8 & 20 & 60 & 0.5 & 0.925 & 0.940 & 0.924 \\ \cline{2-2} \cline{6-7}  & 10 & 20 & 60 & 0.5 & 0.959 & 0.911 & \\ \hline \multirow{2}{*}{Area based} & 0.3 & 20 & 10 & 0.5 & 0.711 & 0.980 & \\ \cline{2-2} \cline{6-7}  & 0.4 & 20 & 10 & 0.5 & 0.821 & 0.971 & 0.809 \\ \cline{2-2} \cline{6-7}  & 0.5 & 20 & 10 & 0.5 & 0.894 & 0.955 & \\ \hline \multirow{2}{*}{Area based} & 0.3 & 20 & 60 & 0.5 & 0.880 & 0.971 & \\ \cline{2-2} \cline{6-7}  & 0.4 & 20 & 60 & 0.5 & 0.951 & 0.955 & 0.937 \\ \cline{2-2} \cline{6-7}  & 0.5 & 20 & 60 & 0.5 & 0.980 & 0.940 & \\ \hline \hline \end{tabular}

* Setups of the value of shrink and extended criterion are identical, which is called the symmetric setting criterion. Similarly, symmetric setting is when the number of images above and below are identical.

\end{table} 
Table 2: Evaluation result with test set images for image processing algorithm. In Figure 11, the 10-pixel split image performs better for the shrink defect criteria in the detection of the bottom part; the predicted results are shown for the thicknesses of 6, 8, and 10. In another setting, the 60-pixel split image cannot detect the same defect. Thus, the 10-pixels split image cannot detect the extended edge defect at the right side of the contact lens with a thickness of 10 pixels.