## 4 Experiments
### Results and Discussion  
#### 4.3.1 DAGM2007  
As for the evaluation criteria, we use the true positive rate (_TPR_), true negative rate (_TNR_) and average accuracy rate (_AVEACC_) as metrics. These metrics are defined as follows:  
\[TPR=\frac{TP}{TP+FN}\times 100\% \tag{4}\]  
\[TNR=\frac{TN}{FP+TN}\times 100\% \tag{5}\]  
\[AVEACC=\frac{\sum TN_{i}+TP_{i}}{\sum TN_{i}+TP_{i}+FP_{i}+FN_{i}}\times 100\% \tag{6}\]  
where _TP_ and _FN_ refer to the number of defective images detected as defective and non-defective, respectively. _TN_ and _FP_ refer to the number of non-defective images \begin{table}
\begin{tabular}{c c c c c c c c} \hline \hline
**Class** & **Class2** & **Class3** & **Class6** & **Class7** & **Class8** & **Class9** & **Class10** & **Total** \\ \hline Train(P/N) \({}^{1}\) & 120/970 & 100/800 & 100/800 & 200/1800 & 200/800 & 200/1800 & 200/1800 & 1120/9770 \\ Test(P/N) \({}^{1}\) & 30/30 & 50/200 & 50/200 & 100/200 & 100/200 & 100/200 & 100/200 & 530/1230 \\ \hline \hline \end{tabular} \({}^{1}\) Here “P” indicates defective images, “N” indicates non-defective images.  
\end{table} 
Table 1: The image distribution of each class. \begin{table}
\begin{tabular}{c c c c c c c c c} \hline \hline
**Class** & **Class2** & **Class3** & **Class6** & **Class7** & **Class8** & **Class9** & **Class10** & **Total** \\ \hline Defective patches & 1503 & 1758 & 2370 & 3690 & 2814 & 2930 & 4504 & 19,589 \\ Non-defective patches & 3880 & 3200 & 2400 & 7200 & 7200 & 6000 & 5400 & 35,280 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: The number of training patches of each class in the wavelet model. detected as non-defective and defective, respectively. _AVEACC_ is the total number of correctly predicted images in all classes divided by the total number of images in all classes. _TN\({}_{i}\)_ refers to the number of non-defective images detected as non-defective in class i. Figure 14 illustrates our detection results of this method. The non-defective areas are covered by the black image in the results. It should be noted that the step of the sliding-window method in the detection phase is 32 px, which is less than the size of patches 64 px, so some areas of the image to be detected may be judged as both defective and non-defective at the same time. The results shown in Figure 14 consider the above situation as defective. It can be found that this method can detect small defects in the image with large texture differences in the background, and also can roughly determine the location of the defects. Figure 14: The examples of detection results in the DAGM2007 dataset. The red ellipse marks the location of the defect. The left image is the image to be detected, and the right image is the detection result. Our model judges that areas without defects are covered with black images. To show the high efficiency of this approach, we trained the wavelet and non-wavelet models for each class of the DAGM2007 dataset under the same parameters. Here we take the class 10 images as an example. Figure 15 shows the accuracy curve and loss curve of the wavelet model and non-wavelet model during the training process. It can be found that the wavelet model is better than the non-wavelet model in accuracy and learning speed. As for the accuracy of detection, the results and comparisons are shown in Table 3. Table 3 shows the TPR and TNR of each class in the wavelet model and non-wavelet model. It can be seen from the comparison between the wavelet model and non-wavelet model that except Class 8, the performance of the wavelet model is better than the non-wavelet model in the same training environment. Compared with the work of other researchers, the average accuracy of our wavelet model is only slightly lower than the method In the Ref. [1; 2; 25]. In terms of TPR and TNR, the performance of this method is better than the traditional defect detection methods proposed in the Ref. [42; 43; 44] in most cases, similar to the CNN model proposed in the Ref. [3], slightly lower than the method proposed in the Ref. [1; 2; 25].