An Enhanced Nonlocal Self-Similarity Technique for Fabric Defect Detection

: Fabric defect detection has been an indispensable and important link in fabric production, many studies on the development of vision based automated inspection techniques have been reported. The main drawback of existing methods is that they can only inspect a particular type of fabric pattern in controlled environment. Recently, nonlocal self-similarity (NSS) based method is used for fabric defect detection. This method achieves good defect detection performance for small defects with uneven illumination, the disadvantage of NNS based method is poor for detecting linear defects. Based on this reason, we improve NSS based defect detection method by introducing a gray density function, namely an enhanced NSS (ENSS) based defect detection method. Meanwhile, mean filter is applied to smooth images and suppress noise. Experimental results prove the validity and feasibility of the proposed NLRA algorithm.


Introduction
With more and more textile enterprises adopting modern equipment for their production, the requirements of automatic detection technology for fabric defects are urgent. The traditional method of fabric detection by manual method has been exposed to many problems in modern production, and the accuracy rate of this method decreases with the increase of working hours. According to statistics, the accuracy rate of human visual inspection is only about 70% [Sari-Sarraf and Goddard (1999)]. Compared with the traditional manual detection method, automated fabric inspection can save labour costs and provide higher accuracy and reliability. After decades of development, many different methods have been developed, and these techniques are usually divided into three categories: statistical approach, spectral approach and model-based approach. Statistical approaches mainly measure the spatial distribution of pixel values. The statistics features of defect-free parts are usually assumed to be stable, and the feature of defect parts can be separated by a fixed or dynamic threshold. The commonly used statistical approaches include gray level co-occurrence matrix (GLCM) [Haralick, Shanmugam and Dinstein (1973) ;Tsai, Lin and Lin (1995); Lund and Burgess (1996)], mathematical morphology [Serra (1982) ;Haralick, Sternberg and Zhuang (1987)], fractal approach [Mandelbrot (1991); Conci and Proença (1998)] and neural network [Hagan, Demuth and Beale (1996) ;Jain, Duin and Mao (2002); ; ]. The spectral approach is to transform the image signal from the spatial domain to the frequency domain. This is because many texture features of the image are more obvious in the frequency domain. The common spectral approach include Fourier transform [Cattermole (1986); Dorrity, Kasdan and Mead (1978)], Gabor transform [Gabor (1946); Bodnarova, Bennamoun and Latham (2000)] and wavelet transform [Mallat (1989); Sari-Sarraf and Goddard (1999)]. The model-based approach is based on the fact that the defect region and the non-defect region have different distribution characteristics. Model-based approaches mainly include Markov Random Field model [Kindermann and Snell (1980)] and Autoregressive model [Akaike (1969)]. Recently, nonlocal self-similarity (NSS) based method [Wong and Jiang (2015)] is used for fabric defect detection and achieves good defect detection performance for small defects, but the linear defects cannot be detected by NSS algorithm effectively and completely. Based on this reason, we improve NSS based defect detection method by introducing a gray density function, namely an enhanced NSS (ENSS) based defect detection method. First of all, we use the mean filter to make the image smoother and highlight the defect area, and then extract the grayscale gradient of the image to get the suspected defect area. The difference of gray value between the suspected defect area and the non-defect area is increased to form a preprocessed image. Then the image is divided into many patchs and each patch is weighted avereage with the surrounding patches, a new image can be resconstructed. By searching for the difference between the resconstructed image and the preprocessed image, the defects on the fabric can be located. The rest of the paper is organized as follows. In Section 2, we describe the ENSS algorithm in detail. Section 3 gives experimental results. The paper is concluded in Section 4.

An enhanced NSS (ENSS) based defect detection method 2.1 Pretreatment
Fabric images are often corrupted by noise during image acquisiton due to malfunctioning pixel elements in the camera sensors. The corrupted images severely influence the defect detection rate and lead to the occurrence of false detection. Therefore, some pretreatment needs to be done before implementing defect detection. In this paper, we use the mean filter to smooth images and suppress noise. For a fabric image need to be detected, a pixel is replaced by the mean value of its neighbors, including itself. This has the effect of eliminating pixel values which are unrepresentative of their surroundings. Mean filtering is usually thought of as aconvolution filter, the template for a 3×3 square kernel is used in ENSS and can be expressed as:

