Abstract
In most fabric industries fabric quality is assessed through manual inspection, which depends on an individual judgment. It is necessary to design an automatic fabric defect performance inspection system for the industry. This study aimed to develop a real-time, low-cost, and high-performance home textile fabric defect inspection machine system. The proposed system uses the Haar wavelet transform to reduce the information content of the fabric image. The brightness of the fabric image is compensated and the camera luminance is corrected in order to filter the image texture for fabric images with the Gaussian filter after correction. After that, the fabric defect classification was performed by using the random forest classifier. The designed system capability can detect and verify 10 kinds of fabrics with different colors. Moreover, the hardware cost of the machine is low and the average true defect recognition detection rate is more than 98.70%, with good adaptability. Meanwhile, the average processing detection time for a single image is 70 ms with a fabric defect inspection speed of 30 m/min. The efficiency of the machine is increased by five times compared with the traditional inspection. The designed inspection machine can also replace manual grading, cutting, and finishing in the processes of labeling defects. Eventually, it can reduced man power and overall mass production cost, so even small-scale home textile industries can afford a machine with high-precision defect detection.
Currently, fabric quality detection has become more important with the increased application and function of fabric products, because the defects on the surface of fabrics will have a great effect on the grading and cost of the product. At present, there are three main problems in the textile industry: firstly, it is difficult to find good cloth. The complicated selling channels and information asymmetry has led to numerous brokers, resulting in high transaction costs. Secondly, cloth inspection is difficult. Not only are manual cloth inspection costs and false detection (FD) rates high, but it also suffers from low efficiency and is facing an increasing shortage of labor. Thirdly, it is difficult to buy cloth, and vicious competition among middlemen and manufacturers often brings industry ills, such as short codes and shoddy products. Providing quality inspection services and fabric trading platforms can solve such problems through automatic fabric inspection machines. 1 The difficulty of fabric defect detection is mainly due to the variety of textures and morphological structures of the fabric; in particular, the types of defects are very different.
The textile industry inspects the quality of its products through manual inspection, which cannot meet actual production quality. The subjective judgment and fatigue of the inspector may affect the results of the fabric detection and the inspector cannot reach the detection rate of more than 60% under the operation of the loom. A skilled inspector can find up to 200 defects in an hour, but the inspector can only maintain a state of high concentration for 30 minutes at most. 1 After this time, the inspector is prone to fatigue and the missed inspection rate is greatly increased. The biggest difficulty lies in how to make the machine accurate and correct in identification and inspection. A skilled inspector can inspect 5–6 meters of cloth per minute.
In recent studies, computer vision technology has been used for the fabric defect inspection system and recognition. Jeong 2 adopted the Hough transform to find the warp and weft directions of the adorned fabric. This method could recognize the warp and weft features for the weaves and various patterns. Pan et al. 3 applied the Hough transform to rectify the image skew of fabric during the image capture process. The warp and weft could be segmented by locating the minimum values. The density of solid color fabric could be inspected by counting the yarns in a unit length in the fabric image. Kuo et al. 4 developed the RGB (red, green, blue) accumulative average method to recognize and locate flawed zones. Fuzzy logic is employed to discern the flaw types. It was an efficient algorithm for pattern recognition. Malek et al. 5 presented the fast Fourier transform and cross-correlation to examine the structure regularity features of the fabric image. This technique was able to detect only the actual or real defects and highlight their exact dimensions. Kuo et al. 6 used wavelet packets and a neural network to distinguish the defects of fabrics. This algorithm selected the lowest two entropies of a sub-image and the standard deviation as the input of the neural network classifier. Three features are presented to achieve high performance in defect inspection of knitted fabrics. Cao et al. 7 proposed prior-knowledge guided least-squares regression (PG-LSR) to inspect various detects in fabric images with diverse textures. This method used PG-LSR to combine the texture features and local similarity seamlessly. This combination helps to generate a clearer irregularity map and improve the robustness. Lizarraga-Morales et al. 8 used texture periodicity reduced coordinated cluster representation (TP-RCCR) to obtain periodically repeated patterns and classify the defect of the fabric. TP-RCCR represents the structural information of fabric textures with high discrimination performance.
The above studies used different methods to discuss the identification and detection of fabric defects. It can be seen that many scholars have paid attention to the detection of automated fabrics, but they still need to be improved for real-time detection applications in the industry. Aiming at the real-time research of fabric detection, Cho et al. 9 applied a line-scan camera to develop a fabric inspection system. Raheja et al. 10 used an embedded DSP (digital signal processing) platform to develop a fabric defect detection system. Çelik et al. 11 illustrated a denim fabric inspection system. This system used Wiener, Mean, Gabor, and Gaussian filters to remove the texture and segment the defects of the fabric. The system reached successful application in a fabric inspection system. Feng et al. 12 proposed the hardware accelerated algorithm based on a small-scale over-completed dictionary to detect fabric defects. However, this paper used the database to analyze the algorithm efficacy, which did not use the actual system to verify the real-time ability. The above studies proposed different methods for real-time detection of fabric defects. There are a great variety of the fabrics. It is still necessary to improve the real-time detection and application in the real industry and it is impossible to apply a single method to detect different fabric defects.
Recent studies about the defect detection using a deep neural network shows good defect detection accuracy. Jun et al. 13 illustrated fabric defect detection and classification using a deep neural network with a two-stage strategy. Liu et al. 14 used the optimized neural network of the VGG16 model to distinguished between defect and non-defect fabric along with classifications. Li and Li 15 used the region-based convolutional neural network (R-CNN) method with three improvisation techniques to detect defects with their defect categories. Jing et al. 16 illustrated the classification and segmentation of defects for fabric materials using Mobile-Unet. Zhou et al. 17 used a semi supervised method using a variational autoencoder (VAE) to learn defect-free fabric and then compared it with other fabric samples to identify defect and non-defect fabric samples. The main disadvantages of deep learning methods are that they are time-consuming for the training, have a huge computational cost, and requires more datasets, otherwise models run into overfitting. The trained model can only be used in particular types of datasets that have been used in training and the model is very complicated, such that it then takes a long time to predict the samples. Therefore, for the implementation of a real-time defect detection machine, more research and a robust technique to implement in the industry are needed.
Existing automatic cloth inspection equipment uses linear cameras and multiple stations for inspection (Elbit Vision Systems (EVS)). However, due to the high hardware cost, it is difficult to introduce it into the traditional weaving industry. This study performed real-time fabric defect inspection system development for fabrics with different colors of home textile fabric, and employed an area-scan camera to extract the fabric image. An adaptive defect detection algorithm was proposed to automatically compensate the image brightness of fabric and overcome the uneven brightness. Defect classification can be carried out against fabrics with different colors. We hope the designed automated fabric inspection system not only needs only a little operational knowledge, but also greatly reduces the cost of manpower training. This machine will effectively detect defects for home textile fabrics, such as for the specific production of bed sheets, sheets, pillows, towels, quilts, duvets, heating cotton, down pillows, mattress quilts, poly floral quilts, and other related textile fabrics.
The design of the fabric defect inspection system and methodology
This section introduces the automatic fabric defect inspection system developed in this study; a flowchart comparing the manual defect inspection and this automatic inspection system is shown in Figure 1. The automatic inspection machine uses the area-scan camera to capture the weave fabric image. The model of camera is a Basler ace acA4600-10uc and it uses a USB 3.0 interface to transmit with the advantage of high system compatibility and carries out the image transmission without the need for an image capture card. It can effectively save the hardware cost compared with other camera transmission interfaces. The Basler Lens C125-0618 is matched to perform the fabric image capture. In consideration of the detection image transmission speed and optical distortion factor, the image capture resolution is 4600 × 600 and the range of image detection is 42 cm × 5.4 cm. To highlight the features of fabric defect, this study erected a bidirectional light source on the weaving system. The system architecture is as shown in Figure 2(a), and the actual erection of the system is as shown in Figure 2(b). Through the actual fabric defect inspection system test, the feasibility of the detection method proposed in this study is confirmed.

