# Improved U2 Net-Based Surface Defect Detection Method for Blister Tablets
## 5 Experiments and Analysis of Results
### Blister Tablets Visual Inspection Results
The red box part covers the stained area, but the complete scope of the stain cannot be completely detected, and there are still omissions. Although the binary segmentation diagram in b(3) can partially reflect the shape of the stain, there is obvious noise at the edge, and the segmentation result is not smooth enough, indicating that Deeplabv3 has insufficient performance in processing details and edges. The detection result of U2 Net in c(2) was more accurate and marked most of the stained areas, but the red box still failed to completely cover the entire stain, resulting in some small stained areas not being detected. The segmentation results of c(3) show more background noise, and the edge of the stain is not smooth enough. The segmentation effect has been improved, but there are still limitations. Figure 8: Surface damage defect detection effect. **(A)** Surface damage images before detection; **(a(1))** Pspnet detection results; **(a(2))** Pspnet detection and cropping results; **(a(3))** Pspnet defect segmentation binary graph results; **(b(1))** Deeplabv3 detection result; **(b(2))** results of Deeplabv3 detection and cropping; **(b(3))** results of Deeplabv3 defect segmentation binary graph; **(c(1))** U2 Net test results; **(c(2))** detection and cropping results of U2 Net; **(c(3))** U2 Net defect segmentation binary graph results; **(d(1))** improved U2 Net detection results; **(d(2))** improved U2 Net detection and cropping results; **(d(3))** improved U2 Net defect segmentation binary graph results. In contrast, the improved U2 Net performs well in d(2), able to accurately detect and frame the complete area of the stain, and the red box accurately covers the stain, showing high detection accuracy. The results of the binary segmentation diagram of d(3) show that the edge of the stain is very smooth and noiseless, the segmented stain area is complete, and the shape is consistent with the actual stain, indicating that the improved U2 Net has the best performance in stain detection and segmentation. By introducing the local mean and OTSU methods, the improved U2 Net can adaptively adjust the segmentation threshold according to different lighting conditions and material changes. Under the complex lighting and surface changes of Figure 9, the improved U2 Net can still maintain high precision segmentation results, ensuring the clear and noise-free boundary of the binary graph. This makes the improved U2 Net extremely robust and adaptive when handling stain detection, significantly better than Pspnet, Deeplabv3, and the original U2 Net. Figure 9: Surface stains defect detection effect. (**B**) Surface stains images before detection; (**a(1)**) Pspnet detection results; (**a(2)**) Pspnet detection and cropping results; (**a(3)**) Pspnet defect segmentation binary graph results; (**b(1)**) Deeplabv3 detection result; (**b(2)**) results of Deeplabv3 detection and cropping; (**b(3)**) results of Deeplabv3 defect segmentation binary graph; (**c(1)**) U2 Net test results; (**c(2)**) detection and cropping results of U2 Net; (**c(3)**) U2 Net defect segmentation binary graph results; (**d(1)**) improved U2 Net detection results; (**d(2)**) improved U2 Net detection and cropping results; (**d(3)**) improved U2 Net defect segmentation binary graph results. Figure 10 shows scratch detection against a complex background. Pspnet failed to locate the scratch area correctly in a(2); the red box deviated greatly from the actual scratch position; the shape of the binary graph in a(3) was wrong; and there was obvious noise at the edge. Deeplabv3 partially detected scratches in b(2), but the red box is still incomplete and the binary image edge of b(3) is rough and noisy. The detection performance of U2 Net in c(2) is biased, and the binary segmentation graph of c(3) has some noise and unsmooth boundary problems.