Abstract
The fabric of colored spun yarn has ever-changing appearances and styles with different fancy yarns. The fabric image is commonly designed by the designer using the software, which needs complex user interactions and difficult image segmentation. In this paper, a modified color transfer method was proposed to generate the fabric appearance of colored spun yarn. Given the color card as the target image, the style fabric image was matched as the reference image based on the dominant luminance. After transferring the two images to lαβ color space, Wavelet transform and luminance sampling were utilized to filter the redundant high-frequency information and select the representative pixels, respectively. Then, the chromatic channels were transferred based on the best matched luminance and the neighborhood relation. Finally, the image after color transfer was reconstructed by wavelet reconstruction. The proposed reference image matching maintained the result to be the ground truth. For the samples selected, the combined methods based on wavelet transform and luminance sampling improved the efficiency and performance of the proposed scheme. Experiments were conducted on different fabrics with different colors and styles. Experiments demonstrated the validity and superiority of the proposed method, which can provide referential assistance for the designer and save considerable amounts of labor.
Colored spun yarn 1 is manufactured by dyeing the fiber into the colored fiber, and thoroughly mixing the fibers of two or more different colors to form a yarn with a unique color mixing effect. The fabrics with different styles, which we called the style fabrics in this paper, can be obtained by different colored spun yarns, such as wood grain style, slub style, nebula style and star shining style. The style fabric has a three-dimensional effect, the color of which is subtle, natural and layered. The color appearance 2 of style fabric is ever-changing with different yarn interactions in the knitting process. In the factory, color cards exhibit the yarn appearances which are mixed with different fibers to the designer and the consumer. Figure 1 exhibits the fabrics of different color cards and style fabrics. At present, the fabric is designed using the basic software by complex user interactions and difficult image segmentation until the demands are met. The result may be plausible but may not be the ground truth, and the design process is time-consuming and requires professional skills. With the aggravated homogenization of the commodity, consumers have increasingly emphasized the aesthetic appearance of textiles and garments, such as color perception 3 and form style. The traditional design method cannot cope with the flexible production of small batches and multiple varieties. The image color transfer method can transfer colors among similar images, generating a series of different image perceptions. Adopting this approach, the fabric produced from one appearance style can be offered in numerous colors to help the designer obtain the image perception quickly and efficiently, saving considerable amounts of labor and material resources.

Fabrics of different color cards and style fabrics.
At present, different example-based color transfer methods have been applied to natural images. There are mainly two kinds of methods: hand-crafted methods and deep-learning-based methods. For hand-crafted methods, Reinhard et al. 4 firstly developed the color transfer formula for each color component based on the uncorrelation of channels in lαβ color space to achieve the example-based colorization. Welsh et al. 5 modified the above method by scanning pixel by pixel between the grayscale image and the color image to find the best matched luminance using neighborhood statistics. Han et al. 6 firstly transferred colors based on the best matched luminance in wavelet domain, then the image was reconstructed to realize color transfer. Pitie and Kokaram 7 presented a transformation of the linear Monge-Kantorovitch linear color mapping for example-based color transfer. Yoo et al. 8 proposed segmenting color regions of the input images based on estimated dominant colors to suppress the color region mixing and transfer colors for the local regions. Liu et al. 9 proposed an ellipsoid color mixture map for the users to selectively re-render the colors for color transfer. Arbelot et al. 10 developed a unified framework that uses the textural content of the images to guide color transfer and colorization. Song et al. 11 combined both color and texture features based on feature detection and matching for image appearance transfer. Such semi-automatic colorization methods can obtain satisfactory results with low artistic skill requirements. The above methods did not report the selection of the reference image, which is the key step determining the color transfer result. Recently, different deep-learning-based methods were proposed to determine the relationship between the luminance and chrominance channels. The representative methods are complex illumination image appearance transfer using convolutional neural networks (CNN), 12 sketch colorization based on generative adversarial networks, 13 grayscale image colorization using CNN14 and dense encoding pyramid network. 15 Such end-to-end colorization methods can learn how to select, propagate and predict colors, but require large-scale training data which is difficult to collect. The small size of training samples will affect the color transfer results. The color transfer method for the fabric of colored spun yarn has not been reported yet. Unlike the natural images, the fabric image of colored spun yarn has no background and there are lots of same or similar colors. The color transfer result of the natural image highly depends on the reference image, and plausible results may vary from the ground truth. 16 However, the results of the fabric of colored spun yarn must be the ground truth for industrial applications. Due to lots of gradient colors within the species diversity, it is challenging to select the representative samples for color transfer and the above methods need to be expanded.
In this paper, a modified color transfer method was proposed for the fabric of colored spun yarn. The main contributions of this paper are as follows:
1. This paper proposed generating the fabric appearance of colored spun yarn to provide preferences for the designer. 2. Wavelet transform and luminance sampling were utilized to filter the high-frequency information and the redundant information, respectively. The combined methods improved the efficiency of color transfer. 3. The selection of the reference image was presented to avoid obtaining unrealistic results.
Methods
The proposed framework is outlined in Figure 2, which describes the workflow of color transfer of the fabric of colored spun yarn. Initially, the color card and the style fabric were transferred to lαβ color space. Then, wavelet transform was utilized to filter the redundant high-frequency information. Subsequently, the close luminance values were merged into the same one to select the representative samples. After image matching, color transfer was implemented based on the l channel. When the luminance was matched, the corresponding α and β were directly exchanged. Finally, the image was reconstructed by wavelet reconstitution and transferred to red, green and blue (RGB) color space, obtaining the result of color transfer.

