# Fabric Defect Detection Based on Pattern Template Correction

Authors: Xingzhi Chang; Chengxi Gu; Jiuzhen Liang; Xin Xu
Journal: Mathematical Problems in Engineering
 (2018)

---

## Abstract

This paper proposes a novel template-based correction (TC) method for the defect detection on images with periodic structures. In this method, a fabric image is segmented into lattices according to variation regularity, and correction is applied to reduce the effect of misalignment among lattices. Also, defect-free lattices are chosen for establishing an average template as a uniform reference. Furthermore, the defect detection procedure is composed of two steps, namely, defective lattices locating and defect shape outlining. Defective lattices locating is based on classification for defect-free and defective patterns, which involves an improvedE-V method with template-based correction and centralized processing, while defect shape outlining provides pixel-level results by threshold segmentation. In this paper we also present some experiments on fabric defect detection. Experimental results show that the proposed method is effective.


---

## Body

## 1. Introduction

Fabric defect detection has drawn a lot of attention in recent years. Although many automated fabric defect detection methods have been proposed in [1, 2], these methods face the following questions: (1) defect position locating, (2) defect shape outlining, (3) detection time consumption, and (4) detected results evaluation.In general, fabrics can be divided into two categories: unpatterned and patterned. Unpatterned fabrics are usually solid-colored with simple structures. There are many defect detection methods for this type of fabrics, including morphological filter [3], Fourier transforms [4–6], Gabor [7, 8], wavelet [9–12], Markov random field [13, 14], sparse dictionary reconstruction [15–17], neural network [18–20], and support vector machine [21, 22]. Patterned fabrics are in periodic variations with complicated pattern features. To deal with this kind of fabrics, many methods such as WGIS [23], BB [24], RB [25], ID [26], and ER [27] are proposed. For unpatterned fabrics, the key problem is to reduce the influence of texture features. This paper focuses on patterned fabric defect detection.The patterned fabric detection methods can be further classified into three categories:(1) partition-matching approach, (2) statistical approach, and (3) modal-based approach.(1) Partition-matching approach includes the WGIS [23] and ER [27] methods. After Haar wavelet decomposition, the WGIS method uses a defect-free partition to perform moving subtraction operation on images to obtain decision boundaries. The ER method obtains the decision boundaries by random competitions. However, the detection results of these two methods are not stable because of the randomness of defect-free partition selection during the training phase.(2) Statistical approach includes the BB [24] and RB [25] methods. By different combinations of moving average and standard deviation, the BB and RB methods obtain the decision boundaries. Although these methods carried out by threshold segmentation are effective, their excessive model parameters lead to overreliance on human experience.(3) Modal-based approach includes the ID [26] method. The ID method decomposes an image into cartoon part and texture part. Then, the detection is realized by converting the decomposed cartoon image into a binary image. But this method is unpractical for requiring a defect-free image which is most similar to the defective image to obtain the optimized parameters for image decomposition.We can see from the previously proposed methods that the features they obtained from defect-free partitions are only used to determine boundaries or optimize the parameters in image decomposition. After that, these methods directly detect image defects at pixel level, resulting in the false inspection of some pixels.Based on the previous problems, we propose a novel two-step template-based correction method. Our contributions can be summarized as follows:(1) We propose an adaptive lattice segmentation method, which can automatically segment the images with periodic structures into lattices. Segmented lattices contain roughly same pattern features, providing favorable conditions for feature extraction, analysis, and comparison.(2) To make the detection results stable, we establish an average template as a uniform reference. Template-based correction which improves detection robustness and accuracy is used in process of template establishing and detection to reduce the effect of misalignment among lattices. Besides, it can also enhance the difference among normal and defective blocks to make feature extraction and defect detection more effective.(3) In order to make the defect detection both efficient and accurate, we divide the detection process into two steps: defective lattices locating and defect shape outlining. The former provides lattice-level rough defect regions and the latter provides pixel-level outlining defect regions.The experiments are conducted on fabric databases with ground-truth images, and our TC method achieves 0.7868 TPR and 0.2158 PPV for box-patterned fabrics using 26 defective images, 0.8914 TPR and 0.2089 PPV for star-patterned fabrics using 25 defective images, and 0.9811 TPR and 0.2209 PPV for dot-patterned fabrics using 30 defective images in defective lattices locating. Besides, the TC method achieves 0.5863 TPR and 0.5237 PPV for box-patterned fabrics, 0.4587 TPR and 0.5201 PPV for star-patterned fabrics, and 0.5901 TPR and 0.6459 PPV for dot-patterned fabrics in defect shape outlining. These results are comparable with the developed methods.The rest of the paper is organized as follows. In Section2, we introduce the originalE-V method. The proposed TC method is introduced in Section 3. The performance of TC method and the comparison of WGIS, BB, RB, and ER methods are presented in Section 4. At last, Section 5 concludes the paper.


## 2. The OriginalE-V Method

The originalE-V method [28, 29] is proposed for defective lattices classification and it evaluates theE andV values with a process of circular shift and moving subtraction method (similar to the GIS method [23]). For convenience, the key equations are outlined below.Considering two lattices, a testing sampleA=Ax,y and a defect-free template B=Bx,y size of r×c pixels, the process of circular shiftH ofB produces r×c new templates such that Bij=H[B] is defined as(1)B11=B1,1B1,2⋯B1,cB2,1B2,2⋯B2,c⋮⋮⋮Br,1Br,2⋯Br,c,⋮,B1c=B1,cB1,1⋯B1,c-1B2,cB2,1⋯B2,c-1⋮⋮⋮Br,cBr,1⋯Br,c-1,Br1=Br,1Br,2⋯Br,cB1,1B1,2⋯B1,c⋮⋮⋮Br-1,1Br-1,2⋯Br-1,c,⋮,Brc=Br,cBr,1⋯Br,c-1B1,cB1,1⋯B1,c-1⋮⋮⋮Br-1,cBr-1,1⋯Br-1,c-1.H [ B ] is regarded as a process of replicating the matrix B itself by shifting rows or columns. Then the 1-norm metric between A and Bij is defined as(2)uijA,Bij=∑x=1r∑y=1cAx,y-Bx,yr×c.Thus, theE and V values are defined as(3)EA,B=∑i=1r∑j=1cuijA,Bijr×c=∑i=1r∑j=1cA-Bijr×c2,VA,B=∑i=1r∑j=1cEA,B-uijA,Bij2r×cThe upper and lower decision boundaries ofE-V value are trained to figure out defective lattices from testing lattices. The details of mathematical definitions and proofs are stated in [28].Although overall detection success rate of the originalE-V method has reached 93.28% [28, 29] in wallpaper groups, it is not suitable for the misalignment and distortion situation. When illumination of input images is not uniform, the detection accuracy declines seriously. Apart from this, it is also difficult for the originalE-V method to detect small defects.


## 3. The TC Method

By applying circular shift, the proposed TC method can reduce the effect of misalignment and can also reinforce the sensitivity of defect detection. Through the introduction of a uniform template, the TC method changes the calculation method ofE andV values to optimize the selection of decision boundaries and ensure the accuracy of defective lattice locating. Pixel-level detection result is achieved by threshold segmentation on the located defective lattices. In short, the TC method includes preprocessing phase, template establishing phase, training phase, and testing phase.


### 3.1. Preprocessing Phase

Preprocessing of the TC method includes grayscale conversion, mean filtering with window size of3×3, and lattice segmentation. The grayscale conversion can simplify the detection and the mean filtering helps in smoothing the fabric image to make the subsequent threshold determination more reliable. After mean filtering, the image size is converted from 256×256 to 254×254. Lattice segmentation can segment images into lattices to obtain lattice-level features.The lattice segmentation of TC method can be briefly described as follows: For each patterned fabric imageI with periodic structures, we define a loss function f(r∗,c∗) to obtain the ideal pattern size(4)r,c=argmin⁡fr∗,c∗,where r∗ and c∗ are denoted as the size of segmented blocks; r and c are considered as the ideal pattern size. Image I size of R×C is segmented into [R/r∗]×[C/c∗] blocks in the same size. Furthermore, f(r∗,c∗) is defined as follows: (5)fr∗,c∗=1r∗×c∗∑x=1r∗∑y=1c∗S2x,y,where S2(x,y) represents the variance among the segmented blocks.Considerm=[R/r∗], n=[C/c∗], and I(x,y) is the pixel value in the xth row and yth column of the image I. Then, X¯ is defined as the mean matrix of all blocks: (6)X¯=1m×n∑i=0m-1∑j=0n-1Ix+i×r∗,y+j×c∗.Then,S2(x,y) is defined as (7)S2x,y=1m×n∑i=0m-1∑j=0n-1Ix+i×r∗,y+j×c∗-Xx,y¯2,where x∈[1,r∗], y∈[1,c∗].However, since the patterned fabric images are in periodic variations, there are many combinations ofr∗ and c∗ that minimize (4). In order to find the proper pattern size, we suppose that the minimum values obtained in the vertical direction are r1,r2,…,rm and the minimum values obtained in the horizontal direction are c1,c2,…,cn,r and c are defined as (8). Segmentation on images are shown in Figure 1. (8)r=medianr1,r22,…,rmm,c=medianc1,c22,…,cnn.Figure 1
Lattice segmentation. (a) Box-patterned fabric. (b) Star-patterned fabric. (c) Dot-patterned fabric.
(a) (b) (c)In Figure1, the size of the box pattern is 24×26, the size of the star pattern is 16×21, and the size of the dot pattern is 36×27. Partial image regions cannot be segmented because they are not satisfied with the size of a single cycle (at the right side and the bottom) and these parts will not be detected during the testing stage. Thus, the size of resultant box-patterned images is 240×234, the size of resultant star-patterned images is 240×252, and the size of resultant dot-patterned images is 252×243. In patterned fabric images, distortion is an unavoidable problem and it will result in slight misalignment between two lattices. Therefore, it is very necessary to correct the obtained segmented lattices.