Defects enhancement strategy based on the gradient of gray density
Under normal conditions, an acquired fabric defect image is composed of noise and normal texture background. The noise can be effectively suppressed by Eq. (1). Therefore, texture background is the main factor to influence the detection results. Although there are many types of defects in the images collected from the factory, they are possible to select them through certain characteristic values due to some statistical characteristics. Next, gray density gradient function is applied to determine the range of fault region. For an image of M×N size, its gray density can be represented by the following function: where m(o) represents the number of times a pixel with a gray value of o appears. As shown in Fig. 1, Fig. 1(b) is the gray histogram of Fig. 1(a), and Fig. 1(c) is the gray density map. From Fig. 1(c), we can see two abrupt points. In order to obtain the values of these two abrupt points, we introduce the gray-scale density gradient function. Since the pixels of each point cannot be regarded as a continuous function, the first order gradient function of the gray density can be represented by the following functions: In Fig. 1(d), a maximum extreme value point and a minimum extreme value point can be found in the curve. The maximum extreme value point denotes defect region across the background texture region, and minimum extreme value point indicates background texture regions across the defect area. According to the distribution of two extreme point, background texture information is mainly existed between two extreme points, but defect information on both sides. Based on this distribution, we increase the gray value of the suspected defect area. This method can make the boundary between the defect area and the non-defect area more obvious.

Nonlocal self-similarity (NSS) based defect detection
Based on this distribution, we increase the gray value of the suspected defect area. This method can make the boundary between the defect area and the non-defect area more obvious. The idea of NSS was mainly used for image denoising [Buades, Coll and Morel (2005)] and then adopted to defect detection [Wong and Jiang (2015)]. An image acquired from fabric can be considered as a natural image and has the characteristics of NSS. For a defective image Y, it will be divided into multiple patches. let Euclidean distance between then is less than a preset threshold. We assume that L patches similar to yi are found. Then the weighted average of L similar patches can be written as: where h is a predefined scalar and a normalized factor. After each patch is processed by Eq. (5), the new image Z can be constructed by where Ri is matrix operator. In the new reconstructed image, the defect pixels are different from the pixels of original image, but the pixels in non-defect area will be almost the same as the original image. Thus defects can be located by finding the difference between the original fabric image and the reconstructed image. Fig. 2 below is the flowchart of ENSS.   [Buades, Coll and Morel (2005)]. Images. (a3)-(d3) are the results ENSS algorithm Figure 4: Detection results of two methods. (a1)-(d1) are the original images. (a2)-(d2) are the results of Buades et al. [Buades, Coll and Morel (2005)]. Images. (a3)-(d3) are the results ENSS algorithm

Experiments
In this section, experiments are carried out to demonstrate the performance of the proposed algorithm. Where is mainly the line defects, including large line defects and small line defects, and the images with spot defects are also selected. The performance of the proposed model is compared with Buades et al. [Buades, Coll and Morel (2005)].

Parameter setting
There are several parameters to set in the proposed the algorithm. Since the proposed method is a patch based method for defect detection, the size of patch can affect the algorithm performance directly. Considering the running time and defect detection rate, we set the size of patch as 7 7 × . The mean kernel n is set as 3 or 7 by experience.

Results
The experimental equipment used in this experiment is PC machine with Intelcore i5 processor. The experiment is tested by Matlab language. Some typical experimental results are shown in Fig. 3 and Fig. 4. In Fig. 3, the first column are the original defective images collected in the factory, the second column are the result of Buades et al. [Buades, Coll and Morel (2005)], the third column are the detection results of ENSS algorithm. On the premise of maintaining good detection performance of the spot defect, from Fig. 3 and Fig. 4, we can see that ENSS algorithm can get better detect results than Buades et al. [Buades, Coll and Morel (2005)].

Conclusion
In this paper, the NSS based defect detection algorithm is improved. The mean filter is added to suppress the noise on the fabric images. Then the defect enhancement method based on grayscale density gradient is used to increase the pixel value of the defect area, so that the linear defect can be retained in the weighted average. After these two steps, NSS based method is adopted to detect defects. The experimental results show that the ENSS algorithm achieves good defect performance.