Fabric inspection flowchart for manual inspection and automatic inspection. (NG: Not Good).

Fabric defect inspection system framework description: (a) system framework and (b) actual framework system.
In order to verify the proposed system performance, this study used two area-scan cameras to extract the fabric image and validated 10 kinds of fabrics with different colors; the categories of fabrics from the home textile fabric manufacturer are as shown in Table 1. In addition to color differences, different fabrics have different yarn densities and organizational structures. The designed defect detection machine testing was carried out with different color fabric to prove the adaptability of the fabric defect inspection system. The types of fabric defect detection in this study include broken warp and float. The defect images are as shown in Figure 3. The causes of defects are (a) broken warps due to interrupted weaving while the warp yarn is not connected properly but weaving is continued, (b) broken wefts due to missing the woven for a short distance during weaving, (c) double picks due to the weaving gap between two woven yarns, (d) slubs due to a small section of yarn being curled and twisted while weaving, (e) knots due to protruding of the cloth surface, (f) holes due to the shuttle friction and licker roller while weaving, (g) stains due to lubrication of the textile machine, such as from oil, and dirt that falls to the cloth surface and creates defects, and (h) floats due to the opening angle of the weaving being too small and a few warp yarns being particularly slack. The defect identification is performed through the method proposed in this study to improve the production efficiency of fabric defects.
Sample categories of detected fabrics