Workflow of color transfer of the fabric of colored spun yarn.
Image capture and pre-processing
Different fabrics of colored spun yarn were collected from the factory for the experiments of image color transfer. To avoid the influence of capture conditions, DigiEye system 17 was utilized for image capture. As shown in Figure 3(a), this system is equipped with a Nikon D7000 camera, special pick-up head and standard illumination D65, 18 which has the advantages of small color difference and stable capture condition. After capture, the image was cropped in the size of 1000 pixels × 1000 pixels to reduce the parts of edge burr and platen, as shown in Figure 3(b). The red box shows the structure of the fabric.

(a) Image capture system; (b) captured image after cropping.
Among different color spaces, lαβ color space
19
is a perception-based color space, which was developed to minimize the correlation between three coordinate axes of the color space. l is the achromatic luminance channel, α is the yellow-blue channel and β is the red-green channel. Different operations can be applied in different channels and undesirable cross-channel artifacts will not occur. lαβ color space is a transformation of long, medium and short (LMS) cone space.
20
When transferring color space from RGB to lαβ, the image is firstly transferred to LMS cone space. Then the generated spatial deformation is eliminated by natural logarithm. Finally, LMS is transferred to lαβ space by a linear transformation. Given the coordinate (m, n) of the image pixel, the channels CR(m, n), CG(m, n) and CB(m, n) in RGB space and C
l
(m, n), C
α
(m, n) and C
β
(m, n) in lαβ space can be transferred reciprocally by the following equations
Changes in one channel will not have an impact on the other two channels, achieving the ideal color transfer results without distortion. Thus, lαβ color space was selected to perform color transfer in this paper. Both the reference image and target image were transferred from RGB color space to lαβ color space. After color transfer, the result was transferred to the RGB color space. To display the image in l channel, the l channel of the image in Figure 3(b) was transferred and represented in standard 8-bit format, as shown in Figure 4(a).
Wavelet transform
In the fabric of colored spun yarn, there are lots of gradient colors within the species diversity. To avoid destroying the fabric texture and reduce the computing time, high-frequency components of the image were firstly filtered by wavelet transform. Two-dimensional discrete wavelet transform 21 is commonly performed for image decomposition in multiple scales, obtaining a series of sub-images. Each decomposition yields an approximation component and three detail components that represent the horizontal, vertical and diagonal details. For further decomposition, the approximation component is divided into four subareas. Figure 4 illustrates the process of the wavelet decomposition of the image in Figure 3. Visually, the approximate component reflects the texture characteristics of the original image. Moreover, it has a small image size and is smoother than the original image. The detail components only retain the boundary characteristics of the original image. Thus, the color transfer is performed on the approximation component obtained by wavelet transform. The image size was processed to 500 pixels × 500 pixels. After color transfer, the image was restructured by wavelet reconstruction to realize image color transfer. The pixels in the low-frequency component were used to colorize the neighborhoods in the reconstruction process.

