# Enhanced Curvature-Based Fabric Defect Detection:
## 3 Curvature Algorithm
### Modified Discrete Curvature Algorithm  
In the standard curvature algorithm, successive sets of three points are selected along the curve. However, this method resulted in excessively large radius values. To address this issue, we modified the algorithm by incorporating a geometric check of the curve to obtain more reasonable radius values. Specifically, it was proposed to examine the second derivative of the curve function to distinguish between concave geometry, where \(f^{\prime\prime}(x)>0\), and convex geometry, where \(f^{\prime\prime}(x)>0\).  
Figure 10 illustrates the calculation of angle and radius values using the discrete curvature algorithm with a 3-point structure. Figure 10A presents a sample curve for evaluation. Figure 10B shows the traditional curvature method where points are selected in close succession, which leads to excessively large radius values and inaccurate angle calculations. In Figure 10C,D, alternative methods are depicted for achieving more accurate and optimal results.  
The new 3-point selection strategy maximizes the coverage area, as shown in Figure 10, thereby enabling more accurate curvature calculations. Additionally, the total number of points was significantly reduced, leading to faster processing. The detection result obtained by applying this method on contour pieces is shown in Figure 11.  
\begin{table}
\begin{tabular}{c l l l l} \hline \multicolumn{2}{c}{**Predicted**} & & \\ \hline \multirow{3}{*}{Actual} & \multirow{3}{*}{non-faulty} & non-faulty & faulty & \(\Sigma\) \\  & & 50 & 102 & 152 \\ \cline{1-1}  & faulty & 52 & 22 & 74 \\ \cline{1-1}  & \(\sum\) & 102 & 124 & 226 \\ \hline \end{tabular}
\end{table}
Table 1: Discrete Curvature Confusion Matrix.  
Figure 10: **(A)** Sample Curve, **(B)** Standard Curvature, **(C)** Optimized Curvature, **(D)** Efficient Curvature.  
The pseudo code of the described Modified Discrete Curvature Algorithm is presented Algorithm 1. The difference from Discrete Curvature can also be observed in the line titled Checking Convex or Concave.  
```
image \((n\times n)\
eq nonempty\) if Filter selection type then \(filteredimage=filter(image)\) endif contours \(\gets findContours(filteredimage)\)\(\triangleright\) finding Countours while\(N\leq len(counters)\)do \(CI_{L}ist=DiscreteCurvature(counters)\)\(\triangleright\) return\((rj,theta,theta,kp_{j})\) endwhile while\(m\leq CI_{L}ist\)do if\(theta_{j}\)is \(<180\)then\(\triangleright\) Checking convex or concave \(dircurv=1\) elseif\(theta_{j}\)is \(>180\)then \(dircurv=2\) elseif\(theta_{j}\)is \(=180\)then \(dircurv=3\) endif  dircurv is changed append values to the \(CI_{L}istedge\) endwhile while\(m\leq CI_{L}istedge\)do if\(CI_{L}istedge\) is between \(x_{1}<r_{j}<y_{1},a_{1}<theta_{j}<b_{1}type1\)then  defect type is hole or oil endif if\(CI_{L}istedge\) is between \(x_{2}<r_{j}<y_{2},a_{2}<theta_{j}<b_{2}\)then  defect type is vertical or horizontal endif endwhile
```  
**Algorithm 1** Modified Discrete Curvature Algorithm  
The results demonstrate that the proposed method, utilizing the modified curvature algorithm, produces more accurate outcomes, as reflected in the confusion matrix in Table 2. This highlights the method's potential application in defect detection. Consequently, further studies will be undertaken to advance and refine this approach.