Texture classification of fabric defects using machine learning

Received Nov 25, 2019 Revised Feb 29, 2020 Accepted Mar 9, 2020 In this paper, a novel algorithm for automatic fabric defect classification was proposed, based on the combination of a texture analysis method and a support vector machine SVM. Three texture methods were used and compared, GLCM, LBP, and LPQ. They were combined with SVM’s classifier. The system has been tested using TILDA database. A comparative study of the performance and the running time of the three methods was carried out. The obtained results are interesting and show that LBP is the best method for recognition and classification and it proves that the SVM is a suitable classifier for such problems. We demonstrate that some defects are easier to classify than others.


INTRODUCTION
In order to maintain the high quality standards established for the clothing industry, Textile manufacturers have to monitor the quality of their products. Therefore, textile quality control is a key factor for the increase of competitiveness of their companies. Textiles faults have traditionally been detected by human visual inspection; skilled worker could at most detect and distinguish 70% of all fabric defects. Then, some defects are classified as reparable because they can be processed through some usual operations by workers and will leave no trace after that. In the other hand, those irreparable defects have a great impact on the quality of cloth which should be eliminated in production and later picked out as many as possible.
That's why we should work on an automaticvisual inspectionand conceive a system to substitute the role of textile workers and surpass their ability in speed and accuracy.
In the past, a lot of work has been done focused on automatic fabric defect detection [1][2][3][4]. Fabric defect classification has not yet attracted a wide research interest. Also, it is very rare that we have based on the texture of tissue in the automatic visual inspection visualization despite the appearance of new texture methods in recent years such as Features Extracted from Co-occurrence Matrix GLCM [5][6][7], or Local Binary pattern LBP [8,9] or local phase quantization LPQ [10].
The object classification problem is divided into two categories: feature extraction and classification. For the classification, most researchers used the neural network as a classifier, but it is proved that it has shown weak performances and among all, it has a too-long running time [11]. All the research works are based on three approaches: spectral, statistical, and model-based. The statistical approaches, texture features extracted from co-occurrence matrix, mean and standard deviations of sub blocks [12], autocorrelation of images or sub-images [13], and KarhumenLoeve transform have been used for the fabric defects detection [14]. In [15], Bodnarovause the normalized cross-correlation functions for defects detection of textile fabrics. Many model-based techniques for fabric defect detectionwereexisted, for example,

RESEARCH METHOD
In many applications,especially in industrial surface inspection,texture analysis is an important issue in image processing, medical imaging [5], content-based image retrieval remote sensing [8], and document segmentation, etc. Since the acquisition of images, orientation can be a problem. In the past, some texture analysis methods have not considered this, but recently an increasing amount of attention has been given to invariant texture analysis that's why many methods for rotation invariance have been proposed. We note many approaches for texture analysis, which can be classified: statistic, structural, model-based and transform-based methods Figure 1. We have elaborated on an algorithm based on the organigram presented in Figure 2. The train and the test feature vectors obtained are implemented in the support vector machine classifier.

LBP method
TimoOjala has introduced the first LBP operator in 2002, which is evaluated us a robust mean of the texture description of images [22]. In LBP, the pixels are labels by thresholding the 3×3 neighborhood of each pixel with the center value, the result is a binary number. Finally, the histogram of the labels will be enter as a texture descriptor, see Figure 3. Later, this LBP was extended by using neighbourhoodsfor many sizes [22]. If we usea bi-linearly interpolating and the circular neighbourhoods of the pixel values, we can allow any number of pixels in the neighbourhood and radius. So we obtain a new extensionof the LBP called uniform patterns. The LBP operator is called uniform if it contains at most two transitions (bitwise) from 0 to 1 or vice versa when the binary string is considered circular. A is the histogram of labeled image M(x, y), it can be defined as: (1) where n: number of labels produced by the LBP, and I

(2)
A is the histogram and represent the distribution of the local micro-patterns of the texture image. (R, P) are the two parameters in this histogram, P is the points (sampling) on a circle radius R see Figure 4. The features vector of the histogramformed will be the input vector for the SVM classification step.

GLCM method
The Gray-Level Co-Occurrence Matrix (GLCM) is the second texture analysis method tested in this work. It based on an extraction of the texture measured from an image. There are three parameters varied in this method: the distance D whereDis the distance between two pixels, the angle θ, it is the angle between two directions, and the offset [22,23]. For θ, There are four directions: θ = 0°, θ = 45°,θ = 90° and θ = 135° shown in Figure 5. We define the offset parameter:offset= (0 D, -D D,-D 0, -D -D). In our work, we note that we detect a second parameter that affects the result of classification it is the number of gray-levels: the Numlevels. We will demonstrate that this parameter is very influential in the classification results.
The origin of GLCM is the paper [23], Haralick proposed 14 different statistical features in order to estimate the similarity in the texture image. We have tested all the 14 features and we concluded that the most significant ones are 4 features expressed in Table 1, and then we form the GLCM features vector. We consider an image with (N×N) dimension, where m,n formed the coordinates of the GLCM co-occurrence matrix, and C mn is the corresponding element of (m,n).