Process of wavelet decomposition. f1 is the first decomposition function. A1, H1, V1 and D1 represent the horizontal detail component, vertical detail component and diagonal detail component after the first decomposition, respectively.
The commonly used wavelet basic functions include Haar, Coiflet and Symlet, among others.
22
Through the trial test, the wavelet basic function has no substantial impact on the result of color transfer. In this paper, one-level wavelet transform using Haar basic function
23
was used to filter the redundant high-frequency information and to avoid omitting the details. Taking the grayscale image of Figure 3(b) as the example, Figure 5 illustrates the one-level Haar wavelet transform decomposition. The image is divided into 2 × 2 subareas as shown in Figure 5. Assuming that each 2 × 2 subarea in the original image is represented by A0(i, j), where (i, j) is the coordinate of the subarea pixel, the approximation component A1, the horizontal detail component H1, vertical detail component V1 and diagonal detail component D1 after the first decomposition can be represented by

One-level Haar wavelet transform decomposition. A1, H1, V1 and D1 represent the horizontal detail component, vertical detail component and diagonal detail component after the first decomposition, respectively.
Luminance sampling
The image size affects the selection of sampling points and the speed of color transfer. Without affecting the color transfer performance, sampling the representative pixels for color transfer can reduce the redundant information and improve the color transfer speed. In this paper, the color transfer is based on the luminance matching in l channel. The luminance values after wavelet decomposition are similar but with subtle differences in the order of magnitude. Taking the image in Figure 3(b) as an example, Figure 6(a) shows the luminance statistics before luminance sampling. It can be seen that the luminance values are different from each other, and the maximal equal luminance value is 5. It is time-consuming to perform luminance matching for each luminance. The luminance sampling can be realized by merging the close values of l channel into one set, represented by one value. The order of magnitude was set to different orders to merge the close values, such as 0.1, 0.01, 0.001, and so on. A different order of magnitude can obtain different quantized values. In this paper, the order of magnitude was set to 0.01, and the optimization experiments will be given in the next section. As shown in Figure 6(b), a large number of close luminance values were merged into one value. In the following process, the color transfer just performs once for each equal luminance value. The quantized values are only adopted for the matching process, not for the color transfer.

Histogram of Figure 4(a): (a) before luminance sampling; (b) after luminance sampling.
Color transfer
The result of color transfer highly depends on the reference image and plausible results may vary from the ground truth. In previous studies,5,6 luminance remapping 24 was used to linearly shift and scale the luminance histograms of the reference image and the target image. Unlike the natural image, the result of color transfer for the fabric of colored spun yarn is required to be the ground truth, rather than be plausible. To select the reference image for color transfer, image matching was performed based on the luminance range. Because the proposed method is based on the dominant luminance, the critical percentage which belongs to the dominant luminance was optimized by the results of color transfer. Given critical percentage pi and the known number of luminance values, the number of critical luminance can be calculated and the range of dominant luminance can be obtained, as shown in Figure 6(b). The range difference of dominant luminance between the reference image and the target image is calculated to optimize the percentage. In this paper, pi was set to 3.4% to match the reference image with the least luminance difference, and the optimized results are given in the next section. Figure 7 shows the color card image matched with the style fabric image in Figure 3(b) and the histogram after luminance sampling.

(a) Color card matched with the image in Figure 3(b); (b) histogram after luminance sampling.
After finding the matched image, the luminance matching process is based on the luminance and its neighborhood statistics. The reference image (style fabric) and the target image (color card) are quantized with the same order of magnitude. For each quantized value Ti in the style fabric image, the differences with the quantized vector R of the color card image are calculated. The minimum is regarded as the best matched value Bi, which is defined as
If there is more than one value of Bi corresponding to Ti, different values of Bi will be compared with the four neighborhoods of each Ti by the average Euclidean distance d, as defined in formula (6). The Bi with minimum distance is chosen as the best matched value to increase realism of the color transfer effect. After obtaining the luminance position of Bi in the style fabric image and the color card image, the corresponding chromatic values in the color card image are assigned to the chromatic channels of the style fabric image. Then, three channels are restructured by wavelet reconstruction to compose the final colorized image.
Based on the proposed scheme, color transfer was performed between the image in Figure 3(b) and the image in Figure 7(a). From the result shown in Figure 8, the proposed method can generate a new appearance with the color of the color card and the style of the style fabric.

