Abstract
Defect detection has been a focal point in fabric inspection research and remains challenging. In this paper, a novel method for fabric defect detection is presented. In the proposed algorithm, only defect-free fabric images are used to build the over-complete basis set via sparse coding. Compared to traditional defect detection methods via sparse coding, our method uses a Gabor filter to reduce the complexity of the fabric signal, and takes the fabric patch’s projections in the small scale over-complete basis set as the original features, not the sparse representation. We compare the averages of the patch and its neighborhoods’ features with the standard features, which are the averages of all defect-free fabric images’ features. At last, according to this compared distance, the patch is classified as defective or non-defective. The experimental results on our own database and the TILDA database reveal that our features are more robust and the proposed algorithm can detect defects on twill, plain, gingham and striped fabric effectively.
As fabric production speed becomes faster, quick defect detection becomes an important step in the process of the fabric quality control system. Traditionally, fabric defects are detected by human inspectors, which limits the speed of high quality fabric production. And the existence of defects reduces the price of fabric by 45–65%. 1 To increase the efficiency of fabric defect detection, it is necessary to replace human inspectors with an intelligent detection system using computer vision.
In past decades, research has been carried out by many researchers. The traditional methods, including auto-correlation, 2 co-occurrence, 3 mathematical morphology, 4 fractal feature detection, 5 Fourier transformation analysis,6–9 Gabor filters10–12 and wavelet analysis13–16 have been used in fabric defect detection. These algorithms study defect-free fabric and defect fabric in different transform spaces, like the frequency and wavelet domains, and try to find their and enhance the differences. Some papers extract different features and use neural networks to train the classifiers for detection and defect classification.17–18 However, it is hard to get adequate defect fabric samples for analysis and training because of the advanced textile machines. These algorithms’ features are chosen based on complex statistical or frequency analysis. If a new kind fabric occurs, they need new analysis and features, which prevents their algorithms from being generally applicable. The fabric image is a repeating texture image, and we can find defects when we know the defect-free fabric texture as well. More attention should be paid to analyzing the defect-free fabric image’s texture. Inspired by this idea, recently ICA (Independent Component Analysis) and sparse coding were used to analyze the normal fabric image.19–22 Compared to the algorithms based on statistics,2–3 frequency domain,6–16 and so on, the algorithms using ICA or sparse coding are more flexible. Because their features are trained and not a fixed mode, these models can adapt to new fabric more easily. Sezer and Eertuzun presented defect detection via ICA. 20 The defect-free and defect fabric were distinguished based upon the difference of their independent components. Zhou used sparse coding to find the over-complete basis set of defect-free fabric images.21,22 Based on the over-complete basis set, defect-free fabric images can be reconstructed with little error via sparse representation. So when the reconstructed error is large, this indicates that the fabric image contains defects. Their advantage is that only defect-free fabric images are needed for training, and features are flexible, but the computation is large when producing the sparse representation and the detection result is not very robust.
To solve this problem, we improve previous methods and propose to detect fabric defects via the small scale over-complete basis set. Like the above algorithms,21,22 the training process only needs defect-free fabric images and the over-complete basis set is trained via sparse coding. To overcome the computation problem posed by Zhou,21,22 the fabric patch’s projections in all vectors of the over-complete basis set are taken as the features. The scale of the basis set is proportional with computation cost. In order to reduce the scale of the basis set and decrease more computation, we use Gabor filter to preprocess the fabric image to reduce the complexity of the fabric image signal, which also can reduce the influence of noise. With the smaller scale over-complete basis set, the computation of our method becomes quicker. The proposed algorithm has two main parts: training and detection, as shown in Figure 1. In the training part, the Gabor filter’s parameters, small scale over-complete basis set, and detector’s parameters (standard features and threshold) are trained. In the detection part, firstly the fabric image is preprocessed by the Gabor filter, and then features are extracted. At last features are filtered by mean-filters, and our result is decided by the filtered features’ distance to standard features and threshold. Our experiments show that the presented algorithm is more robust and can detect defects on twill, plain, gingham, and striped fabric effectively. The rest of the paper is organized as follows: We first introduce the role of the Gabor filter in our algorithm and the set of its parameters in Section 2.1. Sections 2.2 and 2.3 detail the training of the small scale over-complete basis set and the feature extraction. Following this, the detector’s standard features and threshold are presented in Section 3. Sections 4 and 5 show the experiments and discussion. Finally, the paper is concluded in Section 6.
The flowchart of our algorithm.
Feature extraction via small scale over-complete basis set
Preprocessing via a Gabor filter
In the K-means clustering algorithm, if the distribution of signals is concentrated in fewer locations, a smaller clustering center number can be set. This situation is similar to sparse coding according to Yang and Yu’s analysis on K-means clustering algorithm and sparse coding. 23 In order to get a small scale over-complete basis set via sparse coding, we must reduce the complexity of the normal fabric image signal to concentrate the normal fabric patches.
For twill fabric images, the frequency distribution is concentrated in few points.6–9 These points contain the main information. For other more complex fabric images, the main signal of one type fabric image is in one period. As a band-pass filter, a Gabor filter’s frequency and orientation representations are similar to the human visual system. It can understand the balance between the resolutions of the time and frequency domains. So we chose the Gabor filter to extract information about the fabric image in a special frequency which corresponds with the period of fabric image. After the preprocessing, the fabric image signal’s complexity is reduced and the fabric patches’ distribution is more concentrated. As shown in Figure 2, the twill fabric image in Figure 2(a) is very like the ideal 2-D sine image in Figure 2(c), which means that we can take one frequency as the twill fabric image’s main frequency. As shown in Figure 2(b), the defect is retained after the preprocessing.
Image preprocessing. (a) Original twill fabric image. (b) The image preprocessed via the Gabor filter. (c) A 2-D sine image, which is very similar to the twill fabric image.
The Gabor filter G is defined as:
We also can count the fabric image’s pixels to find whether the period if the fabric’s texture is too complex. After the preprocessing via Gabor, we can use the preprocessed defect-free fabric images to train the small scale over-complete basis set via sparse coding, which is introduced in the following section.
Small over-complete basis set training via sparse coding
Let
Assume the periods of fabric image are Tr pixels in the row and Tc pixels in the column, there are Tr × Tc kinds of fabric image patches in ideal conditions. Assume the Gabor filter is an ideal band-pass filter, the preprocessed defect-free fabric image can be seen as a 2-D sine image. The distribution of the ideal digital 2-D sine image’s patches is focused on T locations (assume the sine image’s period is T pixels). So under ideal conditions, there are T kinds, which is much smaller than Tr × Tc according to (2). Because a sine image displays origin symmetry, the number can be reduced by half if we ignore whole signal’s positive and negative scope. In order to satisfy the condition that the basis set is over complete, the scale K should be more than T/2. Although this is an ideal condition, our experiments show that it can yield satisfactory results. The process of training the small scale over-complete basis set is shown in Figure 3.
The process of over-complete basis set C production and some C’s show.
Based on the small scale over-complete basis set, the features of fabric image are extracted, which is described as follows.
Feature extraction
A fabric image patch Xd’s projections in the over-complete basis set are taken as original features The process of feature extraction.
Because the basis set C is trained from the defect-free fabric patches, one defect-free fabric patch should have large projections, while the defect patch should have small projections. The sum of absolute projections and the max of absolute projections are good features to describe the defect and defect-free fabric patches, which are shown in Figure 5(a), (c), and (d). The two kinds of features are defined as:
(a) Original twill fabric image; (b) Reconstruction errors ErrorF; (c) Sum of absolute projections SumF; (d) Max value of absolute projections MaxF.
In Figure 5(b), we also give the reconstruction errors ErrorF to describe the fabric patch,21–22 which is defined as:
(a) and (e) Original twill fabric images; (b) and (f) Reconstruction errors ErrorF; (c) and (g) Sum of absolute projections SumF; (d) and (h) Max value of absolute projections MaxF. (a) Original twill fabric image; (b) Sum of absolute projections SumF; (c) Max value of absolute projections MaxF; (d) Detection distance D in (9), with a mean filter 40 × 2.

