An objective fabric pilling evaluation based on wavelet transform and Gabor filter

A new objective fabric pilling detection method is proposed for monochrome fabric without pattern. Firstly, through wavelet multi-resolution decomposition and reconstruction, remove the high-frequency noise such as fluff which is significantly different from the size of pills and low-frequency noise such as uneven illumination. After wavelet multi-resolution decomposition of fabric image, through analyzing the energy change law between each wavelet decomposition layer, and then the fabric is judged whether it is rough or fine texture. Then, according to the different color characteristics of fine texture and rough texture fabrics, the even symmetry two-dimensional Gabor filter with smoothing effect and the odd symmetry two-dimensional Gabor filter with edge extraction ability in different directions are selected for texture removal. Finally, fabric pilling parameters are extracted to realize fabric pilling grade evaluation. The main contribution of this method is: on the premise of removing the noise such as uneven illumination and fluff, on the basis of considering the different color change laws of fine texture and rough texture, using the directionality of fabric texture and the randomness of pills direction to effectively remove the texture noise, so as to improve the accuracy of fabric pilling grade evaluation.


Introduction
Pilling caused in wear and care procedures is one of the most serious problems for the apparel industry. 1,2 Conventionally, fabric pilling grade is evaluated through trained human eyes in accordance to the pilling standards, to determine the grade of pilling on a level ranging from 1 to 5 (from severe pilling to no pilling). 3,4 This subjective method is inevitably lack reproducibility and repeatability. 5 All of the above have led to the development of various automated pilling evaluation systems based on image analysis that are more objective.
At present, the mainstream fabric pilling methods mainly include two-dimensional image method and three-dimensional image method. 6 The three-dimensional image method can generally extract the pills height information, so it can process the pills extraction of non unicolor fabrics with complex patterns. However, the three-dimensional image method not only has high requirements for the image acquisition environment, but also often requires additional lighting equipment and complex acquisition equipment. For example, even if the 3D fabric surface reconstruction method claims to use cheap and accessible equipment, four lighting devices are still required, and there are strict requirements on the placement distance and placement angle of lighting devices relative to fabric samples. 7 The two-dimensional image method mainly extracts the pills information based on the difference between the pills and the background in color, [8][9][10] size [3][4][5][11][12][13] , periodicity of texture color change, [14][15][16] and so on. However, due to the small color difference between the pills and the background such as fabric texture, and the randomness of the pills size, so far, even the wavelet transform method with quite good denoising effect still has the problem that some fabric textures are not removed cleanly, which affects the accuracy of pills parameter extraction.
In order to solve this problem, based on the ability of local binary pattern (LBP) algorithm to detect texture, some researchers use the change of texture color change law caused by non texture factors to remove the influence of texture noise on fuzzing and pilling grade evaluation or defect detection in fabric image. 4,17 However, compared with defects, the damage degree of pills to texture is weak and the damage range of single pill is small, so the change of texture arrangement law is small. In addition, the change of texture arrangement law caused by the randomness of pills shape and size is random. Therefore, it is not the best choice to remove the influence of fabric texture on pills detection by LBP algorithm.
In this study, the idea of combining wavelet transform algorithm and Gabor algorithm is proposed. The wavelet multi-resolution layered characteristic is used to remove the high-frequency noise such as fabric fluff and low-frequency noise such as uneven illumination, and then the texture noise is removed according to the excellent image smoothing ability or texture extraction ability of Gabor algorithm, so as to realize the robust extraction of fabric wool ball. Figure 1 shows the flow chart of system framework.

Main algorithm analysis
Discrete Haar wavelet transform and Gabor transform are the decisive algorithms in this study. In this section, their working principle is briefly introduced