Result of color transfer.
Experiment implementation
To prove the feasibility and effectiveness of the proposed method, 200 fabrics of color cards and 400 style fabrics were captured and processed by the proposed framework to build the image database. For each style fabric, there is a series of images that can be selected as the reference image. The parameters of the adopted fabrics are listed in Table 1. Experiments were conducted in a MATLAB computing environment on a desktop computer with Intel 3.40 GHz processor and 8 GB RAM.
Parameters of the adopted fabrics
Visual inspection and the standard peak signal-to-noise ratio (PSNR) 25 are selected to evaluate and compare the color transfer results of different methods. Like the 5-point hedonic scale, 26 a 5-point similar scale was carried out for visual inspection, as listed in Table 2. Three experts in the factory were invited to perform a visual inspection and the average assigned degree was used to evaluate the results of color transfer. The experts have been utilising visual inspection for a long time and have extensive experience. The visual inspection was performed in the dark room. The images after color transfer were displayed using the DigiEye software and the monitor was adjusted under the standard illuminant D65.
5-point similar scale
The PSNR is an approximation to human perception of reconstruction quality, and a higher PSNR generally indicates that the reconstruction is of higher quality. For an image x in the size of m × n and the color transfer result y, the PSNR (in decibels) is defined as
Results and discussion
Parameter optimization
In this section, the percentage in image matching was optimized to select the reference image for color transfer. Experiments were conducted on each target image using different reference images. The results were evaluated by the expert designers in the factory to select 50 pairs of acceptable results with a scale of more than 4. Then, the average difference of the dominant luminance of the target image and reference image was counted based on different percentages. In this experiment, the percentage was optimized from 1% to 10%. Figure 9 shows the average difference in dominant luminance for different percentages. It can be seen that when the percentage is less than 3.4%, the average difference tends to be stable. In this paper, the percentage of dominant luminance is set to 3.4% to match the reference image. Given the target image, the reference image is selected based on the optimized parameters.

Average difference in dominant luminance for different percentages.
The sampling number, which is dependent on the order of magnitude, affects the transfer performance and the elapsed time. Fifty pairs of color cards and style fabrics were selected for experiments, and the experiments were performed on the same pairs of images with different orders of magnitude. Table 3 gives the average evaluation criteria for different orders of magnitude. Figure 10 exhibits the color transfer results of one pair of samples. As can be seen, the differences among the results for the different orders of magnitude are small, because the color card commonly has a small number of colors. When the order of magnitude is 10−1, the whole image appears to the dominant color, which is darker than the result of 10−2. The PSNR decreases when the order of magnitude is smaller than 10−2, due to the unfiltered image noise. Besides, the computational complexity and elapsed time increase dramatically. In this paper, the order of magnitude was set to 10−2, which has the least elapsed time with the highest PSNR and the highest visual score.
Average evaluation criteria for different orders of magnitude
PSNR: peak signal-to-noise ratio.

Color transfer results with different orders of magnitude.
Results analysis
Based on the practical application in the textile industry, two experiments of color transfer were carried out using the proposed scheme: the experiment between different color cards and one style fabric, and the experiment between one color card and different style fabrics. For visual analysis, Figure 11 presents the representative color transfer results in two situations. Intuitively, the same style fabric can be colorized using different color cards to generate a series of fabrics with the same style, as shown in Figure 11(a). The same color card can also be performed on different style fabrics to create a series of style fabrics with the same color, as shown in Figure 11(b). Moreover, the average PSNR and visual score are up to 34.77 and 4.53, respectively. Experiments show that the color transfer can be successfully completed to form the new fabric appearance and increase the diversity of the fabrics. Moreover, the average elapsed time of each color transfer process is 3.5 s. The results reveal that the proposed method is practicable and effective, which helps the designer save a considerable amount of time when generating different fabric imageries.

Color transfer results in two situations: (a) different color cards for one style fabric; (b) different style fabrics for one color card.
Different experiments were conducted to prove the rationality of the proposed method. Lab color space, two-level wavelet transform and image decomposition using Laplace pyramids were compared with the proposed scheme when the other parameters were the same. For Laplace pyramids, the decomposition level was set to 2 and the color transfer was performed on the two decomposed images. The color transfer results are exhibited in Figure 12. Table 4 lists the evaluation criteria of the different methods. The result of Lab color space is deeper than that of lαβ color space visually and the PSNR is extremely low, because there are correlations among the three channels. Because the result combined two decomposed images, the result of Laplace pyramids is also deeper than that of wavelet transform. The size of the first decomposed image is the same as that of the original image, thus this processing does not realize luminance sampling. There are some noises in the result of two-level wavelet transform, because of excessive decomposition and reconstitution. By contrast, the results indicate that the proposed scheme is reasonable and obtains the best result.