### 3.2. Template Establishing Phase

In order to highlight the pattern features, we use defect-free lattices to establish an average template. To reduce the effect of misalignment mentioned in Section3.1, we introduce a correction method based on circular shift.(  1) Definitions of Correction. The definitions of correction are concluded as follows. Suppose A is a lattice to be corrected and B is a defect-free lattice. To minimize the difference between A and B, the process of circular shift of the TC method is defined as the following model.(9)p,q=argmin⁡B-Tvp∗·A·Thq∗22,where p∗ is the number of rows shifted in the vertical direction and q∗ is the number of columns shifted in the horizontal direction, p∗∈[0,r-1], and q∗∈[0,c-1]. Tv and Th are two matrices sizes of r×r and c×c, which are denoted as follows:(10)Tv=0⋯011⋯00⋮⋱⋮⋮0⋯10r×r,Th=0⋯011⋯00⋮⋱⋮⋮0⋯10c×c.The specific process of correction is shown in Figure2.Figure 2
The process of correction.After calculatingp and q by (9), the lattice A is divided into two parts in the horizontal direction size q×r and size (c-q)×r. Then, we move the former part to the right of the latter part to finish the horizontal shift. Similar to the process in the horizontal direction, the shift is also applied in the vertical direction. After that, we obtained corrected lattice.(  2) Template Establishing. After lattice segmentation and correction, we have finished the preparation of the uniform template establishing. Lattices selected fromk different defect-free images (in our experiment, lattices are selected in the top left, bottom left, top right, and bottom right corner of each image), noted as Ui,  i=1,2,…,W,  W=4×k, are used for establishing the template.(11)TMx,y=1WY1x,y+Y2x,y+⋯+YWx,y,where TM represents the template and x∈[1,r], y∈[1,c]. Yi(i>1) which is corrected according to U1 represents the corrected Ui and Y1=U1. To reduce the impact of imbalanced illumination, the lattices we selected are from corners of defect-free images. When the parameter k increases, the features extracted from the template will be more reliable and detection results will be more accurate.


### 3.3. Training Phase

The training phase of the TC method involves an improvedE-V method. By quantifying the subtractions among defect-free lattices and the template, we can determine the decision boundaries by analyzing the numerical distribution of these values. The details of the improvedE-V method are as follows. Suppose A is a lattice that has been corrected by using the template TM. In order to reduce the influence of illumination variations, A and TM have been centralized in advance. u, E, and V in (2) and (3) are modified as (12)uNEWA,TM=Ax,y-A¯-TMx,y-TM¯,(13)ENEWA,TM=∑x=1r∑y=1cuNEWA,TMx,yr×c,(14)VNEWA,TM=1r×c∑x=1r∑y=1cuNEWA,TMx,y-ENEWA,TM2,where A¯ and TM¯ are mean values of A and TM, respectively. (15)A¯=1r×c∑x=1r∑y=1cAx,y,TM¯=1r×c∑x=1r∑y=1cTMx,y.SupposeA is a defect-free lattice, the subtraction matrix between A and TM can be denoted by (16)l≈TM-A,where l is a matrix of difference in grayness caused by the varying illuminations of input images or lattices. Therefore, u in (12) can be modified as (17)uNEWA,TM≈TM-TM¯-TM+l-TM¯-l¯=TM-TM¯-TM-l+TM¯+l¯=l-l¯.Under the premise that the illumination is approximately the same in the neighborhood,ENewA,TM≈1/r×c∑l¯-l≈0. Similarly, VNewA,TM≈0.SupposeA is a lattice with defect, the subtraction matrix between A and TM can be denoted by(18)l+d≈TM-A,where d is a matrix of defects. Then, u can be denoted as(19)uNEWA,TM≈TM-TM¯-TM+d+l-TM¯-l¯-d¯=l¯-l+d¯-d≈d¯-d.Because of the varying types of fabric defects, the matrixd is unpredictable. In this case, the values of E and V are greater than 0. We can see from the definition of the improvedE-V method that lattices which are more similar to the template have smaller E and V values (the minimum value is 0).We useK defect-free images for training and there is no overlapping with thek images used for template establishing (for dot-patterned and box-patterned fabric, K=30-k; for star-patterned fabric, K=25-k). After segmentation and correction, we compute the values of E and V between the corrected lattice and the template. The corrected lattices are denoted as Aij, where i=1,2,…,G,j=1,2,…,K.G=90 for box-patterned fabric, G=180 for star-patterned fabric, and G=63 for dot-patterned fabric. The maximum E and V values are denoted as Ej=max⁡(ENEWAij,TM) and Vj=max⁡(VNEWAij,TM), and the boundaries BE and BV are defined as (20)BE=1K∑j=1KEj,BV=1K∑j=1KVj.


### 3.4. Testing Phase

The testing phase of the TC method includes two steps: defective lattices locating and defect shape outlining.(  1) Defective Lattice Locating. With the E and V values between the testing lattices and the template, we can locate the defective lattices by taking advantage of the decision boundaries acquired during the training phase. The E and V values of each testing lattice Li are calculated by the improvedE-V method, which are denoted as ENewLi,TM and VNewLi,TM, where i=1,2,…,G.If0≤ENewLi,M≤BE and 0≤VNewLi,TM≤BV, Li is considered defect-free. Otherwise, Li is considered defective.(  2) Defect Shape Outlining. In order to figure out pixel-level results after locating defective lattices in the images, we propose a segmentation method based on threshold. For each detected defective lattice LD, we can get a binary resultant lattice through following equation:(21)LDx,y=0TMx,y-λ×σx,y≤LDx,y≤TMx,y+λ×σx,y1elseσx,y=1W∑i=1WYix,y-TMx,y2,where TM is the template in (11). σ(x,y) represents the standard deviation of Y(x,y). λ is a constant. Thresholds are determined without centralized processing for the reason that mean value and standard deviation are good measures for indicating abnormity of a set of data; therefore the thresholds composed of mean value and standard deviation have a good tolerance for normal variations. Besides, the defect-free pixels in the lattice are greatly influenced by the defective pixels after the centralized processing if defects are large. Defect-free pixels will be false detected under this situation. Normally, λ is equal to 2 or 3 according to the three-sigma rule [30]. If λ is equal to 2, more pixels will be mistaken for defective and TPR values will increase while PPV values will decrease. If λ is equal to 3, some defective pixels will be mistaken for defect-free and TPR values will decrease while PPV values will increase.SinceLD is corrected, several rows and columns will be shifted. In order to make the testing results consistent with the original defects, we do the following operation on LD: (22)LD∗=Tvr-p·LD·Thc-q,where Tv and Th are matrices defined in (10); r and c are the sizes of LD. For each detected defective lattice LD, p and q are calculated in (9).


## 3.1. Preprocessing Phase

Preprocessing of the TC method includes grayscale conversion, mean filtering with window size of3×3, and lattice segmentation. The grayscale conversion can simplify the detection and the mean filtering helps in smoothing the fabric image to make the subsequent threshold determination more reliable. After mean filtering, the image size is converted from 256×256 to 254×254. Lattice segmentation can segment images into lattices to obtain lattice-level features.The lattice segmentation of TC method can be briefly described as follows: For each patterned fabric imageI with periodic structures, we define a loss function f(r∗,c∗) to obtain the ideal pattern size(4)r,c=argmin⁡fr∗,c∗,where r∗ and c∗ are denoted as the size of segmented blocks; r and c are considered as the ideal pattern size. Image I size of R×C is segmented into [R/r∗]×[C/c∗] blocks in the same size. Furthermore, f(r∗,c∗) is defined as follows: (5)fr∗,c∗=1r∗×c∗∑x=1r∗∑y=1c∗S2x,y,where S2(x,y) represents the variance among the segmented blocks.Considerm=[R/r∗], n=[C/c∗], and I(x,y) is the pixel value in the xth row and yth column of the image I. Then, X¯ is defined as the mean matrix of all blocks: (6)X¯=1m×n∑i=0m-1∑j=0n-1Ix+i×r∗,y+j×c∗.Then,S2(x,y) is defined as (7)S2x,y=1m×n∑i=0m-1∑j=0n-1Ix+i×r∗,y+j×c∗-Xx,y¯2,where x∈[1,r∗], y∈[1,c∗].However, since the patterned fabric images are in periodic variations, there are many combinations ofr∗ and c∗ that minimize (4). In order to find the proper pattern size, we suppose that the minimum values obtained in the vertical direction are r1,r2,…,rm and the minimum values obtained in the horizontal direction are c1,c2,…,cn,r and c are defined as (8). Segmentation on images are shown in Figure 1. (8)r=medianr1,r22,…,rmm,c=medianc1,c22,…,cnn.Figure 1
Lattice segmentation. (a) Box-patterned fabric. (b) Star-patterned fabric. (c) Dot-patterned fabric.
(a) (b) (c)In Figure1, the size of the box pattern is 24×26, the size of the star pattern is 16×21, and the size of the dot pattern is 36×27. Partial image regions cannot be segmented because they are not satisfied with the size of a single cycle (at the right side and the bottom) and these parts will not be detected during the testing stage. Thus, the size of resultant box-patterned images is 240×234, the size of resultant star-patterned images is 240×252, and the size of resultant dot-patterned images is 252×243. In patterned fabric images, distortion is an unavoidable problem and it will result in slight misalignment between two lattices. Therefore, it is very necessary to correct the obtained segmented lattices.


## 3.2. Template Establishing Phase