2DDHWT analysis and application problems
Define two-dimensional scaling function ϕ x y , ( ) and three two-dimensional wavelet functionsψ H x y , Where x, y refers to the spatial coordinate index, and the unit is pixel, the same below. The ψ H in equation (2) measures the variations of gray level of the image along the columns (e.g. horizontal edges), ψ V in equation (3) responds to variations of gray level of the image along rows (like vertical edges), and ψ D in equation (3) corresponds to variations along diagonals.
Given two-dimensional scale and wavelet function, 18 as shown in equations (5) and (6) respectively.
Where index identifies the directional wavelets in equations (2)-(4). Rather than an exponent, is a superscript that assumes the values H,V and D. The discrete wavelet transform of image f (x,y) with the size M×N pixels is then defined as equation (7) and (8).
Where j 0 is an arbitrary starting scale an the W j m n . Among several wavelet transforms, Haar transform has good frequency stratification ability and is the simplest one. 18 Therefore, Haar transform is selected as the denoising algorithm of fabric pilling image.
Equations (9) and (10) show the Haar wavelet scaling function and wavelet function in one dimension respectively. 19 The two-dimensional discrete Haar wavelet transform wavelet (2DDHWT) decomposes an image into one low frequency approximate sub-image and three high frequency detail sub-images at each decomposition scale. 3 Take the three scales 2DDHWT decomposition of Figure 2(a) shown in Figure 2(b) as an example to illustrate some wavelet concepts. In Figure 2(b), and represent the high-frequency detail sub-images corresponding to horizontal, diagonal and vertical orientations at the level decomposition scale respectively, and expresses the low frequency approximate sub-image. Different 2DDHWT decomposition levels reflect different frequency information. The 1-level wavelet decomposition layer contains the highest frequency information in the image, the 2-level wavelet decomposition layer contains the second highest frequency information in the image, and so on.     The noise in a pilled fabric image mainly includes fabric texture, surface unevenness, illuminative variation, and high-frequency noise. [3][4][5][11][12][13] The high-frequency noise in the fabric pilling image mainly appears in the first layer of wavelet decomposition, while the low-frequency noise caused by uneven fabric and uneven illumination mainly appears in the approximate layer after 6-layer wavelet decomposition. [3][4][5] The fabric texture often appears on the two adjacent wavelet decomposition layers. 3 The texture roughness is different, and the adjacent wavelet decomposition layers are different. 3 Wavelet transform can remove noise by setting the coefficients of wavelet decomposition layer containing noise information to zero and then wavelet reconstruction.
However, for some fabrics, the effect of texture removal by this denoising method is not ideal.
In Figure 3, the pilled fabric image was decomposed in six scales by 2DDHWT , and because the fabric texture information mainly exists in two adjacent scales, 3,4 the decomposed image was reconstructed at any two adjacent scales by simply retaining the scale j( s j ) and scale j +1   Figure 3(f), we can see that the pills are obviously different in size and shape, and because of serious pilling, the background texture is slightly damaged. All these lead to the failed separation of fabric texture and fabric pill, see Figure 3(a)-(e).
To solve this problem, Gabor filter is selected to remove the fabric textures based on the roughness of fabric.

Gabor filter analysis
Gabor filter is windowed Fourier transform. Compared with Fourier transform, Gabor filter can well describe local structural information such as spatial frequency, spatial location and direction of processed target, and achieve optimal localization, so it is a good texture expression, description and removal method. Even and odd symmetry two-dimensional Gabor filters used in this study are shown as equations (11) and (12) respectively. 20,21 The noise in a pilled fabric image mainly includes fabric texture, surface unevenness, illuminative variation, and high-frequency noise. [3][4][5][11][12][13] The high-frequency noise in the fabric pilling image mainly appears in the first layer of wavelet decomposition, while the low-frequency noise caused by uneven fabric and uneven illumination mainly appears in the approximate layer after 6-layer wavelet decomposition. [3][4][5] The fabric texture often appears on the two adjacent wavelet decomposition layers. 3 The texture roughness is different, and the adjacent wavelet decomposition layers are different. 3 Wavelet transform can remove noise by setting the coefficients of wavelet decomposition layer containing noise information to zero and then wavelet reconstruction.
However, for some fabrics, the effect of texture removal by this denoising method is not ideal.
In Figure 3, the pilled fabric image was decomposed in six scales by 2DDHWT, and because the fabric texture information mainly exists in two adjacent scales, 3,4 the decomposed image was reconstructed at any two adjacent scales by simply retaining the scale j ( s j ) and scale j +1 (s j +1 ) detail coefficients, and setting the other scale (s s s s ,..., , ,...

− +
) detail coefficients to zero, where the j value is 1-5. Figure 3(f) shows the original knitted fabric image. From Figure 3(f), we can see that the pills are obviously different in size and shape, and because of serious pilling, the background texture is slightly damaged. All these lead to the failed separation of fabric texture and fabric pill, see Figure 3(a)-(e).
To solve this problem, Gabor filter is selected to remove the fabric textures based on the roughness of fabric.

