Fabric Defect Detection Using Local Homogeneity Analysis and Neural Network

In the textile manufacturing industry, fabric defect detection becomes a necessary and essential step in quality control. The investment in this field is more than economical when reduction in labor cost and associated benefits are considered. Moreover, the development of a wholly automated inspection system requires efficient and robust algorithms. To overcome this problem, in this paper, we present a new fabric defect detection scheme which uses the local homogeneity and neural network. Its first step consists in computing a new homogeneity image denoted as -image. The second step is devoted to the application of the discrete cosine transform (DCT) to the -image and the extraction of different representative energy features of each DCT block. These energy features are used by the back-propagation neural network to judge the existence of fabric defect. Simulations on different fabric images and different defect aspects show that the proposed method achieves an average accuracy of 97.35%.


Introduction
Defect detection is one of the main steps in quality control of manufacturing processes. In the fabric field, defect detection becomes an important task due to the widely used material in daily life. Fabric defects are responsible for nearly 85% of the defects found in the garment industry [1]. Also, it has been observed [2] that price of textile fabric is reduced by 45% to 65% due to defects. It is imperative, therefore, to detect, identify, and prevent these defects from reoccurring. A fabric defect is generally represented by a wired variation with respect to the overall surface aspect. Visual human inspection leads to usual errors due to several reasons, namely, the fatigue and fine defects. Hence, the automation of these operations helps to improve quality and reduce labor costs. As confirmed by [3,4], there are more than 70 kinds of fabric defects defined by the textile industry. A human fabric inspection achieves a success rate about 60 to 75% [3]. Figure 1 shows the same machine automated inspection.
Fabric defect detection is one of the most scheming problems in visual inspection. Currently, there are a lot of new studies and researches in fabric inspection [10][11][12][13][14][15][16][17][18][19]. This paper emphasizes this problem and investigates some new technique to solve this problem.

Related Work.
Texture analysis has a great interest in image processing, and there are many applications in its analyzing and processing, one of which is defect detection. Therefore, numerous methods are typically developed to solve the defect detection task in fabric images. The authors in [4] propose a review of the art field in this state. Chan and Pang [10] provided a comprehensive overview of fabric defect detection by Fourier analysis. Wavelet transform is another method which was applied in [11][12][13][14].
On the other hand, Latif-Amet et al. [15] proposed an approach that uses wavelet theory and cooccurrence matrix for the detection of defects encountered in textile images and classifies each subwindow as defective or nondefective by a Mahalanobis distance. Gabor filter has been widely used in the field of fabric defect detection. All the detection approaches using Gabor filter can be classified into two categories. One is to use a filter bank, such as [16,17], and the 2 Journal of Photonics other one is to use optimal filters, such as [18][19][20][21]. In general, filtering with a filter bank can generate excessive data for processing though a set of filters may aid the segmentation. Correspondingly, the quality of localization and recognition is affected dramatically and the time consumption is large as well.
Moreover, model based approaches have been successfully used in the fabric defect detection. Some of textural analysis methods are based on the Markov random field model [22]. Campbell et al. [23] used the model based clustering method to detect linear pattern production defects.
Recently, neural network has attracted a lot of attention in defect detection applications. Huang and Chen [24] have used back-propagation neural network, with fuzzy logic, to achieve the classification of eight different kinds of fabric defects. In [25] an approach for the segmentation of local textile defects using feed-forward neural network is presented. Recently, Jing et al. in [26] present a machine vision system which uses basic patch statistics from raw image data combined with a two-layer neural network to detect surface defects on arbitrary textured and weakly labeled image data.

Present Work.
In textured images, discontinuities represent generally an important feature such as boundaries. It is known that the local homogeneity analysis is the method to detect these discontinuities. Moreover, due to their nonparametric nature and their ability to describe complex decision regions, neural network is one of the best classifiers used for defect detection. In this paper, a new approach for fabric defect detection based on the local homogeneity analysis and neural network is proposed. This paper is organized as follows. In Section 2 the local homogeneity computation ( -image) for different window sizes is presented. The discrete cosine transform of theimage and feature extraction are then described in Section 3. Section 4 provides a system description of the proposed method. It is followed by the experimental results in Section 5. Details of training and test procedures which include our proposed method for fabric defect detection and detection performance are described in Sections 5.1 and 5.2, respectively. Finally, Section 6 draws conclusion and summarizes the paper.   Figure 2: Different pixels used to compute the local homogeneity for 5 × 5 mask, for each pixel corresponds to a direction vector .