In order to highlight the pattern features, we use defect-free lattices to establish an average template. To reduce the effect of misalignment mentioned in Section3.1, we introduce a correction method based on circular shift.(  1) Definitions of Correction. The definitions of correction are concluded as follows. Suppose A is a lattice to be corrected and B is a defect-free lattice. To minimize the difference between A and B, the process of circular shift of the TC method is defined as the following model.(9)p,q=argmin⁡B-Tvp∗·A·Thq∗22,where p∗ is the number of rows shifted in the vertical direction and q∗ is the number of columns shifted in the horizontal direction, p∗∈[0,r-1], and q∗∈[0,c-1]. Tv and Th are two matrices sizes of r×r and c×c, which are denoted as follows:(10)Tv=0⋯011⋯00⋮⋱⋮⋮0⋯10r×r,Th=0⋯011⋯00⋮⋱⋮⋮0⋯10c×c.The specific process of correction is shown in Figure2.Figure 2
The process of correction.After calculatingp and q by (9), the lattice A is divided into two parts in the horizontal direction size q×r and size (c-q)×r. Then, we move the former part to the right of the latter part to finish the horizontal shift. Similar to the process in the horizontal direction, the shift is also applied in the vertical direction. After that, we obtained corrected lattice.(  2) Template Establishing. After lattice segmentation and correction, we have finished the preparation of the uniform template establishing. Lattices selected fromk different defect-free images (in our experiment, lattices are selected in the top left, bottom left, top right, and bottom right corner of each image), noted as Ui,  i=1,2,…,W,  W=4×k, are used for establishing the template.(11)TMx,y=1WY1x,y+Y2x,y+⋯+YWx,y,where TM represents the template and x∈[1,r], y∈[1,c]. Yi(i>1) which is corrected according to U1 represents the corrected Ui and Y1=U1. To reduce the impact of imbalanced illumination, the lattices we selected are from corners of defect-free images. When the parameter k increases, the features extracted from the template will be more reliable and detection results will be more accurate.


## 3.3. Training Phase

The training phase of the TC method involves an improvedE-V method. By quantifying the subtractions among defect-free lattices and the template, we can determine the decision boundaries by analyzing the numerical distribution of these values. The details of the improvedE-V method are as follows. Suppose A is a lattice that has been corrected by using the template TM. In order to reduce the influence of illumination variations, A and TM have been centralized in advance. u, E, and V in (2) and (3) are modified as (12)uNEWA,TM=Ax,y-A¯-TMx,y-TM¯,(13)ENEWA,TM=∑x=1r∑y=1cuNEWA,TMx,yr×c,(14)VNEWA,TM=1r×c∑x=1r∑y=1cuNEWA,TMx,y-ENEWA,TM2,where A¯ and TM¯ are mean values of A and TM, respectively. (15)A¯=1r×c∑x=1r∑y=1cAx,y,TM¯=1r×c∑x=1r∑y=1cTMx,y.SupposeA is a defect-free lattice, the subtraction matrix between A and TM can be denoted by (16)l≈TM-A,where l is a matrix of difference in grayness caused by the varying illuminations of input images or lattices. Therefore, u in (12) can be modified as (17)uNEWA,TM≈TM-TM¯-TM+l-TM¯-l¯=TM-TM¯-TM-l+TM¯+l¯=l-l¯.Under the premise that the illumination is approximately the same in the neighborhood,ENewA,TM≈1/r×c∑l¯-l≈0. Similarly, VNewA,TM≈0.SupposeA is a lattice with defect, the subtraction matrix between A and TM can be denoted by(18)l+d≈TM-A,where d is a matrix of defects. Then, u can be denoted as(19)uNEWA,TM≈TM-TM¯-TM+d+l-TM¯-l¯-d¯=l¯-l+d¯-d≈d¯-d.Because of the varying types of fabric defects, the matrixd is unpredictable. In this case, the values of E and V are greater than 0. We can see from the definition of the improvedE-V method that lattices which are more similar to the template have smaller E and V values (the minimum value is 0).We useK defect-free images for training and there is no overlapping with thek images used for template establishing (for dot-patterned and box-patterned fabric, K=30-k; for star-patterned fabric, K=25-k). After segmentation and correction, we compute the values of E and V between the corrected lattice and the template. The corrected lattices are denoted as Aij, where i=1,2,…,G,j=1,2,…,K.G=90 for box-patterned fabric, G=180 for star-patterned fabric, and G=63 for dot-patterned fabric. The maximum E and V values are denoted as Ej=max⁡(ENEWAij,TM) and Vj=max⁡(VNEWAij,TM), and the boundaries BE and BV are defined as (20)BE=1K∑j=1KEj,BV=1K∑j=1KVj.


## 3.4. Testing Phase

The testing phase of the TC method includes two steps: defective lattices locating and defect shape outlining.(  1) Defective Lattice Locating. With the E and V values between the testing lattices and the template, we can locate the defective lattices by taking advantage of the decision boundaries acquired during the training phase. The E and V values of each testing lattice Li are calculated by the improvedE-V method, which are denoted as ENewLi,TM and VNewLi,TM, where i=1,2,…,G.If0≤ENewLi,M≤BE and 0≤VNewLi,TM≤BV, Li is considered defect-free. Otherwise, Li is considered defective.(  2) Defect Shape Outlining. In order to figure out pixel-level results after locating defective lattices in the images, we propose a segmentation method based on threshold. For each detected defective lattice LD, we can get a binary resultant lattice through following equation:(21)LDx,y=0TMx,y-λ×σx,y≤LDx,y≤TMx,y+λ×σx,y1elseσx,y=1W∑i=1WYix,y-TMx,y2,where TM is the template in (11). σ(x,y) represents the standard deviation of Y(x,y). λ is a constant. Thresholds are determined without centralized processing for the reason that mean value and standard deviation are good measures for indicating abnormity of a set of data; therefore the thresholds composed of mean value and standard deviation have a good tolerance for normal variations. Besides, the defect-free pixels in the lattice are greatly influenced by the defective pixels after the centralized processing if defects are large. Defect-free pixels will be false detected under this situation. Normally, λ is equal to 2 or 3 according to the three-sigma rule [30]. If λ is equal to 2, more pixels will be mistaken for defective and TPR values will increase while PPV values will decrease. If λ is equal to 3, some defective pixels will be mistaken for defect-free and TPR values will decrease while PPV values will increase.SinceLD is corrected, several rows and columns will be shifted. In order to make the testing results consistent with the original defects, we do the following operation on LD: (22)LD∗=Tvr-p·LD·Thc-q,where Tv and Th are matrices defined in (10); r and c are the sizes of LD. For each detected defective lattice LD, p and q are calculated in (9).


## 4. Performance Evaluation

In our experiment, we use a total of 156 fabric images provided by Industrial Automation Research Laboratory from Dept. of Electrical and Electronic Engineering of Hong Kong University. In detail, 71 defective images of size256×256 in 24-bit depth from the box-, star-, and dot-patterned fabric databases are used for evaluation and 85 defect-free images are used in training phase. The box-patterned fabric database contains 30 defect-free and 26 defective images, the star-patterned database contains 25 defect-free and 25 defective images, and the dot-patterned fabric database contains 30 defect-free and 30 defective images. All defective images have corresponding binary ground-truth images that illustrate the defective regions as white (value 1) and the defect-free regions as black (value 0). There are 5 defect types for box and star pattern, that is, Broken End, Hole, Netting Multiple, Thick Bar, and Thin Bar. There is one more defect type called Knots for dot pattern. Moreover, WGIS (2005), BB (2006), RB (2009), and ER (2016) are implemented for comparison purpose. All the experiments are conducted on a desktop computer with an Intel Pentium J2900 2.41-GHz processor and 4.00 GB memory. The algorithm is implemented in Matlab 7.14.The rest of this section is organized as follows. Section4.1 introduces the description of evaluation metrics. Section 4.2 introduces the tuning of the parameters of the TC method. Section 4.3 introduces the results of the original and the improvedE-V method. Section 4.4 introduces overall results of the TC method.


### 4.1. Description of Evaluation Metrics

A number of metrics are obtained for evaluation, true positive (TP), false positive (FP), true negative (TN), false negative (FN), accuracy (ACC), true positive rate (TPR), false positive rate (FPR), positive predictive value (PPV), and negative predictive value (NPV). Related definitions of these metrics can be found in [23], where ACC = (TP + TN)/(TP + FP + TN + FN), and usually the value of TN is larger than TP by more than one order of magnitude. Compared with TN, the value of TP is negligible. Thus, ACC is not a good evaluation metric if defective region is small. To evaluate the detection more correctly, we use the f value (f measure) in this paper. (23)f=α2+1×TPR×PPVTPR+α2×PPV,where α is the weight and α is set to 1 in [31, 32]. Thus (23) can be modified as (24)f=2×TPR×PPVTPR+PPV=2×11/TPR+1/PPV=2×1TP+FN/TP+TP+FP/TP=2×TP2×TP+FP+FN.The above equation shows that when the FN and FP increase, in other words, the detection results and manual-labeled results are not consistent, thef value decreases. Smaller values of FN and FP indicate better detection results and the f value is closer to 1. This evaluation index only considers TPR and PPV, which avoids the detection problem of the small defective regions mentioned above. Thus, ACC is replaced by f value in this paper.


### 4.2. Tuning the Parameters of the TC Method