Gabor filter analysis
Gabor filter is windowed Fourier transform. Compared with Fourier transform, Gabor filter can well describe local structural information such as spatial frequency, spatial location and direction of processed target, and achieve optimal localization, so it is a good texture expression, description and removal method. Even and odd symmetry two-dimensional Gabor filters used in this study are shown as equations (11) and (12) respectively. 20 Where u, v are frequency variables. Where θ is the angle indicating the direction of the filter, δ u and δ v are the standard deviation of Gaussian envelope along the u -axis and v -axis respectively, ω express the frequency, and u -axis is parallel to θ and v -axis is vertical to θ . The ratio δ δ u v decides the length to width ratio of the filter, and δ u and ω decide the filter bandwidth as expressed in equation (13).
Where b represents bandwidth, and must be a positive real number.
The even symmetry two-dimensional Gabor filter shown in Figure 4(a) is a filter formed after the sinusoidal plane wave propagating in frequency f along the direction θ is enveloped by Gaussian function, so it can smooth image. 20 And the odd symmetry two-dimensional Gabor filter shown in Figure 4(a) is odd symmetric about the center, so the integral in its integral region is 0, so it can effectively detect edges. 21 In Figure 4, the parameters δ u and δ v are specified as 2, ω is preferably 0.76 and θ is set to 135°.

Fabric image acquisition and preprocessing
This section mainly introduces the source and preprocessing of fabric image.

Fabric image acquisition
The fabric pilling images used in this study mostly come from professional research institutions in the textile field, mainly including Shanghai wool and linen Research Institute, Tianjin Knitting Technology Research Institute, Suzhou Silk Research Institute and China Textile Research Institute. The fabric pilling images provided by these professional fabric research institutions are provided in the form of paper photos, and the pilling grades have been divided.
And these pilling fabrics are mainly divided into two categories. One is worsted fabric, which is obtained by circular trajectory method based on Chinese GB/T 4802.1-2008 standard. In this study, it is called fine fabric.
The steps of circular track pilling method are as follows: firstly, cut a circular sample with a diameter of 113 mm from the sample; Then foam plastic gaskets, cutting samples and abrasives were installed on the test chuck and grinding table respectively. Finally, according to the fabric type and the standard GB/T 4802.1-2008, the test parameters are selected for the test, and the pilling samples are obtained.
The other kind is coarse combed wool fabric, whose pilling samples are obtained by pilling box method based on Chinese GB/T 4802.3-2008 standard. In this study, it is called rough fabric.
The pilling steps of pilling box method are as follows: firstly, cut a square sample with a size of 125 mm × 125 mm from the sample; Then put the sample on the polyurethane sample carrying tube and fix it with PVC tape; Finally, put the sample loading tube into the box, firmly close the box cover, set the counter to the required rotation times according to GB/T 4802.1-2008 standard, start the pilling box, complete the pilling operation, and obtain the pilling sample.

Fabric image preprocessing
In order to obtain the digital fabric pilling image, this study uses a DCP-7010 laser multi function machine to scan the photos. The size of the scanned image is 982 1374 × pixels.
Before extracting fabric pilling parameters, the background without fabric in the scanned image should be removed first.
The circular worsted fabric pilling image samples obtained by the circular trajectory method, which are called fine images in this study, are shown in Figure 5(a). Circle detection method based on Hough transform was used to detect the fabric area. First, the image shown in Figure 5(a) was segmented into binary image (as shown in Figure 5(b)) used Otsu method. Second, in order to remove small white block noise and effectively preserve the fabric area edge, the binary image shown in Figure 5(b) was filtered through adaptive median filter that the maximum size is 7 7 × pixels. Third, Sobel operators were applied to the filtered image to get the edge of fabric area. Fourth, the Hough transform was used to the edge image got from step three to detect center ( , ) x y 0 0 and radius r of the circle formed by the edge of fabric area. Fifth, the four vertex coordinates (i.e. ( , ) min min min max max min max max x y ) of maximum inscribed square of the circle can be calculated using equation (14). Final, the original fabric image shown in Figure 5(a) was cropped based on the four vertex coordinates, and the result image was shown in Figure 5(c).
The cropped image size is about 500 by 500 pixels.
The rough wool fabric sample is square, which can be realized by scanning the image pixel values from left to right and from top to bottom. Because the background without fabric is close to white and the fabric is darker than the background, the coordinates of the four corners of the positioning square can be suddenly changed by the pixel value in the scanning, so as to realize the clipping. The size of the cropped image is about 400 by 400 pixels to 500 by 500 pixels, as shown in the image in Figure 7(b).

Image noise removal
This section mainly introduces the removal process of various noises in the fabric pilling image.