Local Homogeneity Definition
It is known that discontinuities in textured images represent generally an important feature such as boundaries. The main problem is how to detect these discontinuities. A method to resolve this problem is the homogeneity ( ). The calculation of was proposed first by Jing et al. in [26]. Let ( , ) be the coordinates of a pixel and ( , ) the corresponding intensity level. Let be a squared window, that is, a mask of (2 + 1) width centered on the pixel. In the window one can define different vectors, such as = ( − , − ), where ( , ) is the neighbor of the center ( , ) defined as where ( , ) is the coordinate of the pixel , is the coordinate of the centre pixel ( ), and is an integer number which defines the mask size. Note that this definition allows computing the homogeneity of a pixel for different mask sizes 3 × 3, 5 × 5, and so forth. Figure 2 shows an example of the different pixels used to compute homogeneity in a window of size 5 × 5 pixels.
Based on a new vector is constructed as follows: For a mask of width (2 + 1) we have (2 + 1) 2 vectors : Let be the sum of the whole vectors defined in the window , so The value measurement (the homogeneity value) is defined as the norm of , so that = .
(4) Journal of Photonics 3 To limit the huge variation of the local homogeneity the normalized homogeneity is used: where min and max are the minimum and the maximum value of homogeneity, respectively. The resulting -image is constructed by the different values of̂computed for each pixel value ( , ).
The variables and V are frequency variables, and are spatial variables, and and are the size of the DCT block: where 3.2. Feature Extraction. In order to characterize the frequency domain within texture image, this paper proposes to use the features energy distribution in the 2D-DCT domain from the -image, which is presented as follows [27]: (i) The horizontal energy value of the DCT block: (ii) The vertical energy value of a DCT block: (iii) The diagonal energy value of a DCT block: (iv) The average energy value of a DCT block: (v) The standard deviation energy value of a DCT block: Then the features vector of each pixel is expressed as In the next section, the principal component analysis (PCA) is introduced to eliminate correlations between features and reduce the dimensionality of the original feature vectors.

Features Reduction.
Feature reduction means transforming the original features into a lower dimensional space [28,29]. Most of the feature extraction techniques have been based on linear techniques such as principal component analysis (PCA). PCA is a quantitatively rigorous method for achieving data dimensionality reduction. The method generates a new set of variables, called principal components (PCs), which maximize the variance of the projected vectors. Each PC is a linear combination of the original variables. All the PCs are orthogonal to each other, so there is no redundant information. The PCs as a whole form an orthogonal basis for the space of the data. Thus, the first PC consists of the highest variability, the second PC consists of the next highest variability, and so on for other directions. The first few components are kept and others with less variability are discarded. As shown in Figure 3, in the proposed work, the first 4 PCs are used to feed to the feed-forward neural networks (FFN) classifier.

Fabric Defect Classification Based on FFN.
This method consists in scanning the acquired image with a squared window and computing the local homogeneity for each pixel and constructing the -image. In our work we have used a window of size 11 × 11 pixels. Then, we divided the -image into overlapping squared blocks. The five aforementioned types of energy are computed through the DCT applied for each block which produces these energies. Every pixel of the acquired image is characterized by a feature vector (five types of energy). Then, the statistical or -score normalization technique is applied to all the features vectors that form the input to the neural network. The number of the inputs of the neural network is not equal to the same number of feature extractions. They are obtained using a principal component analyzing (PCA) routine. This routine is applied in order to limit the number of inputs of neural network. In this case the number of inputs equals four (i.e., the number of chosen principal components). The number of the training vectors equals the number of pixels in the considered field of view of the investigated fabric surface. The network has a single output.
The concept diagram of the fabric defect detection scheme is presented in Figure 4.
The procedure of the proposed method can be summarized as follows.
Step 1. Scanning of the input image with a squared window and computing the local homogeneity for each pixel.
Step 2. Normalization of the local homogeneity.
Step 3. Division of the -image into overlapping squared blocks and application of a DCT transform.
Step 4. Features extraction from the DCT block.
Step 5. Features reduction using the PCA method.
Step 6. Normalization of all features using Zero mean and unity variance technique.
Step 7. Classification process for fabric defect by FFN based on -image (since only 2 conditions (block contains defect regions or not) need to be identified in this paper).

Learning Defect Classifier.
After a feature calculation step, now we use the training data to train a neural network using back-propagation. An example of a FFN structure is shown in Figure 4 FFN classification. The size of the input layer is equal to the feature dimension; here = 4 (after applying a PCA technique the number of features is reduced to 4). The second layer, called the hidden layer, has L1 nodes. In the output layer, all nodes from the hidden layer are mapped to one final node showing the classification result. All weights in the neural network are initialized by random numbers. Training a network means optimizing network detection performance. This is realized by minimizing the performance function. The performance measurement function in this case is the mean squared error (MSE). The final classification result is a value between [−1, 1] and predicts whether an unknown block contains defect regions or not.

Experimental Results: Application of the Proposed Method in Fabric Defect
This section presents the experimental results for fabric defect detection. The dataset used is established and the results are analyzed in Section 5.1. The performance of the proposed algorithm for a number of sample images is presented and analyzed in Section 5.2. Discussion and comparison with some previous works are given in Section 5.3.