The TC method involves 2 parameters to be predefined, the number of images for establishing the templatek (mentioned in Section 3.2), and the number for threshold segmentations λ (mentioned in Section 3.4).Experiments on the star-, box-, and dot-patterned fabrics are performed withk of 4, 6, 8, 10, and 15 and λ of 2 and 3. Figure 3 illustrates the average f values plots of box-patterned (Figure 3(a)), star-patterned (Figure 3(b)), dot-patterned fabrics (Figure 3(c)) with different parameters k and λ.Figure 3
f value versus constant k and λ for (a) box-patterned, (b) star-patterned, and (c) dot-patterned fabrics.
(a) (b) (c)From Figure3(a) for box-patterned fabrics and Figure 3(b) for star-patterned fabrics, the f value plots are in a rising tendency when the parameter k increases. As is mentioned previously, if the number of defect-free patterns for template establishing increases, the effect of random errors among defect-free patterns can be reduced, which makes the method more accurate. For star- and box-patterned fabrics, although f value increases when parameter k increases, the change rate of plots decreases.Figure3(a) shows that, for box-patterned fabrics, k=15 and λ=3 provide the highest f value. The maximal deviation is about 0.04 with different λ. For the box-patterned fabrics, except for Thin Bar and Thick Bar, pixel values of other defects are close to backgrounds, which makes it hard for a smaller λ to distinguish defect-free and defective pixels. That is why a larger λ provides higher f values. Figure 3(b) shows that, for star-patterned fabrics, f values of λ=2 and λ=3 are close, which means λ=2 and λ=3 provide similar detection results. When k changes from 4 to 6, f value decreases by 0.01, which is due to the slight differences among the patterns used for template establishing.The regularity in Figure3(c) is poor for dot-patterned fabrics because the dot-patterned defective images are mostly man-made. The maximal deviation in Figure 3(c) is about 0.01. The TC method achieves similar results with different parameters k and λ.Thus, in our experiments,k is equal to 15 and λ is equal to 3.Figure4 shows detection results of several images when parameterk changes between 4, 6, 8, and 15 with λ=3. It is clear that when k increases, some small white dots are removed. The detection results are more accurate as analyzed above.Figure 4
Differences of several images when parameterk changes.


### 4.3. Results of the Original and the ImprovedE-V Method

Detection success rate (DSR) is defined as the percentage of fraction of the amount of correct detection of lattices over the total number of lattices [28], and the numerical results are presented in Table 1. The parameter k is equal to 15 and λ is equal to 3. From Table 1, the improvedE-V method (mentioned in training phrase) shows higher DSR than the original one in the overall results (0.9540 versus 0.8883 for box-patterned fabric, 0.9573 versus 0.8559 for star-patterned fabric, and 0.9251 versus 0.9153 for dot-patterned fabric).Table 1
DSR of the original and improvedE-V methods.
Box-patterned Star-patterned Dot-patterned Method Broken End 0.8333 0.9456 0.8921 Original 0.9356 0.9811 0.9492 Improved Hole 0.8911 0.7782 0.9238 Original 0.9578 0.9578 0.9524 Improved Netting Multiple 0.86 0.9589 0.8825 Original 0.9178 0.9811 0.9048 Improved Thin Bar 0.92 0.8367 0.9175 Original 0.96 0.9511 0.9778 Improved Thick Bar 0.937 0.7604 0.9714 Original 0.9537 0.9152 0.9873 Improved Knots Not this type Not this type 0.9048 Original 0.9429 Improved Overall 0.8883 0.8559 0.9153 Original 0.945 0.9573 0.9254 ImprovedFor originalE-V method on box-patterned fabrics, DSR values achieve about 0.85 in Broken End, Hole, and Netting Multiple while DSR values achieve about 0.92 in Thin Bar and Thick Bar. Pixel values of Broken End, Hole, and Netting Multiple are close to backgrounds. However, defects of Thin Bar and Thick Bar are dark-colored, which are easy to be detected. The average DSR of the improvedE-V method for box-patterned fabrics is about 0.94, which means this method can not only detect the obvious defects like Thin Bar and Thick Bar but also detect the defects similar to the backgrounds.For star-patterned fabrics, this fabric is composed of white and black stars with simple structures. The originalE-V method only achieves about 0.8 DSR in Hole, Thin Bar, and Thick Bar. The reason for this phenomenon is similar to the detection on box-patterned fabrics. It is hard for the originalE-V method to detect defects which are similar to backgrounds.For dot-patterned fabrics, defects are man-made with large areas. The original and the improvedE-V methods achieve similar results. These two methods can detect large defects.Figure5 shows some results detected by the originalE-V method and the improvedE-V method. The 1st row displays the defective images. The 2nd row displays the corresponding ground-truth images. The 3rd row displays the defective lattices locating of the originalE-V method. The 4th row displays the defective lattices locating of the improvedE-V method. The 1st and 2nd columns are box-patterned fabrics. The 3rd and 4th columns are star-patterned fabrics. The 5th and 6th columns are dot-patterned fabrics.Figure 5
Comparison of the original and the improvedE-V method.For box- and star-patterned fabrics, although some defective lattices can be located in the image, there are some missing and false cases for the originalE-V method (3rd column). The main reason for missing detection is that defects are similar to the backgrounds. Moving subtraction will lead to insufficient sensitivity in detection. The reason for false detection lies in the misalignment and grayness differences. The improvedE-V method can effectively improve the sensitivity of detection and ensure the DSR of defect detection (4th column).For 5th and 6th rows of dot-patterned fabrics, the two methods can be correctly locating the defective lattices. However, there are false detection situations in 5th row. The proposed TC method contains a subsequent step of pixel-level detection, which can also improve the detection accuracy.In summary, the improvedE-V method proposed in this paper can not only detect large defects but also detect small defects.


### 4.4. Overall Results of the TC Method