Defect detection
In the proposed algorithm, the detector’s standard features
Just using one small patch’s features to distinguish defect-free fabric and defect fabric patches is not robust. So the fabric image’s original features are filtered by mean-filters, and then compared with the standard features. Figure 7(d) shows the robustness of the detection distance. A larger distance means a larger possibility that the patch contains a defect. The detection distance D and detection result R are defined as:
The detection distances with the mean-filters and the results’ fusion.
Experimental details
In this paper, we use two databases: our own database and the TILDA database.
25
In our own database, 13 types of defects (mispick, coarse pick, broken pick, stretched warp, broken selvedge, rough selvedge, balling up, hole, foreign fiber, double end, evenness, dragged selvedge, and oil warp) are chosen to test the proposed algorithm. Our database contains 284 gray twill fabric images, and the twill fabric images’ period is about 6 pixels in the row and 5 pixels in the column. These images were captured by a Basler line scanner with resolution of 4096 pixels, and the fill light is in front of the fabric, as shown in Figure 9. We also use the fabric images from the C1, C2, and C3 groups of the TILDA database. Each group contains two types of fabric. In groups C1 and C2, there are four types of plain fabric. In the group C3, they are gingham and striped fabric. For each textile type, there are four different defect classes (E1–E4) and one defect-free class (E0). Each class contains 50 images; these 50 images contain both different types of defects and the same defect taken from different rotation angles. MATLAB (R2010a) is used to develop the detection system, which runs on an AMD Athlon X2 270 3.41 GHz CPU with 4 GB RAM. Some detection results are shown in Figures 10–13. In these result images, some detection red rectangles may have some small deviations because of mean-filters and image borders, and some defects are not detected because they are too small. In industrial application, most of these small defects are not defined as defects. And in our database, because they are taken from multi-kind twills with close main frequency, the fabric images appear different.
Framework of image acquisition. Some detection results for twill fabric. Some detection results for plain fabric. Some detection results for gingham fabric. Some detection results for striped fabric.




