# Apparatus and Method of Defect Detection for Resin Films
## 2 Materials and Methods
### 2K Resolution Camera
#### 2.2.2 Image Adjustment and Image Processing  
Normally, the inspection process of the plastic resin film is not conducted in a dust-free environment. Therefore, the plastic resin film can contain dust. Thus, identifying defects is difficult because dust and defects (scratches and edges) appear similar under the 2K-resolution camera. This can decrease the classification performance. Therefore, a comparing component was introduced to filter noise and avoid dust before contour extraction. In this approach, three images on the same plastic resin film  
Figure 8: Architecture of the method with the 2K-resolution camera.  
Figure 9: Sketch of the inspection process using the 2K-resolution camera.  
were used, the contours of each image were determined and compared, and a fan was used to remove dust each time before capturing an image.  
If the contour's location was different than that of other contours, then the contour was mostly dust or fiber. The comparison between the contours must be in the same location or at least close, we used Intersection of Union (IoU) to examine whether they are the same object, which is defined as follows:  
\[\text{IoU}=\frac{\text{Area of Overlap}}{\text{Area of Union}} \tag{4}\]  
when we evaluate the IoU of the bounding box of the detected objects, the bounding box is defined during contour detection. We defined IoUs that are more than 0.3 as the same object. However, it is impossible to capture three images at the same position. Manual adjustment of the picture to the exact position is time consuming and reduces efficiency. Therefore, affine transformation is used. Affine transformation is any transformation that can be expressed through matrix multiplication. Rotation, translation, or scaled operations can be expressed using an affine transformation. Affine transform is the relation between two images, usually shown as a \(2\times 3\) matrix. The formula used for image adjustment is expressed as follows:  
\[\text{T}=\text{M}\cdot[x,y,1]^{T}=\left[\begin{array}{ccc}a_{00}&a_{01}&b_{00 }\\ a_{10}&a_{11}&b_{10}\end{array}\right]\cdot[x,y,1]^{T}=\left[\begin{array}{ ccc}a_{00}x+a_{01}y+b_{00}\\ a_{10}x+a_{11}y+b_{10}\end{array}\right] \tag{5}\]  
where M is the affine transform matrix, (\(x\),\(y\)) is the original image position, and T is the new position after applying the affine transform. To apply the transform to an image, \(M\) must be defined first. Our goal was to apply the affine transform to transform one image into another image, which required three corresponding positions in the two images. Thus, the relation between the two images can be obtained and can be transferred from one to the other. Three same points can be obtained from both images to achieve the affine transform matrix, the transform can then be applied to one of the images, and transform into the other image. The affine transformation is depicted in Figure 10.  
Therefore, three images were captured, and the affine transform was applied to two of the images making them exactly the same, and then the locations of the contours were compared to determine whether the objects were dust. To achieve the affine transform matrix, three exact points are required.  
Figure 10: Affine transformation. (**a**) The first step: obtain the affine transform matrix, (**b**) the second step: apply the transform to the image.  
Three stickers were placed on the plastic resin film. Some simple thresholding technique and contour detection could easily determine the center position.  
After the images had been transformed to the same position, image processing was performed, and the bounding box of the contours in all three images was obtained after contour detection. IoU more than 0.3 was counted as the same contour as mentioned before. The contours were extracted only if all three images have them. The results indicated the method can efficiently filter most of the dust and reduce the number of contours. Figure 11 illustrates the details of both the image adjusting stage and image processing stage.