In this section, results of the TC and other methods (WGIS, BB, RB, and ER) are presented in two ways,(1) numerical and graphical results and (2) TPR-PPV graphs. The former part shows numerical results of TPR, PPV, FPR, NPV, and f value with some graphical detection results. The latter part shows TPR and PPV in the form of scatter plots. Besides, each scatter also can represent the f value. In this way, the results are presented more intuitively.(  1) Numerical and Graphical Results. Detection of the TC method is divided into two parts: the defective lattices locating and defect shape outlining, short for TC locating and TC outlining, respectively. It must be noted that, because of the preprocessing phrase, the resultant images are smaller than the original images and the resultant images need to be zero padded into size of 256×256.Figure6 depicts the detection results (without zero padding) of TC locating (3rd row) and TC outlining (4th row) with randomly chosen defective images (1st row) and corresponding ground-truth images (2nd row), where the 1st and 2nd columns are the box-patterned defective fabric images; the 3rd and the 4th columns are the star-patterned defective fabric images; the 5th and 6th columns are the dot-patterned defective fabric images. For the star- and box-patterned fabric, the results obtained from TC outlining are close to the manual-labeled results. However, TC outlining on dot-patterned fabric is worse because some small white dots are false detected. Above all, TC outlining performs better than TC locating with more finely defected defect shapes.Figure 6
Several detection results of TC locating and TC outlining.Tables2, 3, and 4, respectively, tabulate the numerical results of each defect type in box-, star-, and dot-patterned fabric images. The results of BB, RB, WGIS, and ER are presented as comparison with results of each part in TC method. For each table, each row represents the average result for a specific method and all rows are categorized based on the defective types.Table 2
Numerical results of different methods on box-patterned fabric.
Box pattern TPR PPV FPR NPV f value Method Broken End 0.9024 0.2883 0.0487 0.9977 0.437 TC locating 0.6671 0.6188 0.0082 0.993 0.642 TC outlining 0.0356 0.0652 0.0098 0.995 0.0461 BB 0.0429 0.0911 0.0084 0.9982 0.0583 RB 0.3639 0.0294 0.2443 0.984 0.0544 WGIS 0.1026 0.3043 0.0069 0.9588 0.1535 ER  Hole 0.695 0.2167 0.0198 0.9977 0.3303 TC locating 0.3856 0.5215 0.0026 0.9953 0.4434 TC outlining 0.0404 0.0342 0.0086 0.9963 0.037 BB 0.0566 0.0529 0.0075 0.9956 0.0547 RB 0.3117 0.0092 0.2553 0.9931 0.0179 WGIS 0 0 0.0003 0.9769 0 ER  Netting Multiple 0.6826 0.1508 0.0607 0.9968 0.2471 TC locating 0.4495 0.3911 0.0112 0.994 0.4183 TC outlining 0.0422 0.0467 0.0099 0.9913 0.0443 BB 0.1983 0.1051 0.0195 0.9966 0.1374 RB 0.33 0.0128 0.2568 0.9887 0.0246 WGIS 0.0015 0.04 0.0004 0.9581 0.0029 ER  Thin Bar 0.8378 0.1177 0.0706 0.9985 0.2064 TC locating 0.7083 0.4759 0.0095 0.9974 0.5693 TC outlining 0.3154 0.2983 0.0078 0.9935 0.3066 BB 0.3221 0.3079 0.0066 0.9958 0.3148 RB 0.269 0.0102 0.242 0.9907 0.0197 WGIS 0.0584 0.0236 0.0451 0.9768 0.0336 ER  Thick Bar 0.8161 0.3189 0.0429 0.9976 0.4586 TC locating 0.7211 0.6114 0.0097 0.9952 0.6618 TC outlining 0.6012 0.5304 0.0105 0.9856 0.5636 BB 0.7975 0.4091 0.0225 0.9847 0.5408 RB 0.4908 0.043 0.2424 0.9877 0.0791 WGIS 0.2276 0.424 0.0168 0.9693 0.2962 ER  Overall 0.7868 0.2185 0.0485 0.9977 0.3359 TC locating 0.5863 0.5237 0.0083 0.995 0.5469 TC outlining 0.207 0.195 0.0093 0.9923 0.1995 BB 0.2835 0.1932 0.0129 0.9942 0.2212 RB 0.3531 0.0209 0.2482 0.9888 0.0391 WGIS 0.078 0.1584 0.0139 0.968 0.0972 ERTable 3
Numerical results of different methods on star-patterned fabric.
Star pattern TPR PPV FPR NPV f value Method Broken End 0.9249 0.1703 0.0294 0.9994 0.2876 TC locating 0.5142 0.4337 0.0042 0.9962 0.4705 TC outlining 0.0283 0.0333 0.0078 0.9899 0.0306 BB 0.0454 0.0752 0.0045 0.9919 0.0566 RB 0.0026 0.0009 0.0356 0.9924 0.0013 WGIS 0.0879 0.0717 0.0116 0.9927 0.079 ER  Hole 0.8970 0.1273 0.0434 0.9995 0.223 TC locating 0.474 0.3932 0.0049 0.9972 0.4298 TC outlining 0.0269 0.0816 0.0016 0.9931 0.0405 BB 0.069 0.2599 0.0012 0.9939 0.109 RB 0.0034 0.0005 0.0366 0.9945 0.0009 WGIS 0.2447 0.1168 0.0123 0.9954 0.1581 ER  Netting Multiple 0.9270 0.3702 0.027 0.9990 0.5291 TC locating 0.4167 0.6683 0.0031 0.9899 0.5133 TC outlining 0.1158 0.3711 0.0042 0.9799 0.1765 BB 0.1523 0.4799 0.0025 0.9834 0.2312 RB 0.0103 0.0088 0.0361 0.9825 0.0095 WGIS 0.1642 0.1261 0.0082 0.9854 0.1426 ER  Thin Bar 0.8277 0.117 0.0738 0.9994 0.2051 TC locating 0.5269 0.4909 0.0063 0.9961 0.5082 TC outlining 0.0676 0.2216 0.0023 0.9882 0.1036 BB 0.0314 0.2769 0.0008 0.9889 0.0564 RB 0 0 0.0365 0.99 0 WGIS 0.4547 0.125 0.0283 0.9945 0.1961 ER  Thick Bar 0.8802 0.2595 0.0813 0.9967 0.4008 TC locating 0.3614 0.6146 0.0071 0.9777 0.4552 TC outlining 0.3067 0.6318 0.0049 0.9688 0.4129 BB 0.1961 0.7711 0.0032 0.9686 0.3127 RB 0.0437 0.0509 0.0344 0.9663 0.047 WGIS 0.6952 0.5452 0.0167 0.9881 0.6111 ER  Overall 0.8914 0.2089 0.051 0.9988 0.3291 TC locating 0.4587 0.5201 0.0051 0.9914 0.4754 TC outlining 0.1091 0.2679 0.0042 0.984 0.1528 BB 0.0988 0.3726 0.0024 0.9853 0.1532 RB 0.012 0.0122 0.0358 0.9851 0.0117 WGIS 0.3293 0.197 0.0154 0.9912 0.2374 ERTable 4
Numerical results of different methods on dot-patterned fabric.
Dot pattern TPR PPV FPR NPV f value Method Broken End 0.9737 0.3031 0.1779 0.9994 0.4623 TC locating 0.3611 0.5679 0.0115 0.9081 0.4415 TC outlining 0.0546 0.7424 0.0009 0.8857 0.1017 BB 0.1423 0.6028 0.0041 0.8884 0.2302 RB 0.5463 0.2559 0.1171 0.9166 0.3485 WGIS 0.3232 0.562 0.0344 0.9226 0.4104 ER  Hole 0.9792 0.1563 0.1521 0.9993 0.2696 TC locating 0.5288 0.4056 0.022 0.9861 0.4591 TC outlining 0.2619 0.5528 0.0065 0.9779 0.3554 BB 0.1509 0.4126 0.0069 0.97 0.221 RB 0.7633 0.1056 0.189 0.9915 0.1855 WGIS 0.6921 0.3063 0.0458 0.9907 0.4247 ER  Netting Multiple 0.939 0.2679 0.1037 0.9972 0.4169 TC locating 0.2967 0.7054 0.0046 0.9718 0.4177 TC outlining 0.2943 0.9081 0.0015 0.9081 0.4445 BB 0.2115 0.9639 0.0005 0.9562 0.3469 RB 0.6391 0.1415 0.1458 0.9828 0.2317 WGIS 0.4561 0.8133 0.0056 0.9782 0.5844 ER  Thin Bar 0.9974 0.1054 0.2182 0.9999 0.1906 TC locating 0.9308 0.6839 0.0118 0.9981 0.7885 TC outlining 0.5371 0.5867 0.0126 0.9839 0.5608 BB 0.5393 0.7517 0.0063 0.9854 0.628 RB 0.6678 0.1123 0.1449 0.991 0.1923 WGIS 0.8056 0.2701 0.058 0.9946 0.4046 ER  Thick Bar 0.9973 0.337 0.3046 0.9992 0.5037 TC locating 0.9354 0.9347 0.0102 0.9899 0.9351 TC outlining 0.6449 0.7574 0.0352 0.9456 0.6966 BB 0.6646 0.8254 0.0231 0.9497 0.7363 RB 0.7324 0.3323 0.1923 0.9614 0.4572 WGIS 0.8596 0.5011 0.1175 0.9766 0.6331 ER  Knots 1 0.1559 0.221 1 0.2697 TC locating 0.4879 0.578 0.0152 0.9795 0.5291 TC outlining 0.3122 0.6685 0.0055 0.9785 0.4256 BB 0.2256 0.6652 0.0044 0.9675 0.3369 RB 0.3934 0.0574 0.1958 0.9781 0.1002 WGIS 0.5346 0.6853 0.0109 0.9814 0.6006 ER  Overall 0.9811 0.2209 0.1963 0.9992 0.3521 TC locating 0.5901 0.6459 0.0126 0.9723 0.5952 TC outlining 0.3508 0.7027 0.0104 0.9466 0.4308 BB 0.3224 0.7036 0.0076 0.9529 0.4166 RB 0.6237 0.1675 0.1642 0.9702 0.2526 WGIS 0.6119 0.523 0.0454 0.974 0.5096 ERFrom Table2 of the box-patterned fabric, overall results of the TC method reach 0.7868 TPR, 0.2185 PPV, 0.0485 FPR, 0.9977 NPV, and 0.3359 f value for TC locating and 0.5863 TPR, 0.5237 PPV, 0.0083 FPR, 0.9950 NPV, and 0.5469 f value for TC outlining. According to the TPR of TC locating, most defective lattices are detected. However, about 0.2 PPV means only about one-fifth of detected pixels are real defective ones. For the results of TC outlining, TPR drops to 0.5863 (25 percent of decrease) but PPV rises to 0.5273 (141 percent of increase). That is the reason that f value of TC outlining is higher than TC locating. The BB and RB provide about 0.05 TPR and PPV values in Broken End and Hole defect detection while these two methods are good competitive rivals for the proposed TC method in Thick Bar defect detection. Also, the BB and RB methods outperform the WGIS and ER methods in Thick Bar and Thin Bar defect detection. The BB and RB methods seem unable to detect small defects like Broken End and Hole but are good at detecting obvious defects like Thin Bar and Thick Bar. The TPR and PPV values of the WGIS method are around 0.35 and 0.02, which means although the WGIS method provides stable results on these five kinds of defects, it is still not practical because of much false detection. According to the results, it is difficult for the ER method to detect fabrics defects with complex structures. Figure 7 depicts the detection results (without zero padding) of the WGIS, RB, and TC outlining; TC outlining performs better than the WGIS and RB in defect types of Broken End, Thin Bar, and Thick Bar. However, TC outlining is not good at detecting defect types of Hole and Netting Multiple. Especially for Hole, only a few defective pixels are detected (2nd row in Figure 7).Figure 7
Box-patterned fabric: (1st column) defective sample names; (2nd column) defective images; (3rd column) ground-truth image; (4th column) detection results of WGIS; (5th column) detection results of RB; (6th column) detection results of TC.From Table3 of the star-patterned fabric, overall results of the TC method reach 0.8914 TPR, 0.2089 PPV, 0.051 FPR, 0.9988 NPV, and 0.3291 f value for TC locating and 0.4587 TPR, 0.5201 PPV, 0.0051 FPR, 0.9914 NPV, and 0.4754 f value for TC outlining. TPR value of TC outlining drops sharply (48 percent of decrease), especially for defect types of Broken End (0.9249 versus 0.5142), Netting Multiple (0.9270 versus 0.4167), and Thick Bar (0.8802 versus 0.3614). This means although the TC method on star-patterned fabric can locate defective lattices correctly, it is difficult to outline the defect shapes. According to the numerical results of other methods, the BB, RB, WGIS, and ER methods provide lower TPR and FPR values than the TC method in Broken End, Hole, Netting Multiple, and Thin Bar defect detection. The ER method shows higher TPR and f value than TC outlining in Thick Bar defect detection. The average TPR values of BB and RB methods are less than 0.2. The BB and RB method detect defects by different combinations of moving average and standard deviation and the star-patterned fabrics consist of black and white stars. It is hard for these statistical approaches to detect dark-colored defects. The ER method has good performances except for Broken End because this kind of defect is small. In Figure 8, TC outlining provides good results of Hole and Thin Bar. However, it is hard to detect dark defects in black backgrounds, such as Netting Multiple (3rd row). Besides, TC outlining provides many false detected white dots, such as Thick Bar (5th row).Figure 8
Star-patterned fabric: (1st column) defective sample names; (2nd column) defective images; (3rd column) ground-truth image; (4th column) detection results of WGIS; (5th column) detection results of RB; (6th column) detection results of TC.From Table4 of the dot-patterned fabric, overall results of the TC method reach 0.9811 TPR, 0.2209 PPV, 0.1963 FPR, 0.9992 NPV, and 0.3521 f value for TC locating and 0.5901 TPR, 0.6459 PPV, 0.0126 FPR, 0.9723 NPV, and 0.5952 f value for TC outlining. TPR values of TC outlining drop sharply on Broken End (0.9737 versus 0.3611) and Netting Multiple (0.9390 versus 0.2967) but it provides highest PPV values on Thick Bar (0.9347). Defects of dot-patterned fabrics are usually large, such as Thick Bar and Knots. However, with obvious texture features, it is hard for these methods to maintain TPR and PPV values. The BB and RB methods provide higher PPV values than the TC, WGIS, and ER methods while the TC, WGIS, and ER methods provide higher TPR values than the BB and RB methods. According to f values, the TC and ER outperform other methods. In Figure 9, the WGIS method provides a better result than RB and TC outlining on Netting Multiple (3rd row) and Knots (6th row). The WGIS and TC outlining perform better than RB on Broken (1st row) and Hole (2nd row) end. These three methods are all good at detection on Thin Bar (4th row) and Thick Bar (5th row) while the WGIS method provides many false detected pixels.Figure 9
Dot-patterned fabric: (1st column) defective sample names; (2nd column) defective images; (3rd column) ground-truth image; (4th column) detection results of WGIS; (5th column) detection results of RB; (6th column) detection results of TC.(  2) TPR-PPV Graphs with Optimized Parameters. Figure 10 shows TPR-PPV graphs between the WGIS, BB, RB, ER, and TC (including TC locating and TC outlining). The TPR-PPV graphs are formulated by the average TPR and PPV values of each defective sample of the dot-, star-, and box-patterned fabrics. TPR estimates how many true defective pixels are detected among the manually labeled defective pixels while PPV estimates how many true defective pixels are among the detected pixels. For performance evaluation, PPV values are much better than FPR. Furthermore, TPR and PPV are usually called recall and precision in information retrieval and natural language processing. In TPR-PPV graphs, a point located closer to the top right corner is regarded as an optimized result.Figure 10
TPR-PPV graphs of detection results on different kinds of fabric. (a) Box-patterned fabric, (b) star-patterned fabric, and (c) dot-patterned fabric.
(a) (b) (c)The magenta stars represent TC locating and the blue crosses represent TC outlining. The red squares, green pentagrams, cyan diamonds, and black hexagrams represent the BB, RB, WGIS, and ER method, respectively. Each mark represents TPR-PPV value of a defect type.The locating and outlining of the TC method show good results for these three fabrics. The TC locating shows good TPR distributions. The TC outlining maintains the TPR and PPV, which makes thef values higher than the TC locating. For the box-patterned fabric, the blue crosses in Figure 10(a) clearly show the TPR-PPV points of the TC outlining are close to the top right corner of the graph, which means the TC outlining performs better than the other methods. Besides, magenta stars (the TC locating) are close to the right bottom corner of the graph with higher TPR values and lower PPV values than the TC outlining. For the star-patterned fabric (Figure 10(b)), the TC outlining does not perform as well as that in the box-patterned fabric. Most blue crosses are around (0.45, 0.55), which means only about a half of defective pixels are detected and only about a half of detected pixels are real defective ones. For the dot-patterned fabric (Figure 10(c)), the TPR-PPV points of the TC outlining are dispersed. Four blue crosses are around (0.45, 0.6) and two blue crosses are around (0.9, 0.8).