Fabric roughness judgment and non texture noise removal
In Figure 3(a), the periodic background textures generate similar frequency information, so each wavelet decomposing level energy calculated by equation (15) Where M N × and C i j l ( , ) are the size and wavelet coefficient values of reconstructed image at l ( l = 1 2 6 , ,..., ) scale respectively.
Experiments show that it is appropriate to decompose the fabric pilling image into six scales. The reconstructed image of the scale 1 is mainly composed of highest frequency information in the original image. Approximate sub-image at scale 6 consists of the fabric surface inequalities and the background illuminative variance. And the other detail sub-images mainly comprise textures and pills information (see Figure 6). Figure 7 shows the variation law of the scale energy of fine and rough background texture fabric respectively. We can judge whether the fabric is rough or fine according to the change law of wavelet energy.
From Figure 7, we can see that the maximum energy of fine and rough background fabric images present at scale 2 and scale 4 respectively. If the two scales with maximum energy are the scale 1 and scale 2 or scale 2 and scale 3 then the fabric is regarded as fine fabric, otherwise the fabric is regarded as rough fabric.
After judging whether it is rough fabric or fine fabric, only the detail sub-images at scale 2 to scale 6 of wavelet multi-resolution decomposition are reconstructed (the reconstructed image shown in Figure 7), so as to remove high-frequency noise such as fabric fluff and low-frequency noise such as uneven illumination. The size of these noises is obviously different from that of the fabric pills, which can be effectively removed by the above wavelet method.

Removal of fabric texture based on Gabor filter
Based on Gabor filter, fabric texture can be removed in two ways: one method is to smooth fabric texture with even symmetry two-dimensional Gabor filter, so fabric background texture brightness is more similar, and then the color-based segmentation method can be used to remove the texture (Called smoothing method). Another method, we can detect the fabric texture edges with odd symmetry two-dimensional Gabor filter. The fabric texture edges are detected, then in the original grayscale fabric image containing fuzz and pillars, the pixel values at texture edge's coordinates are set to zero, to achieve the removal of the texture edges (Called sharpening method).
Because the fine fabric's warp and weft yarns are fine, the brightness difference between yarn junction and yarn surface is small. In other words, compared with coarse fabric the fine fabric texture edges are not so clear and are not so easy to be detected correctly, so smoothing method is used. In equation (1), the parameters δ u and δ v are specified as 2, ω is preferably 0.76 and θ is sequentially set to 0°, 45°, 90°, and 135°. The purpose of the application of 0°, 45°, 90°, and 135° even Gabor filter in turn is to smooth the corresponding direction texture. For rough fabric, the yarn is coarse, and the brightness difference is more obvious between yarn surface and yarn junction, it is difficult to get uniform brightness through smoothing method, so sharpening method is adopted. In equation (2), the values of the parameters δ u , δ v , and θ are same as the fine fabrics, but the ω value is 0.88. Figure 8 presents the images got from main steps of Gabor filtering process.
In Figure 8(a1) and (a2) are the original pilled image of fine and rough fabrics, then (a1) and (a2) are decomposed into 6 levels by Haar wavelet, and then detail subimages at scale 2 to scale 6 are reconstructed respectively,   shown in Figure 8(e1) was filtered by even Gabor filter with the angle θ setting of 145°, and the resulting image was shown in Figure 8(f1). The binary image shown in Figure 8(g1) was got by using Otsu algorithm on image shown in Figure 8(f1). The odd Gabor filters with the angle θ setting of 0°, 45°, 90°, and 135° are used to image shown in Figure 8(b2) respectively, and the filtered images are shown in Figure 8(c2)-(f2) in turn. And then images shown in Figure 8(c2)-(f2) are sequentially subtracted from image shown in Figure 8(b2), and the resulting image is shown in Figure 8(g2). The binary image shown in Figure 8(h2) was got by using Otsu algorithm on image pixels with nonzero values shown in Figure 8(g2).