Dataset. The dataset used in this work is provided by PARTNER textile industry in Tunisia [30]
. The dataset consists of 89 images, of which 13 have no defects and 76 have various fabric defects. The total databases were divided into two sets: one for training (containing 60% of the samples) and the other for test (containing 40% of the samples). Table 1 summarizes some fabric defects types used in this study, their definition, and their reasons. All simulations were implemented on a personal computer (Intel core 2Duo CPU T5870 @2 GHz and 3 GB of RAM). The programs were tested first in MATLAB language and after that they were rewritten in C++ language for the purpose to be implemented in a real time process. We note that once the neural network is trained in the learning phase (offline step) it will be inserted in the defect detection process and then the global needed time is considerably reduced.  Training of the network was carried out with the error back-propagation algorithm by using a set of fabric images data containing 46 images with defect and 8 images without defect covering every possible pattern of defect blocks and nondefect blocks.
Initially, all the weight values of the neural network were randomly set to small values between 0 and 0.1 and the learning coefficients were set to 0.6. Several experiments were conducted for selecting the best FFN. The factors that played a significant role in the performance of the system were the number of hidden layer neurons, the learning coefficients of the hidden layer neurons and the output layer, the activation function, and the learning rule. The parameters of the best architecture for FFN are summarized in Table 2.

Performance Detection.
After the FFN is trained with 54 images, its performance has been tested with the remaining ones (35 images). The performance of this algorithm is validated by calculating the following performance measure for the train set and test set separately. The classification accuracy (CA) is as follows: ratio between the total number  The classification results of all classifiers in the training and testing processes are presented in Table 4. In the training process, all the FFN classifiers achieve an average accuracy of 98.30% and 99.05% in the whole dataset and the reduced dataset, respectively. This indicates that the classifiers are well trained and can be applied for fabric defect detection. However, in the testing process these classifiers are validated against the test data; the average accuracy is about 97.35% and 96.25% for the reduced and original features, respectively.
From the test results shown in Table 4 it can be seen that the FNN classifiers recognize the blocks defects effectively. The recognition results of FNN are ideal because of its high accuracy and a good generalization capability, when the average classification efficiency close to 97.35% is reasonably good.
For 256 × 256 image the time needed for defect detection by scanning all the image is about 0.8 seconds. Taking into account the production rate (knitting speed), the algorithm can be used in a real time application. 6 Journal of Photonics

Discussion and Comparison with Some Previous Works.
In this experiment, the -image is obtained after scanning the input image using a window of size 11×11 pixels. The features extractions are produced by dividing the -image into overlapping blocks of size 4 × 4 pixels after applying the DCT transform. The final classification result is obtained from a feed-forward network trained with the back-propagation (BP). Figure 5 shows detection examples of the fabric dataset. The kinds of fabric defects vary in size, shape, and orientation. In Figure 5, column (a) shows the original images. Columns (b) and (c), respectively, correspond to the -image and defect detection results. Image in the first line represents the "hole" defect. The proposed algorithm was able to correctly detect the defect. Image in the second line shows another type of defect (slub defect) and the corresponding defects detection results which were accurately detected. Other types of sample defects are shown in the rest of the figure.
It is interesting to note that despite the varying size and orientation of the defects, the algorithm managed to identify accurately most of the defects.
Based on these results, it can be concluded that the DCT features extraction method effectively improves classification performance for the given fabric defect classification problem. Table 5 provides a summary of the studies on automated fabric defect detection. Bissi et al. (2013) [29] proposed an approach for automated texture defect detection in uniform and structured fabrics based on a complex symmetric Gabor filter bank and PCA. The performance of their algorithm has been extensively evaluated by using images of the TILDA Textile Texture Database and reported an accuracy of 98.8%.  [33] used an approach for defect detection applied to twill, plain, gingham, and striped fabric using Gabor filter and sparse coding with an accuracy of 93%.
In conclusion, the evaluation of our method versus those in previous researches, given in Table 5, shows that our experiment has good potential for improving fabric defect detection. The features derived from the DCT transform of -image with the FFN classifier produce a good classification performance: the average CA result is 97.35%. This combination of the feature and classifier is promising for a high accuracy of fabric defect detection.

Conclusions and Future Work
In this paper a novel method is proposed to solve the problem of fabric defect detection, which is based on the local homogeneity analysis and the feed-forward neural networks. A DCT transform based feature extraction method beside the PCA was used. The performance of this algorithm has been extensively evaluated by using images of the PARTNER Textile Texture Database. The comparison with other existing algorithms reported in literature highlights the effectiveness of the proposed approach. The average accuracy of block condition was 97.35%; the results show that the proposed algorithm is a strong technique for fabric defect detection.  Journal of Photonics The algorithm presents some drawbacks, namely, the arbitrarily choice of the windows size of the mask used to compute the -image. This in its turn affects intensively the defect detection of the algorithm. Indeed if the mask size is chosen relatively large (such as 15 × 15) this will homogenize even some different regions and then this will cause some false alarms. If the mask size is chosen relatively small (such as 3 × 3 or 5 × 5) this will induce a poor homogenization and, therefore, similar areas (especially in stochastic textures) will be considered as different areas and may be seen as defects by the algorithm.