## 4.1. Description of Evaluation Metrics

A number of metrics are obtained for evaluation, true positive (TP), false positive (FP), true negative (TN), false negative (FN), accuracy (ACC), true positive rate (TPR), false positive rate (FPR), positive predictive value (PPV), and negative predictive value (NPV). Related definitions of these metrics can be found in [23], where ACC = (TP + TN)/(TP + FP + TN + FN), and usually the value of TN is larger than TP by more than one order of magnitude. Compared with TN, the value of TP is negligible. Thus, ACC is not a good evaluation metric if defective region is small. To evaluate the detection more correctly, we use the f value (f measure) in this paper. (23)f=α2+1×TPR×PPVTPR+α2×PPV,where α is the weight and α is set to 1 in [31, 32]. Thus (23) can be modified as (24)f=2×TPR×PPVTPR+PPV=2×11/TPR+1/PPV=2×1TP+FN/TP+TP+FP/TP=2×TP2×TP+FP+FN.The above equation shows that when the FN and FP increase, in other words, the detection results and manual-labeled results are not consistent, thef value decreases. Smaller values of FN and FP indicate better detection results and the f value is closer to 1. This evaluation index only considers TPR and PPV, which avoids the detection problem of the small defective regions mentioned above. Thus, ACC is replaced by f value in this paper.


## 4.2. Tuning the Parameters of the TC Method

The TC method involves 2 parameters to be predefined, the number of images for establishing the templatek (mentioned in Section 3.2), and the number for threshold segmentations λ (mentioned in Section 3.4).Experiments on the star-, box-, and dot-patterned fabrics are performed withk of 4, 6, 8, 10, and 15 and λ of 2 and 3. Figure 3 illustrates the average f values plots of box-patterned (Figure 3(a)), star-patterned (Figure 3(b)), dot-patterned fabrics (Figure 3(c)) with different parameters k and λ.Figure 3
f value versus constant k and λ for (a) box-patterned, (b) star-patterned, and (c) dot-patterned fabrics.
(a) (b) (c)From Figure3(a) for box-patterned fabrics and Figure 3(b) for star-patterned fabrics, the f value plots are in a rising tendency when the parameter k increases. As is mentioned previously, if the number of defect-free patterns for template establishing increases, the effect of random errors among defect-free patterns can be reduced, which makes the method more accurate. For star- and box-patterned fabrics, although f value increases when parameter k increases, the change rate of plots decreases.Figure3(a) shows that, for box-patterned fabrics, k=15 and λ=3 provide the highest f value. The maximal deviation is about 0.04 with different λ. For the box-patterned fabrics, except for Thin Bar and Thick Bar, pixel values of other defects are close to backgrounds, which makes it hard for a smaller λ to distinguish defect-free and defective pixels. That is why a larger λ provides higher f values. Figure 3(b) shows that, for star-patterned fabrics, f values of λ=2 and λ=3 are close, which means λ=2 and λ=3 provide similar detection results. When k changes from 4 to 6, f value decreases by 0.01, which is due to the slight differences among the patterns used for template establishing.The regularity in Figure3(c) is poor for dot-patterned fabrics because the dot-patterned defective images are mostly man-made. The maximal deviation in Figure 3(c) is about 0.01. The TC method achieves similar results with different parameters k and λ.Thus, in our experiments,k is equal to 15 and λ is equal to 3.Figure4 shows detection results of several images when parameterk changes between 4, 6, 8, and 15 with λ=3. It is clear that when k increases, some small white dots are removed. The detection results are more accurate as analyzed above.Figure 4
Differences of several images when parameterk changes.


## 4.3. Results of the Original and the ImprovedE-V Method

Detection success rate (DSR) is defined as the percentage of fraction of the amount of correct detection of lattices over the total number of lattices [28], and the numerical results are presented in Table 1. The parameter k is equal to 15 and λ is equal to 3. From Table 1, the improvedE-V method (mentioned in training phrase) shows higher DSR than the original one in the overall results (0.9540 versus 0.8883 for box-patterned fabric, 0.9573 versus 0.8559 for star-patterned fabric, and 0.9251 versus 0.9153 for dot-patterned fabric).Table 1
DSR of the original and improvedE-V methods.
Box-patterned Star-patterned Dot-patterned Method Broken End 0.8333 0.9456 0.8921 Original 0.9356 0.9811 0.9492 Improved Hole 0.8911 0.7782 0.9238 Original 0.9578 0.9578 0.9524 Improved Netting Multiple 0.86 0.9589 0.8825 Original 0.9178 0.9811 0.9048 Improved Thin Bar 0.92 0.8367 0.9175 Original 0.96 0.9511 0.9778 Improved Thick Bar 0.937 0.7604 0.9714 Original 0.9537 0.9152 0.9873 Improved Knots Not this type Not this type 0.9048 Original 0.9429 Improved Overall 0.8883 0.8559 0.9153 Original 0.945 0.9573 0.9254 ImprovedFor originalE-V method on box-patterned fabrics, DSR values achieve about 0.85 in Broken End, Hole, and Netting Multiple while DSR values achieve about 0.92 in Thin Bar and Thick Bar. Pixel values of Broken End, Hole, and Netting Multiple are close to backgrounds. However, defects of Thin Bar and Thick Bar are dark-colored, which are easy to be detected. The average DSR of the improvedE-V method for box-patterned fabrics is about 0.94, which means this method can not only detect the obvious defects like Thin Bar and Thick Bar but also detect the defects similar to the backgrounds.For star-patterned fabrics, this fabric is composed of white and black stars with simple structures. The originalE-V method only achieves about 0.8 DSR in Hole, Thin Bar, and Thick Bar. The reason for this phenomenon is similar to the detection on box-patterned fabrics. It is hard for the originalE-V method to detect defects which are similar to backgrounds.For dot-patterned fabrics, defects are man-made with large areas. The original and the improvedE-V methods achieve similar results. These two methods can detect large defects.Figure5 shows some results detected by the originalE-V method and the improvedE-V method. The 1st row displays the defective images. The 2nd row displays the corresponding ground-truth images. The 3rd row displays the defective lattices locating of the originalE-V method. The 4th row displays the defective lattices locating of the improvedE-V method. The 1st and 2nd columns are box-patterned fabrics. The 3rd and 4th columns are star-patterned fabrics. The 5th and 6th columns are dot-patterned fabrics.Figure 5
Comparison of the original and the improvedE-V method.For box- and star-patterned fabrics, although some defective lattices can be located in the image, there are some missing and false cases for the originalE-V method (3rd column). The main reason for missing detection is that defects are similar to the backgrounds. Moving subtraction will lead to insufficient sensitivity in detection. The reason for false detection lies in the misalignment and grayness differences. The improvedE-V method can effectively improve the sensitivity of detection and ensure the DSR of defect detection (4th column).For 5th and 6th rows of dot-patterned fabrics, the two methods can be correctly locating the defective lattices. However, there are false detection situations in 5th row. The proposed TC method contains a subsequent step of pixel-level detection, which can also improve the detection accuracy.In summary, the improvedE-V method proposed in this paper can not only detect large defects but also detect small defects.