Fabric detection defect types: (a) broken warp; (b) broken weft; (c) double pick; (d) slub; (e) knot; (f) hole; (g) stain and (h) float.
Fabric inspection algorithm
The detection flowchart of the adaptive real-time fabric defect inspection system is as shown in Figure 4 and the method will be introduced in this section.

Fabric defect detection flowchart.
Haar wavelet transform
Wavelet transform has the characteristics of multi-layer resolving capability and inverse transformation, which can remove the texture noise and reduce the amount of image information. This study used Haar wavelet transform to filter the image noise and has the advantage of a short calculation time. The Haar transform has been mainly used for image applications. A Haar transform decomposes each signal into two components, one of which is called average or trend and the other is known as difference or fluctuation.
18
This wavelet represents a sequence of square-shaped functions that together form a wavelet basis. For an input represented by a list of 2
n
numbers, the Haar wavelet transform simply pairs input values, storing the difference and passing the sum. This process is repeated recursively, pairing up the sums to provide the next scale: finally resulting in 2
n
–1 differences and one final sum. The Haar wavelet orthonormal transform can be expressed as follows
19
The N × N Haar transformation matrix contains the elements of hi (Z) for Z = 0/N, 1/N, …, (N–1)/N 3. The 4 × 4 Haar transformation matrix is shown as follows
The basic operation of a discrete wavelet transform is as follows: each row of a two-dimensional (2D) image is filtered with a low-pass and a high-pass filter and the output of each filter is down-sampled by a factor of two to produce the intermediate images L and H. Here, L is the original image low-pass filtered and down-sampled in the x-direction and H is the original image high-pass filtered and down-sampled in the x-direction. After that, each column of these new images is filtered with low- and high-pass filters and down-sampled by a factor of two to produce four sub-images (LL, LH, HL, and HH), as shown in Figure 5. Here, LL is the original image, low-pass filtered in the horizontal and vertical directions and sub-sampled by a factor of 2. 20 In this study, the Haar wavelet transform was used to reduce the amount of fabric image information and speed up the fabric detection algorithm, as well as being applied to real-time fabric detection.

Two-dimensional two-level Haar wavelet transform.
Fabric image brightness compensation
In view of the color diversity of the fabric samples and the brightness differences of the captured images, it is necessary to compensate for the brightness of the fabric image in order to achieve system adaptability. Firstly, the average value of the captured image was calculated so as to obtain the difference between the average value of the image and the target value of compensation brightness. Then the image brightness of fabric was compensated. The equation is as follows
Camera brightness calibration
If the fabric defect camera has a larger field of view of sampling, the optical path of the optical model of the camera will show a difference, resulting in non-uniform brightness of the image. Thus, the segmentation of the defect information and fabric defect detection become difficult. The least-squares method is often used to generate estimates of the relationships among variables. The mathematical procedure for finding the curve in a given set of the points is by minimizing the sum of the square.
21
In this study, the least-squares fitting was used to estimate the brightness distribution model of the camera, shown as follows
22
Then this model can rewrite the problem as
and then the model can get the pseudo-inverse for v
This study estimated the brightness distribution model of the camera through inputting the fabric images. Through the luminance distribution model obtained by least-squares fitting, the luminance correction array of the camera can be deduced by which the image brightness of the fabric can be compensated. The calculation process of the luminance correction array is complex and it requires huge memory and is time-consuming. Therefore, it is impossible to obtain the calculation result of every fabric image. Because the brightness distribution model of the camera is fixed, the array of luminance correction is calculated before the detection and the array value can be read in the detection process, which greatly reduces the calculation time.
Gaussian blur filter
Due to the texture of fabric images, it is necessary to remove the texture structure before defect segmentation. The Gaussian filter was used to remove the texture of fabric images in this study. This filter is a linear filter that selects weight based on the shape of the Gaussian function, and makes use of the normal Gaussian distribution to suppress noise.
23
The Gaussian kernel coefficients are sampled from the 2D Gaussian function
Random forest classifier and cross-validation
The random forest model 24 is one of the most popular machine learning algorithms due to its simple structure, easy implementation, resistance to overfitting, and other advantages. The random forest classifier is an ensemble learning technique that has capability to recognize a pattern, as shown in Figure 6. Compared with the artificial neural network and support vector machine, the random forest has a deeper model structure and is more effective for datasets with step manifold features. In addition, the random forest has the ability to learn from small samples and non-linearities. The random forest method uses Breiman’s bagging method. Bagging, which means “bootstrap aggregation,” is one of the types of ensemble learning introduced by Breiman 25 that improves the accuracy of a weak classifier by making a set of classifiers.