Color transfer results of the different methods.
Evaluation criteria of the different internal methods
PSNR: peak signal-to-noise ratio.
The proposed method is based on the luminance matching. When there is a large luminance difference between the color card and the style fabric, the color transfer will be meaningless. To verify the significance of image matching, the experiment was implemented on the same color card and two style fabrics with different luminance. Figure 13 exhibits the color transfer result of different luminance. L1 and L2 represent luminance 1 and luminance 2, respectively. As can be seen, the colors of result 2 are closer to the color card than that of result 1 when L1 and L2 have the same style and different luminance. The PSNRs of result 1 and result 2 are 27.58 and 29.51, respectively, and the visual scores are 2.67 and 4.33, respectively. The result indicates that image matching can avoid the generation of bad results.

Color transfer results of two different luminances.
Comparison results
To verify the superiority of the proposed method, three previous methods,4–6 which were based on lαβ color space, were compared with the proposed method on different pairs of color cards and style fabrics. The results of the different methods are shown in Figure 14. Table 5 gives the evaluation criteria of different samples using the different methods. From visual inspection and the qualitative baseline PSNR, it can be seen that the proposed method obtained the best results compared with the other three methods for different samples. In particular, the proposed method substantially retains the color of the color card and the texture appearance of the style fabric to generate the most satisfactory result.

Comparison of the different color transfer methods.
Evaluation criteria of the comparison methods
PSNR: peak signal-to-noise ratio.
The method used by Reinhard et al. 4 imposes mean and standard deviation onto the data points. This method can retain the whole color appearance, but the details of the texture are destroyed. The methods used by Welsh et al. 5 and Han et al. 6 misused the colors due to the luminance mapping, resulting in unrealistic fabric appearances, such as the results in the first row and the fourth row. Welsh et al.’s 5 method requires the user to select 200 sample pixels to improve the color transfer results. It is difficult for the user to select the sample pixels when the colors are close to each other. Han et al.’s 6 method randomly selected 100 sample pixels after two-level wavelet transform, which is extremely insufficient for most samples. Furthermore, the result is unpredictable and depends on the selected sample pixels. As a result in the third row and the fifth column shows, some noises appeared because of the randomly selected sample pixels. In contrast, the proposed frame achieves the best results by automatically merging the same or similar illumination to sample the representative illuminations, as shown in the last column. On the other hand, the previous methods did not describe how to select the reference image. The results are unsatisfactory when there is a large luminance difference between the target image and the reference image. Table 5 lists the average elapsed time of the different methods. For comparison, the elapsed time of Welsh et al.’s 5 method did not involve the time of sample selection by the user. The methods of Reinhard et al. 4 and Han et al. 6 are fast but the color transfer results are not acceptable for the fabric of colored spun yarn. The proposed method is effective and fast to obtain satisfactory results.
Conclusion
In this paper, an effective and fast appearance change method was proposed for the fabric of colored spun yarn based on wavelet transform and luminance matching. Wavelet transform and luminance merging were combined to choose the representative sample pixels automatically. The images were matched based on the luminance distribution to avoid the generation of bad results. Results reveal that the proposed method can transfer the fabric appearance among different color cards and style fabrics fast and efficiently, and shows more superiority than other color transfer methods. This system can provide references for the designer and help the factory save considerable amounts of labor when designing the fabric image perception.
However, this method generated unsatisfactory results when there are no matched style fabrics with the color card. A future effort will be made to develop a better image matching method. An optimized method will be proposed for a more robust and effective color transfer method for the fabric of colored spun yarn.
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 study received support from Postgraduate Research & Practice Innovation Program of Jiangsu Province (No. KYCX18_1819); the National Natural Science Foundation of China (No. 61976105 and No. 61802152); the Natural Science Foundation of Jiangsu Province (No. BK20180602); the China Postdoctoral Science Foundation Funded Project (No. 2018M640453); the Jiangsu Province Postdoctoral Science Foundation (No. 2018K037B); the Fundamental Research Funds for the Central Universities (No. JUSRP11805).