## 4.4. Overall Results of the TC Method

In this section, results of the TC and other methods (WGIS, BB, RB, and ER) are presented in two ways,(1) numerical and graphical results and (2) TPR-PPV graphs. The former part shows numerical results of TPR, PPV, FPR, NPV, and f value with some graphical detection results. The latter part shows TPR and PPV in the form of scatter plots. Besides, each scatter also can represent the f value. In this way, the results are presented more intuitively.(  1) Numerical and Graphical Results. Detection of the TC method is divided into two parts: the defective lattices locating and defect shape outlining, short for TC locating and TC outlining, respectively. It must be noted that, because of the preprocessing phrase, the resultant images are smaller than the original images and the resultant images need to be zero padded into size of 256×256.Figure6 depicts the detection results (without zero padding) of TC locating (3rd row) and TC outlining (4th row) with randomly chosen defective images (1st row) and corresponding ground-truth images (2nd row), where the 1st and 2nd columns are the box-patterned defective fabric images; the 3rd and the 4th columns are the star-patterned defective fabric images; the 5th and 6th columns are the dot-patterned defective fabric images. For the star- and box-patterned fabric, the results obtained from TC outlining are close to the manual-labeled results. However, TC outlining on dot-patterned fabric is worse because some small white dots are false detected. Above all, TC outlining performs better than TC locating with more finely defected defect shapes.Figure 6
Several detection results of TC locating and TC outlining.Tables2, 3, and 4, respectively, tabulate the numerical results of each defect type in box-, star-, and dot-patterned fabric images. The results of BB, RB, WGIS, and ER are presented as comparison with results of each part in TC method. For each table, each row represents the average result for a specific method and all rows are categorized based on the defective types.Table 2
Numerical results of different methods on box-patterned fabric.
Box pattern TPR PPV FPR NPV f value Method Broken End 0.9024 0.2883 0.0487 0.9977 0.437 TC locating 0.6671 0.6188 0.0082 0.993 0.642 TC outlining 0.0356 0.0652 0.0098 0.995 0.0461 BB 0.0429 0.0911 0.0084 0.9982 0.0583 RB 0.3639 0.0294 0.2443 0.984 0.0544 WGIS 0.1026 0.3043 0.0069 0.9588 0.1535 ER  Hole 0.695 0.2167 0.0198 0.9977 0.3303 TC locating 0.3856 0.5215 0.0026 0.9953 0.4434 TC outlining 0.0404 0.0342 0.0086 0.9963 0.037 BB 0.0566 0.0529 0.0075 0.9956 0.0547 RB 0.3117 0.0092 0.2553 0.9931 0.0179 WGIS 0 0 0.0003 0.9769 0 ER  Netting Multiple 0.6826 0.1508 0.0607 0.9968 0.2471 TC locating 0.4495 0.3911 0.0112 0.994 0.4183 TC outlining 0.0422 0.0467 0.0099 0.9913 0.0443 BB 0.1983 0.1051 0.0195 0.9966 0.1374 RB 0.33 0.0128 0.2568 0.9887 0.0246 WGIS 0.0015 0.04 0.0004 0.9581 0.0029 ER  Thin Bar 0.8378 0.1177 0.0706 0.9985 0.2064 TC locating 0.7083 0.4759 0.0095 0.9974 0.5693 TC outlining 0.3154 0.2983 0.0078 0.9935 0.3066 BB 0.3221 0.3079 0.0066 0.9958 0.3148 RB 0.269 0.0102 0.242 0.9907 0.0197 WGIS 0.0584 0.0236 0.0451 0.9768 0.0336 ER  Thick Bar 0.8161 0.3189 0.0429 0.9976 0.4586 TC locating 0.7211 0.6114 0.0097 0.9952 0.6618 TC outlining 0.6012 0.5304 0.0105 0.9856 0.5636 BB 0.7975 0.4091 0.0225 0.9847 0.5408 RB 0.4908 0.043 0.2424 0.9877 0.0791 WGIS 0.2276 0.424 0.0168 0.9693 0.2962 ER  Overall 0.7868 0.2185 0.0485 0.9977 0.3359 TC locating 0.5863 0.5237 0.0083 0.995 0.5469 TC outlining 0.207 0.195 0.0093 0.9923 0.1995 BB 0.2835 0.1932 0.0129 0.9942 0.2212 RB 0.3531 0.0209 0.2482 0.9888 0.0391 WGIS 0.078 0.1584 0.0139 0.968 0.0972 ERTable 3
Numerical results of different methods on star-patterned fabric.
Star pattern TPR PPV FPR NPV f value Method Broken End 0.9249 0.1703 0.0294 0.9994 0.2876 TC locating 0.5142 0.4337 0.0042 0.9962 0.4705 TC outlining 0.0283 0.0333 0.0078 0.9899 0.0306 BB 0.0454 0.0752 0.0045 0.9919 0.0566 RB 0.0026 0.0009 0.0356 0.9924 0.0013 WGIS 0.0879 0.0717 0.0116 0.9927 0.079 ER  Hole 0.8970 0.1273 0.0434 0.9995 0.223 TC locating 0.474 0.3932 0.0049 0.9972 0.4298 TC outlining 0.0269 0.0816 0.0016 0.9931 0.0405 BB 0.069 0.2599 0.0012 0.9939 0.109 RB 0.0034 0.0005 0.0366 0.9945 0.0009 WGIS 0.2447 0.1168 0.0123 0.9954 0.1581 ER  Netting Multiple 0.9270 0.3702 0.027 0.9990 0.5291 TC locating 0.4167 0.6683 0.0031 0.9899 0.5133 TC outlining 0.1158 0.3711 0.0042 0.9799 0.1765 BB 0.1523 0.4799 0.0025 0.9834 0.2312 RB 0.0103 0.0088 0.0361 0.9825 0.0095 WGIS 0.1642 0.1261 0.0082 0.9854 0.1426 ER  Thin Bar 0.8277 0.117 0.0738 0.9994 0.2051 TC locating 0.5269 0.4909 0.0063 0.9961 0.5082 TC outlining 0.0676 0.2216 0.0023 0.9882 0.1036 BB 0.0314 0.2769 0.0008 0.9889 0.0564 RB 0 0 0.0365 0.99 0 WGIS 0.4547 0.125 0.0283 0.9945 0.1961 ER  Thick Bar 0.8802 0.2595 0.0813 0.9967 0.4008 TC locating 0.3614 0.6146 0.0071 0.9777 0.4552 TC outlining 0.3067 0.6318 0.0049 0.9688 0.4129 BB 0.1961 0.7711 0.0032 0.9686 0.3127 RB 0.0437 0.0509 0.0344 0.9663 0.047 WGIS 0.6952 0.5452 0.0167 0.9881 0.6111 ER  Overall 0.8914 0.2089 0.051 0.9988 0.3291 TC locating 0.4587 0.5201 0.0051 0.9914 0.4754 TC outlining 0.1091 0.2679 0.0042 0.984 0.1528 BB 0.0988 0.3726 0.0024 0.9853 0.1532 RB 0.012 0.0122 0.0358 0.9851 0.0117 WGIS 0.3293 0.197 0.0154 0.9912 0.2374 ERTable 4
Numerical results of different methods on dot-patterned fabric.
Dot pattern TPR PPV FPR NPV f value Method Broken End 0.9737 0.3031 0.1779 0.9994 0.4623 TC locating 0.3611 0.5679 0.0115 0.9081 0.4415 TC outlining 0.0546 0.7424 0.0009 0.8857 0.1017 BB 0.1423 0.6028 0.0041 0.8884 0.2302 RB 0.5463 0.2559 0.1171 0.9166 0.3485 WGIS 0.3232 0.562 0.0344 0.9226 0.4104 ER  Hole 0.9792 0.1563 0.1521 0.9993 0.2696 TC locating 0.5288 0.4056 0.022 0.9861 0.4591 TC outlining 0.2619 0.5528 0.0065 0.9779 0.3554 BB 0.1509 0.4126 0.0069 0.97 0.221 RB 0.7633 0.1056 0.189 0.9915 0.1855 WGIS 0.6921 0.3063 0.0458 0.9907 0.4247 ER  Netting Multiple 0.939 0.2679 0.1037 0.9972 0.4169 TC locating 0.2967 0.7054 0.0046 0.9718 0.4177 TC outlining 0.2943 0.9081 0.0015 0.9081 0.4445 BB 0.2115 0.9639 0.0005 0.9562 0.3469 RB 0.6391 0.1415 0.1458 0.9828 0.2317 WGIS 0.4561 0.8133 0.0056 0.9782 0.5844 ER  Thin Bar 0.9974 0.1054 0.2182 0.9999 0.1906 TC locating 0.9308 0.6839 0.0118 0.9981 0.7885 TC outlining 0.5371 0.5867 0.0126 0.9839 0.5608 BB 0.5393 0.7517 0.0063 0.9854 0.628 RB 0.6678 0.1123 0.1449 0.991 0.1923 WGIS 0.8056 0.2701 0.058 0.9946 0.4046 ER  Thick Bar 0.9973 0.337 0.3046 0.9992 0.5037 TC locating 0.9354 0.9347 0.0102 0.9899 0.9351 TC outlining 0.6449 0.7574 0.0352 0.9456 0.6966 BB 0.6646 0.8254 0.0231 0.9497 0.7363 RB 0.7324 0.3323 0.1923 0.9614 0.4572 WGIS 0.8596 0.5011 0.1175 0.9766 0.6331 ER  Knots 1 0.1559 0.221 1 0.2697 TC locating 0.4879 0.578 0.0152 0.9795 0.5291 TC outlining 0.3122 0.6685 0.0055 0.9785 0.4256 BB 0.2256 0.6652 0.0044 0.9675 0.3369 RB 0.3934 0.0574 0.1958 0.9781 0.1002 WGIS 0.5346 0.6853 0.0109 0.9814 0.6006 ER  Overall 0.9811 0.2209 0.1963 0.9992 0.3521 TC locating 0.5901 0.6459 0.0126 0.9723 0.5952 TC outlining 0.3508 0.7027 0.0104 0.9466 0.4308 BB 0.3224 0.7036 0.0076 0.9529 0.4166 RB 0.6237 0.1675 0.1642 0.9702 0.2526 WGIS 0.6119 0.523 0.0454 0.974 0.5096 ERFrom Table2 of the box-patterned fabric, overall results of the TC method reach 0.7868 TPR, 0.2185 PPV, 0.0485 FPR, 0.9977 NPV, and 0.3359 f value for TC locating and 0.5863 TPR, 0.5237 PPV, 0.0083 FPR, 0.9950 NPV, and 0.5469 f value for TC outlining. According to the TPR of TC locating, most defective lattices are detected. However, about 0.2 PPV means only about one-fifth of detected pixels are real defective ones. For the results of TC outlining, TPR drops to 0.5863 (25 percent of decrease) but PPV rises to 0.5273 (141 percent of increase). That is the reason that f value of TC outlining is higher than TC locating. The BB and RB provide about 0.05 TPR and PPV values in Broken End and Hole defect detection while these two methods are good competitive rivals for the proposed TC method in Thick Bar defect detection. Also, the BB and RB methods outperform the WGIS and ER methods in Thick Bar and Thin Bar defect detection. The BB and RB methods seem unable to detect small defects like Broken End and Hole but are good at detecting obvious defects like Thin Bar and Thick Bar. The TPR and PPV values of the WGIS method are around 0.35 and 0.02, which means although the WGIS method provides stable results on these five kinds of defects, it is still not practical because of much false detection. According to the results, it is difficult for the ER method to detect fabrics defects with complex structures. Figure 7 depicts the detection results (without zero padding) of the WGIS, RB, and TC outlining; TC outlining performs better than the WGIS and RB in defect types of Broken End, Thin Bar, and Thick Bar. However, TC outlining is not good at detecting defect types of Hole and Netting Multiple. Especially for Hole, only a few defective pixels are detected (2nd row in Figure 7).Figure 7
Box-patterned fabric: (1st column) defective sample names; (2nd column) defective images; (3rd column) ground-truth image; (4th column) detection results of WGIS; (5th column) detection results of RB; (6th column) detection results of TC.From Table3 of the star-patterned fabric, overall results of the TC method reach 0.8914 TPR, 0.2089 PPV, 0.051 FPR, 0.9988 NPV, and 0.3291 f value for TC locating and 0.4587 TPR, 0.5201 PPV, 0.0051 FPR, 0.9914 NPV, and 0.4754 f value for TC outlining. TPR value of TC outlining drops sharply (48 percent of decrease), especially for defect types of Broken End (0.9249 versus 0.5142), Netting Multiple (0.9270 versus 0.4167), and Thick Bar (0.8802 versus 0.3614). This means although the TC method on star-patterned fabric can locate defective lattices correctly, it is difficult to outline the defect shapes. According to the numerical results of other methods, the BB, RB, WGIS, and ER methods provide lower TPR and FPR values than the TC method in Broken End, Hole, Netting Multiple, and Thin Bar defect detection. The ER method shows higher TPR and f value than TC outlining in Thick Bar defect detection. The average TPR values of BB and RB methods are less than 0.2. The BB and RB method detect defects by different combinations of moving average and standard deviation and the star-patterned fabrics consist of black and white stars. It is hard for these statistical approaches to detect dark-colored defects. The ER method has good performances except for Broken End because this kind of defect is small. In Figure 8, TC outlining provides good results of Hole and Thin Bar. However, it is hard to detect dark defects in black backgrounds, such as Netting Multiple (3rd row). Besides, TC outlining provides many false detected white dots, such as Thick Bar (5th row).Figure 8
Star-patterned fabric: (1st column) defective sample names; (2nd column) defective images; (3rd column) ground-truth image; (4th column) detection results of WGIS; (5th column) detection results of RB; (6th column) detection results of TC.From Table4 of the dot-patterned fabric, overall results of the TC method reach 0.9811 TPR, 0.2209 PPV, 0.1963 FPR, 0.9992 NPV, and 0.3521 f value for TC locating and 0.5901 TPR, 0.6459 PPV, 0.0126 FPR, 0.9723 NPV, and 0.5952 f value for TC outlining. TPR values of TC outlining drop sharply on Broken End (0.9737 versus 0.3611) and Netting Multiple (0.9390 versus 0.2967) but it provides highest PPV values on Thick Bar (0.9347). Defects of dot-patterned fabrics are usually large, such as Thick Bar and Knots. However, with obvious texture features, it is hard for these methods to maintain TPR and PPV values. The BB and RB methods provide higher PPV values than the TC, WGIS, and ER methods while the TC, WGIS, and ER methods provide higher TPR values than the BB and RB methods. According to f values, the TC and ER outperform other methods. In Figure 9, the WGIS method provides a better result than RB and TC outlining on Netting Multiple (3rd row) and Knots (6th row). The WGIS and TC outlining perform better than RB on Broken (1st row) and Hole (2nd row) end. These three methods are all good at detection on Thin Bar (4th row) and Thick Bar (5th row) while the WGIS method provides many false detected pixels.Figure 9
Dot-patterned fabric: (1st column) defective sample names; (2nd column) defective images; (3rd column) ground-truth image; (4th column) detection results of WGIS; (5th column) detection results of RB; (6th column) detection results of TC.(  2) TPR-PPV Graphs with Optimized Parameters. Figure 10 shows TPR-PPV graphs between the WGIS, BB, RB, ER, and TC (including TC locating and TC outlining). The TPR-PPV graphs are formulated by the average TPR and PPV values of each defective sample of the dot-, star-, and box-patterned fabrics. TPR estimates how many true defective pixels are detected among the manually labeled defective pixels while PPV estimates how many true defective pixels are among the detected pixels. For performance evaluation, PPV values are much better than FPR. Furthermore, TPR and PPV are usually called recall and precision in information retrieval and natural language processing. In TPR-PPV graphs, a point located closer to the top right corner is regarded as an optimized result.Figure 10
TPR-PPV graphs of detection results on different kinds of fabric. (a) Box-patterned fabric, (b) star-patterned fabric, and (c) dot-patterned fabric.
(a) (b) (c)The magenta stars represent TC locating and the blue crosses represent TC outlining. The red squares, green pentagrams, cyan diamonds, and black hexagrams represent the BB, RB, WGIS, and ER method, respectively. Each mark represents TPR-PPV value of a defect type.The locating and outlining of the TC method show good results for these three fabrics. The TC locating shows good TPR distributions. The TC outlining maintains the TPR and PPV, which makes thef values higher than the TC locating. For the box-patterned fabric, the blue crosses in Figure 10(a) clearly show the TPR-PPV points of the TC outlining are close to the top right corner of the graph, which means the TC outlining performs better than the other methods. Besides, magenta stars (the TC locating) are close to the right bottom corner of the graph with higher TPR values and lower PPV values than the TC outlining. For the star-patterned fabric (Figure 10(b)), the TC outlining does not perform as well as that in the box-patterned fabric. Most blue crosses are around (0.45, 0.55), which means only about a half of defective pixels are detected and only about a half of detected pixels are real defective ones. For the dot-patterned fabric (Figure 10(c)), the TPR-PPV points of the TC outlining are dispersed. Four blue crosses are around (0.45, 0.6) and two blue crosses are around (0.9, 0.8).


