Abstract
The layout of colored yarns in yarn-dyed fabrics is a significant part of designing and production in the textile industry, which is still analyzed manually at present. Existing methods based on image processing have some limitations in accuracy and stability. Therefore, an automatic method is proposed to recognize the layout of colored yarns and some other basic fabric structure parameters: the fabric density and weave pattern. First, a large dataset with fabric structure parameters is constructed. The fabric images are captured by a wireless portable device. Then the yarns and floats are accurately located using a novel multi-task and multi-scale convolutional neural network. Finally, a density-based color clustering algorithm is proposed to recognize the layout of colored yarns. The results of extensive experiments show that the proposed method can automatically identify the basic structure parameters with high effectiveness and robustness.
Keywords
In the process of design and production, the analysis of fabric structure parameters is an indispensable step in the textile industry. The layout of colored yarns, as an essential structure parameter, is especially vital for the production of yarn-dyed fabrics. However, its analysis still relies on manual operations, which are labor-intensive and time-consuming. Therefore, it is essential to find a competent and objective automatic method for the recognition of the layout of colored yarns.
With the improvement in image processing technologies, scholars have presented many automatic recognition methods and achieved much impressive progress.1–3 Their methods show high performance for specific kinds of fabric and can be applied in certain environments. However, there are still some problems:
Some existing methods usually depend on a high image resolution, which makes the image acquisition system cumbersome and expensive. Some methods need to tune parameters according to different fabric types, causing low adaptability. The diameters of yarns and weave patterns are diverse, which causes some errors in locating and recognizing the colored yarns.
In our previous work,
4
we creatively utilized a convolutional neural network to accurately locate yarns, showing high accuracy in the location of yarns and fabric density measurement. In this study, a novel hybrid method is proposed to recognize the layout of colored yarns and some other parameters: the fabric density and weave pattern. The flow chart of the proposed method is shown in Figure 1. First, a database with a wide range of fabrics is established by a portable device. Then, a new multi-task and multi-scale convolutional neural network (MTMSnet) is proposed to locate yarns and floats jointly. Using the results, every single float is located, and its color information is extracted. Next, a density-based color clustering algorithm (DBCCA) is introduced to cluster the color of yarns. Finally, the layout of the colored yarns and the color effect are recognized by combining the weave pattern and the color clustering results. During the process, the fabric density and the weave pattern are also obtained.
Flow chart of the proposed method.
The framework of the paper is organized as follows. In the next section, some related work is reviewed. Then, the image acquisition system and the establishment of the dataset are introduced, and the proposed method, which utilizes the MTMSnet for yarn and float location and the DBCCA for the clustering of colored yarns, is described. In the following sections, the experiments are then described in detail, the results are given, and the effectiveness of the proposed method is discussed. Finally, conclusions are drawn.
Related works
In general, to recognize the layout of colored yarns, existing methods mainly include two procedures: the location of yarns or floats, and the clustering of colored yarns.
For the location of yarns or floats, existing methods can be divided into two types: frequency-domain methods and spatial-domain methods. The frequency-domain methods convert the image to the frequency domain by utilizing the periodical nature of the yarn layout. The typical method is the fast Fourier transform,5,6 which selects characteristic frequency points to reconstruct feature images. Zheng et al. 7 used the discrete wavelet transform to extract edge information and locate yarns. However, the power spectrum is often noisy, and the results are often marred by the irregular distribution of the yarns and the color of yarns. Moreover, these methods show poor performance for sophisticated fabrics, especially yarn-dyed fabrics and jacquard fabrics, owing to their complex periodical nature.
The main principle behind the spatial-domain methods is the analysis of brightness variation to determine the location of yarns and the crevices. Zhong et al., 8 Huang et al., 9 and Huang and Liu 10 used the gray projection to locate yarns, but the method depends heavily on the ability to locate the local peak, which is easily affected by the slanted placement of the fabrics. Thus, Pan et al. 11 used the Hough transform to detect the skew angle of the placement, increasing the accuracy of yarn location. Other widely used spatial-domain methods utilize the co-occurrence matrix, 12 the quadratic local extremum, 13 and morphology analysis. 14 However, owing to the interstices between the yarns, the subsequently identified color of yarns may produce interference.
For the clustering of colored yarns, Luo et al. 15 described how the instrumental color may be influenced by the yarn texture and used a modified k-means clustering approach to analyze the fabric structure parameters. Han et al. 16 proposed a lightness-biased cartoon-and-texture decomposition method for color segmentation of fabric images. Zheng et al. 17 used a multi-region fuzzy segmentation process to realize the color classification and then, based on the segmentation results, detect the yarn location. Although the color classification results of their method are relatively precise, there is always some error in judging the yarn position. Xin et al. 18 proposed an active grid model to identify the color pattern by acquiring duel-side fabric images. Zhang et al.19–21 conducted a series of studies of the automatic detection of the layout of colored yarns of different kinds of yarn-dyed fabric. They divided the fabric images into some sub-images to locate yarns and used the fuzzy c-means (FCM) clustering method to classify the colored yarns. The drawbacks of their method are that they have to deal with different types of yarn-dyed fabrics individually and that the number of yarn colors need to be specified in advance. Pan et al. 22 adopted a genetic algorithm and Xu and Lin 23 used neural networks for automatic yarn color classification. There might be some errors in their results, and Zhou et al. 24 introduced an error-correcting method to improve the accuracy of the recognition. Although their methods show certain adaptability and accuracy, some weaknesses are shown in the actual production, owing to the cumbersome image acquisition system.
In the past few years, convolutional neural networks have been widely used to solve pattern recognition problems. With the help of the excellent feature extraction capability of the convolutional neural network, we develop the MTMSnet to locate yarns and floats accurately. Meanwhile, inspired by the success of a density-based algorithm (DBSCAN) 25 that does not need the number of clusters to be specified and can discover clusters from the dataset with arbitrary shape, we propose a DBCCA to cluster colored yarns. The algorithm does not consider noises and uses a color difference formula (CIEDE2000) 26 to calculate the distance for the aim of color clustering. These improvements increase the accuracy and adaptability of the method for fabric structure analysis.
Image acquisition system and dataset establishment
Image acquisition system
To extend the application range, a new portable wireless device is used to capture fabric images in sRGB mode. The details of the device are shown in Figure 2. The device is equipped with a prime lens, and its distance to the fabric is fixed to ensure a fixed spatial resolution. Below the lens, it has eight small LEDs to provide constant illumination. The captured image is transferred wirelessly to a server with the help of a WIFI module to analyze the fabric structure parameters further. During image acquisition, it is necessary to ensure that the device is close to a clean and flat fabric surface. The spatial resolution is set as 4680 pixel/inch, and the image size is 1280 pixels × 720 pixels.
Portable wireless fabric image acquisition device.
Compared with other image acquisition systems, the device has the advantages of small size and wireless connection, which allows us to capture images and establish a dataset quickly. Moreover, the application range and portability are significantly increased. It should be noticed that the proposed method does not rely heavily on the image acquisition system, as long as the spatial resolution of the image is within a suitable range.
Dataset establishment
We collected about 400 kinds of fabric with detailed parameter information from a factory. The information contained the fabric density, the weave pattern, the layout of the colored yarns, and some other parameters. Then, by using the image acquisition system, an elaborate dataset was established, which covered a wide range of fabric types, such as solid color fabrics, yarn-dyed fabrics, and jacquard fabrics. There were no identical or quite similar images in the dataset. Figure 3 shows the distribution of the warp and weft densities and fabric types in the dataset. In Figure 3, the axes indicate the distribution of fabric densities, and different symbols signify different basic fabric types. The number of different fabric types are given in the figure key.
Distribution of warp and weft densities and fabric types in the dataset.
Label generation
To train the network, which will be introduced in the next section, we labeled the locations of yarns and floats in every fabric image and tried different label generating strategies.
For yarn location, we labeled the outline of every yarn in the dataset and used a smooth label strategy to generate yarn location maps. A Gaussian distribution was adopted to express the information about the location of yarns. Its effect has been proved in our previous work.
4
For the location of floats, we randomly labeled a basic weave repeat and combined the locations of yarns to generate every float location. If the image did not have a basic weave repeat, we labeled all floats. To generate float location maps, we used a hard-label strategy, which adopts 0 or 1 to represent whether a pixel belongs to a float or not. This is because float classification is a binary classification problem, and it shows better performance in experiments. Because we do not train the network to learn the layout of colored yarns, it is not necessary to label the color of each yarn, but we still marked the color of every yarn in the test set, for evaluation.
A labeled fabric image sample, two generated yarn location maps, and two float location maps are shown in Figure 4. The four location maps were used to train the model. Finally, we established an elaborate fabric dataset with 800 images, which not only covers a wide range of fabric types but also contains the location of yarns and floats, as well as the structure parameters. The establishment of the dataset allows us to better train and evaluate our network.
Labeled image and its generated location maps for training: (a) labeled image; (b) warp location map; (c) weft location map; (d) warp float location map; (e) weft float location map.
The proposed method
In this section, we introduce the architecture of the multi-task and multi-scale convolutional neural network (MTMSnet). Then we describe the steps involved in processing the location maps to predict the fabric density and weave pattern. Finally, we give the details of the DBCCA used to recognize the layout of the color pattern.
Multi-task and multi-scale convolutional neural network
The architecture of the proposed MTMSnet is illustrated in Figure 5. It contains three components: a shared multi-scale feature encoder, which extracts features of the image, a yarn location map decoder, which decodes the extracted feature maps to predict warp and weft yarn location maps, and a float location map decoder to predict warp and weft float location maps.
Structure of the proposed MTMSnet.
By combining the warp and weft yarn location maps, we can calculate the fabric density and locate the intersection points. Then, because the relative location between the four predicted location maps has not been changed, the location of intersection points plus the warp and weft float location maps ensures recognition of the weave pattern. Furthermore, the encoder and decoder enable the network to address some general object location problems, such as defect detection, face detection, and crowd counting. Owing to the multi-task structure, the network is also suitable for extracting related features, such as the extraction of defect features and facial landmarks.
Shared multi-scale feature encoder
As shown in Figure 6, the initial shared multi-scale feature encoder is made up of four multi-scale modules to extract features. Owing to the diversity of yarn diameters and float sizes, each multi-scale module has four different sizes of filter, to ensure that the net has a more extensive local receptive field. A 1 × 1 filter is added before each filter to reduce the feature dimensions. Each interior layer has the same feature maps for concatenation. A 2 × 2 maximum pooling layer is applied to eliminate most texture noises and retain robust features. A rectified linear unit is adopted as the activation function after every layer. The existence of shared convolutional features improves the field of focus to extract texture features of yarns and floats and reduces the number of parameters required.
Structure of the multi-scale module.
Yarn location map decoder
The yarn location map decoder contains four transposed convolutional modules to refine the details of feature maps step by step. Three 2 × 2 transposed convolutional layers are added between the four convolutional layers to ensure that the outputs have the same size as the input image. Rectified linear unit activation is applied in each layer to avoid gradient vanishing. The mean square error (MSE) and structural similarity index (SSIM) are used as loss functions; their effectiveness has been proved in our previous work.
4
The definitions are
Float location map decoder
There are minor differences between the floats location map decoder and the yarn location map decoder. Because a hard-label strategy is adopted to generate float location maps as the ground truth, the activation function of the output layer is set as sigmoid and the loss function is set as binary cross entropy (BCE), which is defined as
Using sigmoid as the activation function and BCE as the loss function will accelerate convergence and reduce the classification error for the binary classification problem.
Float location and classification
The trained model takes a fabric image of arbitrary size, and outputs two sets of location maps: warp and weft yarn location maps, and warp and weft float location maps. The size of the images in each set is the same. Figure 7(a) to (f) shows a fabric image sample and its predicted location maps. It can be seen that the trained model successfully extracts the yarn and float features and eliminates most of the noises. Next, the following steps are introduced to realize fabric density measurement and weave pattern recognition.
Predicted location maps and subsequent processes for fabric density measurement and weave pattern recognition: (a) test fabric image sample; (b) predicted warp location map; (c) predicted weft location map; (d) predicted warp float location map; (e) predicted weft float location map; (f) combination of image for weft float location map and original image to show the predicted effect; (g) skeletonized image of warp location map; (h) skeletonized image of weft location map; (i) rotated original image and its region of interest, the red rectangle region; (j) smoothed warp projection curve; (k) smoothed weft projection curve; (l) rotated original image and boundary box of floats; (m) heat map for probabilities of each float as a warp float; (n) schematic diagram of recognized weave pattern; (o) distribution of colored yarns in CIELAB color space, and clustering results; (p) recognized layout of colored yarns.
Skew angle detection
Owing to the placement of the fabric samples, the skew of the warp and weft yarns cannot be ignored. Therefore, the skew angle is detected based on the predicted yarn location maps. First, the Otsu algorithm
27
is applied to convert the yarn location maps to binary images, and the Zhang–Suen thinning algorithm
28
is used to skeletonize the binary images to save computation time. Next, the Hough transform
29
is conducted to detect the skew angles of warp (
Fabric density measurement
Image projection is used to locate the warp and weft yarns. The rotated warp location map is projected along the column, and the rotated weft location map is projected along the row to get the projection curves. A 5 × 1 minimum filter is adopted to smooth the curve. The final smoothed projection curves are shown in Figure 7(j) and (k). Because the predicted location maps mainly retain the yarn information, the smoothed projection curves are almost noiseless. By locating the local maxima (Pc), the fabric density (d) can be derived
4
as
Float location
The two minima (Pl, Pr) on either side of a local maximum (Pc) represent the boundary of the yarn. The boundary box of each intersection point can finally be obtained by combining the Pl and Pr of each warp and weft. Figure 7(l) shows the predicted boundary box of every intersection point in the original image. It can be seen that the boundary box retains the core of floats and that the interstices are not included; this ensures the accuracy of the subsequent float classification and color recognition.
Float classification
Because the relative location between all the predicted location maps has not been changed, once the location of the intersection point has been obtained by combining the yarn location maps, the float type can be classified by summing the values within the boundary box in the corresponding location of the float location maps. The float type is determined as
Basic weave repeat recognition
Because the number of yarns is relatively small, we calculate the size of the basic weave repeat using the Su index, which is proposed by Pan et al. 30 The main principle is to calculate the probabilities of different repeat sizes from two to the number of yarns. Once the size is obtained, the basic weave repeat can be extracted by randomly choosing the same size for the whole predicted weave pattern.
Yarn color features extraction
After these steps, every float is obtained in RGB mode. However, the RGB color space is not a uniform color space and does not matched the characteristics of the human vision system (HVS). Because CIELAB is a relatively uniform color space and is widely used for color difference evaluation, 31 especially in the textile industry, 32 all the floats are converted to the CIELAB mode. 33 The color specification of a single strand of yarn is ambiguous because the pixel values vary with positions, owing to the effect of the three-dimensional shape of yarns. In this paper, the mean values of L, A, and B of the warp floats on each warp yarn, and the mean values of L, A, and B of the weft floats on each weft yarn are calculated as the color features. The layout of colored yarns can be analyzed by clustering the color features of yarns.
Recognition of colored yarns
Current clustering methods include FCM, 34 k-means, 15 and neural networks.35,36 The main drawbacks of these methods are that the number of clusters must be specified. Although some improved color clustering methods24,30 do not need the number of clusters to be specified, those methods are not aimed at color clustering, and their calculation times are relatively long. Inspired by the success of density-based methods25,37 in discovering clusters from datasets with arbitrary shape, and without specifying the number of clusters, we improve the DBSCAN and propose a DBCCA.
Since the clustering of colored yarns can be considered noise-free, the minimum number of points (minPts) is set as one. At the same time, a color difference formula (CIEDE2000) is used to calculate the distance of two colors instead of the Euclidean distance. The DBCCA is relatively parameter-free and more suitable for color clustering. The pseudo code of the DBCCA is shown in Figure 8, which has some modifications compared with DBSCAN.
Pseudo code of DBCCA.
The main principle of the DBCCA is that the collection of all the density-reachable points is set as a cluster. The collection of density-reachable points is defined as follows. If point q is within distance ε from p, the point q is directly reachable from p. If there is a path p1, p2, …, p n where each pi + 1 is directly reachable from p i , all the points within the path make up a collection of density-reachable points.
The calculation of the distance can be considered the calculation of color difference (
Figure 7(o) shows the distribution of colored yarns in the CIELAB color space and the clustering results based on the DBCCA. Figure 7(p) shows the recognized layout of colored yarns. We can finally recognize the layout of colored yarns and the color effect by combining the weave pattern and the results of the clustering of colored yarns.
Experiments
The hardware used in this study included a server with Intel Core i9-7900x CPU, GTX 1080Ti GPU, and 32 GB RAM. The algorithm was implemented on the Keras 2.2.4 framework with Tensorflow 1.13.0 as the backend. A series of experiments were conducted to evaluate the effectiveness of our proposed method.
Training details
Number of fabric types in the training and test sets
Evaluation details
To evaluate the fabric density measurement, we also estimated the mean-absolute-percentage error (MAPE) and the mean-squared-percentage error (MSPE),
4
which are defined as
For the weave pattern recognition, we followed the convention of existing works, which used the recognition error of weave pattern (WRE), calculated as
For recognition of the layout of the colored yarns, we calculated the recognition error of color pattern (CRE) to evaluate the model, which is based on the yarn-dyed fabrics in the test set. The definition is
To further evaluate the effectiveness of the DBCCA for the clustering of colored yarns, the commonly used indexes for evaluating the clustering methods—adjusted Rand index (ARI) 41 and Fowlkes–Mallows index (FMI) 42 —were adopted.
The ARI is calculated based on the test set, to evaluate the similarity between the clustering results and the real situation. Its values range from −1 to 1. The larger the value, the more consistent the clustering results with the ground truth. The calculation is defined as
The FMI is defined as the geometric average of the pairwise precision and recall of the clustering results, which is more comprehensive for qualitative analysis. The range of scores is [0, 1]. A high value indicates a good similarity between two clusters. The definition is
To evaluate the effectiveness of the method, we record the time consumption. A hot-loading method is used to eliminate the time for loading the weights of the model.
Results and discussion
Results
In the experiment, some representative fabric samples in the test set were displayed for qualitative evaluation. Figure 9 shows the original fabric samples, predicted location maps, recognized weave patterns, and recognized color effects. The results illustrate that the method can correctly locate yarns and recognize most of the weave patterns and color patterns. However, it has minor errors in dealing with complex weave patterns, such as jacquard fabrics.
Some representative fabric samples and the recognized weave patterns and the layouts of colored yarns in the test set: the largest complete weave pattern is marked with a red rectangle, and misjudged floats are marked in red.
From a quantitative perspective, the estimated CRE of the yarn-dyed fabrics in the test set (77 in 100) is 10.39% for the recognition of the layout of colored yarns. For weave pattern recognition, the estimated WRE of the whole test set is 8%. Conversely, the proposed method can accurately measure fabric density. The estimated MAPEs of warp and weft densities in the whole test set are 1.38% and 1.65%, respectively, and the MSPEs are 2.28% and 2.43%, respectively. All these results demonstrate that the proposed method can jointly realize fabric density measurement, weave pattern recognition, and the recognition of the layout of colored yarns with high accuracy and robustness.
In terms of the computation time, the method takes about 6.73 s in all for an image to output the warp density, weft density, full weave pattern, basic weave pattern, and layout of the colored yarns and color effect. However, when the model is hot-loading, the computation time is less than 1.80 s. This is because the hot-loading does not load the weights every time, and the method outputs the schematic values of the patterns instead of the images of the weave pattern, basic weave pattern, and color effect. Moreover, by using a portable device, the fabric structure parameters can be conveniently obtained within 10 s.
The method shows errors when dealing with some more complex fabrics, resulting from faults in locating the floats or yarns. This is because the Hough transform is used to calculate the average skew angle, but the skew angle of each yarn is not the same, while some yarns are curved. Moreover, even the human eye can scarcely tell the float type apart in some images.
It should be noted that the method does not rely heavily on the image acquisition device. If the yarns and floats in the image can be clearly distinguished by human vision, the MTMSnet can achieve favorable results. Figure 10 shows the predicted weft yarn and float location maps based on different resolutions. When the resolution is too large or too small, there are some deficiencies in the predicted location maps. In practice, the recommended range of the fabric density is 50–250 thds/inch, and the fixed spatial resolution of the fabric image is better between 3000 pixel/inch and 12000 pixel/inch. The fabric should not have large curved or overlapped yarns, such as nap fabrics, or two-layer fabrics.
Predicted yarns and floats location maps with different image resolutions: (a) 3078 PPI, (b) 4680 PPI, (c) 5925 PPI, (d) 12312 PPI.
Evaluation of dataset size
Evaluation indexes of MTMSnet trained with different sizes of training set; the MAPE and MSPE are calculated for the mean values of the estimates of warp and weft densities
Boldface indicates the best values.
Evaluation of ε
The threshold of distance ε = 5 was adopted by an experience value, which is considered as a noticeable difference for human vision. To select a suitable value of ε, a series of experiments with different values of ε were carried out. The range of ε was [0.1, 10], and the step was set as 0.1. The variation curves of ARI and FMI are shown in Figure 11. The results show that when ε = 5.2, the cluster results of the DBCCA have maximal ARI and FMI. In this study, ε was set as 5.2 for the clustering of colored yarns based on our image acquisition system. The illumination was not strict, and the target of our problem was the clustering of colored yarns, so ε is still recommended as 5 for the general color clustering problem.
Evaluation based on different ε.
Evaluation of different color spaces
Clustering results based on different color spaces and distance calculation methods
Boldface indicates the best values.
Evaluation of different distance calculation methods
In calculating the color difference, we used the CIEDE2000 instead of the CIE76. The nature of the CIE76 is to calculate the Euclidean distance. Considering that different distance calculation methods have different best values of ε, the best value of ε is calculated using the same method as mentioned previously. The results are also shown in Table 3. The CIEDE2000 gives larger ARI and FMI than the CIE76 in general. This is mainly because the perceptual ability of human vision for different colors is different. The same color distance may give a huge difference from human sensitivity. The results verify that the CIEDE 2000 is more suitable for the method to cluster colored yarns.
Comparisons between different color clustering methods
Comparisons between different clustering methods
Boldface indicates the best values.
Comparisons between different methods
Evaluation indexes and processing times of different methods: (1) step angle, min angle, and min distance of the Hough transform are 1°, 10°, 9, respectively; (2) fuzzy weighting exponent of FCM are all set as 2; NAN indicates that the method was not used to recognize weave patterns, as it was based on a weave pattern database
Boldface indicates the best values.
Conclusion
In this article, a novel hybrid method is proposed to automatically recognize a series of fabric structure parameters: the fabric density, weave pattern, and layout of colored yarns. An elaborate fabric dataset is established using a portable device, which ensures the development of the proposed MTMSnet for the locating of yarns and floats. The colored yarns are then clustered with the help of the DBCCA, which is aimed at color clustering. Experiments demonstrate that the method has the following advantages:
Low errors. The errors for fabric density measurement, weave pattern recognition, and recognition of the layout of colored yarns are relatively low, compared with other methods. Good robustness. The evaluation results of the method in the test set, which covers different kinds of fabric, verify the adaptability of the method. High efficiency. The portable wireless device makes it fast and convenient to capture images. The application range is significantly increased.
Although the proposed method reaches high performance, it still has some limitations:
The establishment of the dataset is time-consuming. The method cannot deal well with fabrics that contain large curved or overlapped yarns.
In the future, the detailed directions of our research are as follows:
The dataset will be further expanded. The enhancement of the structure of the MTMSnet or new end-to-end methods will be studied. An online web service will be established for the automatic detection of fabric structure parameters.
Footnotes
Declaration of conflicting interests
The authors declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.
Funding
The authors disclosed receipt of the following financial support for the research, authorship, and/or publication of this article: This work was supported by the National Natural Science Foundation of China (Grant No. 61976105).