Random forest classifier.
Experimental results and discussion
This study proposed the detection system with the computer hardware specification of CPU: Intel Core i7-4770 K 3.50 GHz, RAM: 16 GB. The system adopted the software Microsoft Visual Studio 2012 to develop the program interface and image processing algorithm through a C++/CLR framework matching with OpenCV. In order to verify that the system proposed in this study can be applied to real fabric defect inspection, two cameras were installed on the fabric defect inspection system, performing the parallel processing detection operation with a background worker framework. The fabric inspection machine specification and functional specification are shown in Tables 2 and 3, respectively. The total cost of the fabric detection machine is 15,000 USD, which includes two charge-coupled device (CCD) area cameras, one computer, a light source, and a machine body. This low-cost machine can be affordable for small industries. The fabric defect inspection system speed was 30 m/min, which can carry out the detection of fabrics with 10 different colors, so as to verify the feasibility of the proposed method in actual detection applications.
Fabric inspection machine specifications
Functional specifications
In this study, the designed machine tests of defect identification ability for defects of different fabrics were conducted and the results for defects of different fabrics are as shown in Figure 7. As seen, the proposed method can be used to carry out defect identification of fabrics with different colors, and effectively identify the defect location. Among them, the broken weft defect in Figure 7(f) had a small difference from the fabric texture, but the defect location can still be selected. In Figure 7(g), the brightness of the extracted fabric image is low, but the defect area is still available to be identified by the proposed method to carry out the brightness correction and compensation. In Figure 7(j), the fabric images had a larger texture difference. This study applied the image’s standard deviation to calculate the threshold value of defect segmentation, and even smaller defects can be effectively identified. Table 4 presents the performance evaluation of the proposed method where there were 10,726 images of different fabrics extracted by two cameras with true detection (TD), FD, misdetection (MD), and overall detection (OD) as the system detection criteria. 26 The system developed in this study had good effects on the detection of different fabrics, among which the lowest TD rate was 96.79% and fabric defect rate was 3.21%. There were in total 10,587 TDs and 139 FDs. The result showed that the proposed method had good defect identification ability.

The detection results of different fabrics. Left-hand side: original images. Right-hand side: results of image processing.
Evaluation of inspection system performance
TD: true detection; FD: false detection; MD: misdetection; OD: overall detection.
As for the configuration of camera analysis, the smallest defect identification size of the real-time fabric defect inspection system developed in this study is 1 mm. The proposed defect identification algorithm was applied to 10 kinds of fabrics with different colors for detection, successfully identifying the defects of different fabrics and verifying the adaptability of the proposed method. The total average operation time of defect recognition is 89 ms for extracting and handling the image, which can be applied to practical online fabric detection.
A comparison between other methods and the proposed method for real-time fabric defect inspection is shown in Table 5, where the comparisons are based on the average TD, fabric winding speed, detection speed, and minimum defect size. It is clearly seen that the proposed method is more effective than other methods in terms of defect detection accuracy and speed and in terms of total cost. The proposed method is under operation and the cloth inspection efficiency has increased by more than 200%. The automatic fabric inspection system developed an inspection speed of 30 m/min, which can increase inspection efficiency by 200–270% compared with the current manual inspection speed of 8–10 m/min, and detects the location of the defects. It will automatically store the inspection information record and reduce the time for recording or shutdown operations, and the system can automatically generate a designed machine test report after the final test.
Comparison table between others method and the proposed method
However, the proposed method in this study has one limitation in terms of type of fabric detection. This study used calendered fabric with a single color; therefore, other than calendered fabric this system may not perform well. However, the proposed system can be used for other types of fabric if the system is trained with the defect dataset.
Conclusions
An automatic fabric defect inspection system is designed to effectively improve the production efficiency of fabrics. This research developed an adaptive fabric defect inspection system used for fabric defects, and performed luminance compensation and correction through the proposed algorithm as well as the adaptive fabric defect segmentation. In the proposed method, two cameras were used to conduct the fabric defect identification with the testing speed of 30 m/min, and the system capability was verified through fabrics with 10 different colors. It was shown that the defect recognition average TD rate of the proposed method is more than 98.70%, which had good adaptability and accuracy. Moreover, the average processing time of a single image was only 70 ms, which proved the real-time operation ability. This low-cost and high-performance defect designed machine can be affordable for the small- to large-scale home textile industries. The proposed system has the ability to adapt itself to the identification of fabric defects. During the detection process, it is not necessary to adjust the parameters when the fabric type changes and thus it has practical real-time application effectiveness.
Footnotes
Declaration of conflicting interests
The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.
Funding
The author(s) disclosed receipt of the following financial support for the research, authorship, and/or publication of this article: This work was supported by the Ministry of Science and Technology of the Republic of China (grant no. 110-2221-E-011-005).