## 5. Conclusion

This paper presents a new method of patterned fabric inspection called the TC method. With an adaptive method of lattice segmentation, fabric images are segmented into lattices automatically. A method of correction is used to reduce the effect of misalignment among lattices. Detection is then carried out in two steps: defective lattices locating and defects shape outlining. The former step is good at locating the defective lattices in the images (over 0.92 DSR and over 0.78 TPR) and the latter step provides finely defected defect shapes. When it comes to unpatterned fabric defect detection, the proposed TC method is not suitable because most unpatterned fabrics do not contain periodic variations. Thus, lattice segmentation and template-based correction are not necessary. The TC outlining achieves the highestf values and the TPR and PPV values are over 0.45 and 0.52. For the definition of f value, it can be regarded as the weighted harmonic average of TPR and PPV. The TC method performs worse in shape outlining for dot-patterned fabrics than in star- and box-patterned fabrics, which results in the fact that some defect-free pixels are false detected. The reason is that most of the dot-patterned fabric defective images are synthetic with large defects which are similar to backgrounds such as Knots, Netting Multiple, and Broken End. The TC method is too sensitive to deal with these defects. The TC method still has room for improvement in feature extraction such as LBP or Gabor. In the future, additional theoretical development involving feature extraction should be carried out. Such research will be beneficial for defect detection in the textile, tile, ceramics, and wallpaper.



---

*Source: 3709821-2018-03-22.xml*