3. LPQ method
The third method is (LPQ) Local Phase Quantization.It is based on localize ofthe phase information extracted using the 2-D DFT or in other way we can say it uses a Fourier transform in a short-term (STFT) computed over M-by-M neighborhoodrectangular. It was used on the blur invariance property of the Fourier phase spectrum [10]. xis the pixel position of the image f(x) defined by: is the basis vector of the 2-D DFT and u is the frequency, and is another vector containing (M×M) image samples from . As it can be noticed from (4), an efficient way of implementing the STFT is to use 2-D convolutions: for all u.
Computation can be performed using 1-D convolutions for the rows and columns successively since the basic functions are separable, In LPQ only four complex coefficients are considered, corresponding to 2-D frequencies. a is a scalar frequency below the first zero crossing of that satisfies the condition: ∠G(u) = ∠F(u) for all H(u) ≥0 let and (7) Im{.} andRe{.}return imaginary and real parts of a complex number, respectively. The corresponding 8-by-transformation matrix is: For each pixel position this results in a vector: We mark the signs of the real in F(x) and imaginary in F(x) and we record the phase information in the Fourier coefficients by using a simple scalar quantization.
where g j is the j component of the vector: G(x) = [Re{F(x)}, Im{F(x)}] q j are the integer values between 0 and 255 using LPQ: Finally we obtain a feature vector input for the classification phase.

4. Classification phase
We use machine learning and practically the multi-class SVM as a classifier for this study [24]. The main idea of The SVM classifier is to obtain a function f(x) which determines the optimal hyperplane that separe the different classes' zones. We obtain this hyperplane when it managed to separate two classes, or more, of input data points shown in Figure 6. M represents the distance from the hyperplane to the closest point for both classes of data points. In order to maximize the margin M, we consider and the conditions of the problem will be written: (11) where: w: a vector defining the boundary, n: number of input of data of SVM, b: a scalar threshold value.
: input data point, The optimal hyperplane problem of SVM,f(x): (12) : support vector having non-zero Lagrange multiplier and it should be us In this case we can note that there are more than two types of multi-class classifiers in this SVM algorithm. The first is called one against all and the other is called one against one. We have compared the performance of the two types. The type one against one needs to construct one classifier for two arbitrary classes, i.e. k(k-1)/2 classifiers all together. For One against all trains k classifiers (k is the number of classes). In that case, the classifier tries to separate the class i from the rest. Then the two-class classifiers evaluate the input data and vote on their classes. In this study, we have worked with a toolbox named 'simpleSVM'in Matlab [25]. We can conclude that it is a simple and efficient toolbox.

DATABASE
In 1995, the TechnischeUniversitt Hamburgelaborated a database special textile texture images namedTILDA [26], which consists of 8 different classes of woven fabric. The hardest case in this database is that the orientation of the textile is not known. It is an important test of the robustness of our approach. In our study, we have included a new class named "No Defect". The results show that this class regarded as the best available one. It presents many forms related to the textures analysis and recognition Figure 7.

RESULTS AND ANALYSIS
We have chosen to use 5 classes of woven fabric defects, "Hole", "Kink", Missing weft", "oil satin", and "No defect"; each class contains 100 images: 20 images for training and 80 for the test. In total, we have used 500 samples from the TILDA database see Table 2. The samples are picking randomly.
In order to compare the three proposed methods in resolving the problem of classification of woven fabric images, we have started with the GLCM one. In Figure 8, we present the performances of classification using the followingGLCM parameters (contrast, energy, homogeneity, correlation) and varying the offset values. The results of classification presented in Figure 8 shows that the contrast gives a better classification result with 92% compared to other parameters: homogeneity, energy, and correlations. With the GLCM method we remark that we obtained the best percentage of the successful classified images is 98.25%. It is obtained with the couple (offset,Numlevels)=(6, 3), and the running time is about 44.84 seconds as showed in Figure 9 and Table 3.   With the LBP method, we varied two parameters (R, P) and we obtained 99.75 % as the best result percentage illustrated in Table 4. We note that this result is obtained with LBP method and with the couple (1,16) and in a running time equal to 474.49 seconds. We can conclude that the percentage of this method is higher than the GLCM while the disadvantage it is long run time shown in Figure 10.  With the LPQ method, we obtain us a result with the combination of the four parameters (win_size, decor, freqstem, and mode)=(3,1,2,h) and the result is about 90.5% shown in Table 5. This method seems to be less accurate than the two other methods. The detailed percentage of correctly classifications for each method is illustrated in Figure 7. We notice that the images with no defects 'ND' are easier to classify than the others. Furthermore, the method LBP provides a good classification that reached 98.75% with a short time 16.18s. We can say that the GLCM method can give a good classification rate but with a longer time.
The LPQ method is characterized by its short running time and its classification rate lower than the other techniques precisely of the "Hole" class. Another important result concerning the SVM classifier algorithm is determined; more detailed results are presented in Figure 11. The approach "1vs1" increases the classification rate more than the "1vsall". For example, the LBP method with parameters (1, 16) leads to 99.75%, whereas with the approach "1vsall" we obtained 99.25 %.  Figure 11. Comparison of performance between two multiclass "1vs 1" and "1vs all"

CONCLUSION
We have studied the problem of automatic classification of the woven fabric defects based on texture of the images. The presented work consists on a comparative study of three different approaches: GLCM, LBP and LPQ. Using the GLCM method, after studying the different statistical features, we conclude that only 4 are the most significant Contrast, Homogeneity, correlation, and energy. The best one is the contrast. With this method, we remark that the best performance result ofclassification is about of 98.25% with a 44.84 seconds running time. With the LBP method, based on the property of local image textures and their occurrence histogram, we obtained 97.25 % as the best result percentage with a running time about 16.18 seconds only.
The third method LPQ is based on local frequency coefficient; it showed not bad results with 88.5% performance and 22.36 seconds. The established study proves that SVM is a suitable classifier for such problems. A TILDA database is used to test our algorithm. Some defects which are easier to classify than others, for example, unrelated corpus, hole, and oil satin are easier to classify. In conclusion, we remark that LBP method is the best method for this problem of recognition and classification woven defects, it is characterized also by good running time ISSN: 2088-8708  Texture classification of fabric defects using machine learning (Yassine Ben Salem) 4399