In this paper, detection rate and false alarm rate are utilized to judge the performance of the detection algorithm, which are defined as
Results and discussion
In this section, firstly we discuss the detection rate, false alarm rate and their relationship with parameters using our own database. Then we give some comparison with other algorithms using the TILDA database. These algorithms used the TILDA database and gave the detection data in their papers. Finally, the computation cost is discussed.
Our own database (twill fabric)
The detection rate
If patch size is too large, it is hard to detect small defects and a large amount of computation is needed. Otherwise, detection results are influenced by noise easily. So patch size is an important parameter. As shown in Figure 14, when the size is 4 × 3, the detection rates are lower than 90%, and their false alarm rates are also lower than others. When the patch size and the scale of the basis set are increased, the detection rates increase quickly. As to the larger patch size, it must have a larger scale than the basis set in order to yield an acceptable detection rate. As shown in Figure 14, when the patch size is 12 × 10, the detection rate can reach 90% with the scale of the basis set larger than 24. Because most defects are very small, the influence of defect signal for one patch is decreased when using a larger patch size. When the patch size is 6 × 5, which is the same as the period of the twill fabric image, or the size is 9 × 7, which is a little larger, we can get acceptable detection rates with the scale of the basis set larger than 16.
Detection rate and false alarm rate.
The false alarm rate
As shown in Figure 14, a larger patch size means more false alarms. This is because many kinds of defects are very small, and the defect-free patch’s and defect patch’s features are too close when the patch size is large, which makes it difficult to get an ideal threshold T defined in (9). And the false alarm rate decreases with a larger scale of the basis set. The patch sizes 9 × 7 and 12 × 10 have very small false alarm rates when the scale of the basis set is 4 and 6, because low detection and false alarm rates often happen at the same time.
The set of parameters
As discussed above, the optimal patch size is close to the fabric’s period. In our experiments, we preferred a patch size equal to the fabric’s period. The larger the scale of the basis set, the better the detection result. In our experiments, the scale of the basis set is set to be larger than half of the patch size. The threshold T in (9) is three to five times the variance of the defect-free fabric’s detection distance.
Detection with and without the Gabor filter
The detection rate and false alarm rate are 93.7% and 9.6% with the Gabor filter, and 87.2% and 14.2% without the Gabor filter, as shown in Figure 15. The scale of basis set without the Gabor filter is about five times that with the Gabor filter. Without the Gabor filter, in order to yield an acceptable detection rate, the algorithm needs a larger basis set scale and more computation. The Gabor filter not only helps our algorithm improve the detection rate and reduce the false alarm rate, but also reduce the computation cost. However, some defect characteristics are weakened by the preprocessing via the Gabor filter. So fewer kinds of defect have higher detection rates without the Gabor filter.
Detection rate comparison.
Detection comparison between sparse coding and ICA
ICA and sparse coding have much in common. 26 The over-complete basis set of sparse coding and independent components of ICA look alike. But our experiments show just using independent components instead of an over-complete basis set with the same other parameters cannot produce similar detection results. The ICA’s detection results are poor. As shown in Figure 15, most kinds of defect’s detection rates with ICA are lower than with our method. Our method’s detection rate is 93.7%, and the ICA’s is 76.4%. The main reason is that their features are different. Our features are more robust and have some characteristics of sparse representation. We can simply use a mean-filter to get the information of the neighborhood’s features for detection. However, the ICA’s features need more processing or training for detection.
The TILDA database
Comparison with other algorithms (comparison data is from respective papers). The numbers of the images used for detection are in brackets. If there is no bracket after the detection rate, it means all fabric images with defects were used
The detection of plain fabric in the groups C1 and C2
The plain fabric images in the group C1 are smooth, and their period is very small. The patch size is set to be 6 × 6. The mean filter’s size is 6 × 6. The fabric images in the group C2 are rough, so we set larger patch sizes. For the R2 in the group C2 the patch size is 8 × 8; and for the R3 in the group C2 the patch size is 10 × 10. The detection rates of R1 and R3 in the group C1 are 98.5% and 97.5%, and the detection rates of R2 and R3 in the group C2 are 97% and 86%. The comparison is shown in Table 1. Our algorithm has better detection rates in most cases. Some algorithms’ detection rates, such as for Orientation and NPPCCFs, are about 100%, but in their experiments less than 25 images are used. The algorithm of ICA used all the defect fabric images and had high detection rates in the group C1. However, their detection rates in the group C2 are much lower than our algorithm’s. Our algorithm is more robust. For the fabric in R3 of the group C2, our detection rate is 86%. That’s because the fabric is too rough and contains too much noise for our method. In this non-ideal condition, our detection rate is 86%, which is much higher than the ICA’s 72%. The detection distance images and detection results are shown in Figure 16. More detection results are shown in Figure 11.
Detection for plain fabric. Images in the first line are the gingham fabric images and red rectangles are the detection result; images in the second line are the detection distances between defect-free fabric patch and defect fabric patch. Red means large distance, and blue means small distance.
The detection of gingham fabric in the group C3
As per the discussion of results using our own database, above, the best patch size is near to the fabric’s period. For the gingham fabric detection, the patch size is set to be 16 × 16, because its period is about 16 × 16. The size of mean filter is 16 × 16. The detection distance images and detection results are both shown in Figure 17. Our algorithm also has its shortcomings. As shown in Figure 17, the detection distance is not continuous for one continuous defect, although it can detect defects correctly. More detection results are shown in Figure 12. In the detection of gingham fabric, our algorithm’s detection rate is 94.5%, and the corresponding false alarm rate is 6.5%.
Detection for gingham fabric. (a), (c), (c), and (d) Gingham fabric images and red rectangles are the detection result; (e), (f), (g), and (h) Detection distances between defect-free fabric patch and defect fabric patch. Red means large distance, and blue means small value.
The detection of striped fabric in group C3
For the striped fabric image, we only need to use the information in one direction. In the database, there are 200 striped fabric images. For half of these images, whose period in the horizontal direction is about or less than 15 pixels, the patch size is 5 × 15 and the size of the mean filter is 5 × 15. For the other half, whose period in the vertical direction is about or less than 15 pixels, the patch size is 15 × 5, and the size of mean filter is 15 × 5. The detection distance images and detection results are shown in Figure 18. Our algorithm has its shortcomings, as in the case for gingham fabric detection. As shown in Figure 18, the distance is not continuous for one continuous defect. More detection results are shown in Figure 13. In striped fabric defect detection, our algorithm’s detection rate is 95% and the false alarm rate is 6%. Our patch size is not exactly equal to the period, and we use the same patch size for a different rotation angle. As the results show, we find that our algorithm is very robust and not sensitive to the parameters.
Detection for striped fabric. (a), (b), (c), and (d) Striped fabric images and red rectangles are the detection result; (e), (f), (g), and (h) are the detection distances between defect-free fabric patch and defect one. Red means large distance, and blue means small value.
The estimation of efficiency
When the detected twill image’s size is about 300 × 300 pixels, with different parameters the average time our algorithm needs is shown in Figure 19. When the patch size is 30 (6 × 5) and the scale of basis set is 16, the detection rate is 93%, and the false alarm rate is 5.5%. The average computation speed for these fabric images is 4.6 s when using MATLAB (version 2010a). If the fabric image size is 256 × 256 pixels, we can estimate that our algorithm needs about 32,000,000 multiplications and additions. This amount of calculation is not hard for most DSP embedded systems and PCs. As shown in Figure 1, a larger patch size and larger basis set need more time. Theoretically, the real computation time is proportional with patch size, and the basis set scale. When the scale of the basis set is small, the average times needed by different patch sizes shown in Figure 19 are very near. That is because when the scale of basis set is small, the real computation time is very small and the time needed by MATLAB to read data, save data, and so on accounts for the greater proportion.
Detection time using MATLAB (version 2010a).
Conclusions
This paper proposed an applicable method for defect detection applied to twill, plain, gingham, and striped fabric. The proposed algorithm firstly uses a Gabor filter to reduce the complexity of the fabric image signal and extract the main texture signal; then, a sparse coding training algorithm is used to find the small scale over-complete basis set of defect-free fabric patches. The fabric patch’s projections in the basis set are taken as the features. The proposed algorithm is characterized as follows: (1) it has an acceptable detection rate, false alarm rate, and computation cost, and can be applied to different type fabric easily; (2) the imprecise parameters do not influence the detection result a lot, which means it is easy to adjust the parameters for different types of fabric; (3) the training process only needs the defect-free fabric images, which is convenient for application. There are some shortcomings. Our algorithm is sensitive to the changes of fabric structure. Some fabric which is little irregular, which is not a defect, is detected. After the preprocessing via one Gabor filter, some defect information is lost. Therefore, using a set of Gabor filters to preprocess the fabric image with acceptable computation cost is the subject of our further research.