Pilling features extraction
In order to be consistent with the evaluation results of the standard sample comparison method used in manual detection, most researchers take pill number, pill density, parameters related pill size and shape as the parameters of fabric pilling grade evaluation. Therefore, this study attempts to use pill number, pill density, the maximum area of pills and the standard deviation of pill areas as candidate parameters.
In the binary segmentation image of fabric pilling shown in Figure 8, white represents fabric pills and black represents fabric background. Suppose the area of each connected region is p i pixels, then the pill number corresponds to the number of connected areas, which is recorded as N. The total area of these pills is marked as S pixels, then, S = p 1 +p 2 + . . . p N , and the pill density D is D = S/A, where A is the total area of pilling image. The maximum area of these pills is recorded as P max .
The area standard deviation of pills reflect the dispersion of pill size. The area standard deviation is recorded as σ p , and the calculation formula is shown in equation (16): Where, p i is the area of the ith pill, N is the total number of pills, and p S N o = / is the average area of fabric pills. Taking the worsted fabric (the image shown in Figure  8(a1) belongs to worsted fabric) as an example to analyze these parameters. As shown in Figure 9, the corresponding characteristic parameters are extracted from the five level segmented binary images of the fabric pilling standard sample provided by Suzhou Silk Research Institute, and their values are shown in Table 1.
Then, Pearson coefficient is used to analyze the correlation between the selected four characteristic parameters and the fabric pilling grade. The results are shown in Figure 10.
From the correlation coefficient, it can be concluded that there is a negative correlation between the selected four characteristic parameters and the pilling grade. Among them, compared with the other three characteristic parameters, the correlation coefficient of the maximum area of pills is smaller, which is because in the actual pilling experiment, with the increase of pilling friction times,  small fabric pills will be wound into larger pills, but when the friction reaches a certain degree, the continuous increase of friction times will lead to the decomposition and falling off of large pills, Therefore, even fabrics with secondary pilling grade may have larger pilling area than those with primary pilling grade. After the experiments and theoretical analysis of the above-mentioned pilling parameters, in order to consider the accuracy of fabric pilling grade evaluation, this study selects three characteristic parameters: the standard deviation of pill areas, pill density and pill number as the parameter index to judge the fabric pilling grade.

Pilling grade evaluation and discussion
The evaluation method of fabric pilling grade used in this study is to extract the relevant parameters of fabric pilling standard samples at all levels for standby, then extract the corresponding pilling parameters of the fabric to be evaluated, and compare them with the pilling parameters of the standard samples to determine the pilling grade of the fabric to be tested. The parameters extracted from the five level standard sample of worsted fabric used in this study have been shown in Table 1 Pilling grade evaluation After determining these three parameters shown in Table 1 as the characteristic parameters of fabric pilling grade evaluation, the relationship between the characteristic parameter value and fabric pilling grade is established. This study adopts the method of finding the boundary value, which is the most commonly used but simple and effective. In other words, the fabric pilling grade can be determined according to the grade range in which the pilling characteristic parameters fall. The implementation process is as follows: the boundary value between the two fabric pilling grades is set to X, and the interpolation method can be used to figure out X. Take the calculation of the grade 1 and grade 2 rating threshold X as an example, and the specific formula is as follows: . .
When judging the fabric pilling grade, first obtain standard deviation of pill areas, pill density and pill number through the method introduced before, and then judge which range the value falls into in Table 2, so as to judge the anti-pilling   performance of the fabric as several grades, which completes the automatic grade evaluation of fabric pilling.

Discussion
For comparative analysis, 10 groups of 50 fabric pilling images (Grade 1-5 fabric pilling images) as shown in Table 3 are rated by the fabric pilling rating system composed of three denoising methods mentioned in this study, and each grade corresponds to 10 images. Among them, 12 of the 50 images have obvious uneven illumination. It can be seen from Table 4 that the accuracy of the fabric pilling evaluation based on the combination of wavelet analysis and Gabor filtering proposed in this study is 96%, which is higher than the first two. This is because wavelet analysis can not always effectively separate fabric texture and fabric pilling, and Gabor filtering does not consider fabric non-texture noise.
However, there are still two images misjudged. The reason for the misjudgment is that the fabric contains small white areas (as shown in Figure 11(a)), and small bulges are raised due to the deformation of the fabric structure during use. The characteristics of small white areas and fabric bulges are similar to fabric pilling, which are misjudged as fabric pilling (as shown in Figure 11(b)), resulting in wrong evaluation.

Conclusion
This study presented an effective way of removing noise from pilled fabric image based on wavelet transform and Gabor filter. The pilled fabric image is decomposed into different resolution sub images by wavelet transform, and the energy of each layer of wavelet multi-resolution decomposition is calculated. By the variation law of the energy, we can judge whether the fabric is rough or fine. And the reconstructed detail image f at scales 2-6 is as the image to be processed. Through this step, the noise caused by surface unevenness, background illuminative variation (low frequency noise) and fine nap (high frequency noise) is removed. If the fabric is judged to be fine, the even symmetry Gabor filter is used in turn in four directions to smooth the fabric texture. Otherwise, the odd symmetry Gabor filter is selected to filter the image f in four directions respectively to detect the texture edges. And then subtract the four direction textures from f in turn. Through odd Gabor filter the fabric texture edges can be removed effectively, and the gray scales of the remaining textures are more uniform. Then the textures as the same kind of noise are easier to be removed by using Otsu algorithm. And then we got the binary image. According to the binary image, pill density, pill number and standard deviation of pill areas can be extracted for evaluation of fabric pilling rating. The experimental results show that the fabric pilling evaluation process proposed in this study is robust.

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.