Study on the measurement and evaluation of cotton color using image analysis

Color is an important property to grade cotton. However, precise measurement and comprehensive evaluation of cotton color have not yet been carried out because of instrumental defect, colorful trash and less indicators. This work proposed an accurate method of color measurement and cotton grading. In order to remove the influence of trash on result, a novel trash detection method based on color features of defined three categories of trash and cotton was introduced. In order to improve the accuracy of trash detection, a method based on two-step threshold algorithm is proposed. The original images stored in sRGB format was transformed into binary images according to fixed thresholds and ‘Otsu’ algorithm. Compared to previous trash detection methods, the two-steps detection method was more suitable for cottons with different trash-content. Indicators expressed in Hunter color space were determined by the conversion referring to optical theory and light source. The feasibility of the proposed method was confirmed by comparing the present result with that obtained from standard instruments system. Furthermore, the grading indicators of cotton discussed in this paper suggested that the variation and distribution within a cotton sample should be considered in cotton grading, including a parameter redness or blueness (a). Our work would provide a much better approach to measure and evaluate color of cotton.


Introduction
In recent years, the increasing demand for fast and accurate measurement in textile industry has caused much concern. In the textile market, cotton fiber accounts for more than 25% in the world during the last decade [1]. Color, as one of the most important properties of cotton, plays an important role in cotton grading [2]. There have been a number of researches focusing on the measurement of cotton color. For example, Cui et al [3] adopted the method of image analysis to measure the cotton color, including overall and intra-sample color. However, the influence of trash on color was ignored. Trash has a significant effect on the color of cotton, including the cotton color distribution. Besides, its scan resolution was not enough high to extract the detail color of each fiber. Vik et al [4,5] used the method of Non-contact to measure the cotton color and evaluate the color variation within cotton samples. However, the cotton used in the work of Vik et al was treated without trash. Therefore, this method was suited for the cotton without trash. Thomasson et al [6] reported a device to measure cotton color without the influence of trash. However, the trash detection algorithm is not sensitive to the detection of two kinds of trash. Currently, color can be measured by cotton classer or instrument [4]. Many scholars pay more attention to advanced instrument, ignoring the advantages of original subjective measurement. It is more accurate because human eyes are the more sensitive 'instrument' if compared with the apparatus. However, it cannot meet the necessary of factory due to its subjectivity and time-consuming [7]. So, instrumental measurement has been developed. High Volume Instrument (HVI) is a widely used instrument for quality inspection of cotton fiber, including length/strength module, color and trash module, Micronaire module and nep module [8]. Compared with traditional subjective measurement, it is generally fast and Any further distribution of this work must maintain attribution to the author(s) and the title of the work, journal citation and DOI. consistent in testing results. However, high cost, huge floor area, and the different testing results between classer and machine also limit their practical application [9,10]. Charge-coupled Device (CCD) [11] is a digital device. CCD is widely used in digital photography and astronomy, especially indigital cameras and scanners [12]. To date, CCD camera has received a large amount of attention as image acquisition technique for precise color measurement. It can capture the images containing the color information of each pixel [13]. Therefore, the color variation and distribution can be obtained easily, which directly affects cotton price. Current colorimeters, including HVI, only provide average color values within a certain area [4]. Another advantage is that the detection of trash can be carried out based on the trash color information provided by CCD. One reason for classer-machine testing difference is that eyes eliminate the trash influence on color while almost all colorimeters do not [14]. In addition to CCD, light is also important for image acquisition. The HVI is not sensitive enough as the light source does not cover the entire visible spectrum [4]. Compared to the light source of HVI, Light-emitting diodes (LED) lamps become popular due to their small size, long lifetime and high efficiency [15].
In addition to the study of testing machine, the grading parameters have also been paid attention to. Reflectance (R d ) and yellowness (+b) are used to grade cotton, which belong to the 3-dimensional Hunter color space. The grading indexes come from the investigation of United States Department of Agriculture (USDA) in 1940s [16]. The third parameter of 3D Hunter color space named a is always neglected, because it is a constant for the US upland cotton. The 2D grading method is used in the whole world [17]. However, previous studies have failed to consider the color difference between Chinese and American cotton. Therefore, it is more reasonable to grade Chinese cotton using the 3D Hunter color space. Some researchers also studied to use more common color space, such as CIE Lab, to represent the cotton color [18,19].
In our work, an experimental device was used to measure cotton color, which mainly included LED lamps, CCD camera, sample box, optical glass, press handle and plate. The scanned images of samples were obtained by the device. According to the binary image processing, a method was proposed to detect trash based on color features, which extracted from the three kinds of trash and clean cotton images. The method was carried out by combing the CCD technology and two-step threshold algorithm to process the original images into clean cotton blocks and trash blocks. Therefore, the influence of trash would not affect the color measurement any more. Finally, this paper established a comprehensive evaluation index system, including current grading indicators and extra parameters, namely parameter a, color variation and distribution. By using the indicators obtained from our equipment and method, cotton color can be measured more comprehensively.

Materials and methods
2.1. Material 16 kinds of cottons, which varied in producing area and color, were used as experimental samples to develop and validate the novel color measurement system proposed in this study. All the prepared samples were placed in a climatic room which maintained a constant temperature 20±2°C and humility 65±4% to achieve a balanced moisture. The color parameters of experimental samples were determined using a colorimeter (HVI-1000, Ulster, Switzerland) in accordance with ASTM D 5867, and the detailed results were summarized in table 1. Figure 1 shows the experimental device developed in our work, which mainly includes a row of LED lamps, CCD camera (Sony, ICX282AQ), RGB color senses (Keyence, CZ-V20,), plate and so on. Before the measurement, 10 g cotton assembly was evenly placed in the sample box to form a uniform and randomly arranged structure. The box was square shape in cross section, without top and bottom surface to form a tube, whose internal wall was painted black to avoid the influence of external light. The internal and external edge lengths of the square were separately 98 mm and 102 mm, indicating a 4 mm thickness. A black plate hold right above the box began to drop down. A 20 pounds pressure was applied on the cotton assembly. The bottom surface of the black plate was made of spongy-rubber cushion, as the soft contacting interface was beneficial to generate a uniform pressure on cotton assembly and thus enhance measurement accuracy and decrease deviation throughout the surface. Afterward, a row LED lamps at the bottom were arranged with a distance of 30 mm under the cotton assembly and illuminate the sample with an angle of 45°in order to meet ASTM D 1729. The images taken by this device were stored in sRGB format with a resolution of 1000 dpi, and finally saved as bmp format with an area of 98×98 mm.

Methodology
The proposed algorithm mainly included three stages: image acquiring, image processing and results displaying. As shown in figure 2, the first stage was further composed of image size, resolution and image format setting before the image acquiring. The scanned images of cotton assembly were obtained by the experimental device described in previous paragraph. Next step was the image processing which was the second stage and was of great importance to obtain the color information in this algorithm. It could be divided into step1, 2 and 3 as shown in figure 2. During the step 1, trash detection was carried out to remove the influence of trash on cotton color measurement. The detection of trash has been studied by many researchers to obtain the trash content [20]. For example, Thomasson [6] developed a device to remove the influence of trash on the cotton color measurement, which mainly consisted of proper design with lighting system, sample window, filter wheel assembly, spectral filters, camera and so on. However, the trash detection algorithm is not very sensitive to the detection of two kinds of trash, which is the trash particle buried in cotton and light color trash such as inner portions of the cotton boll. In order to increase detection accuracy, all the trash existing in cotton was classified into three categories based on their respective perceptual color in this paper. All pixels of clean cotton and three kinds of trash were collected, and then gray color model based on the distribution of these pixels in gray color space were defined. Impulse noise generated during scanning process was removed by a median filtering method in this algorithm, and then grayscale images were obtained from the color images. After that, a two-step threshold method (fixed and 'Otsu' threshold) was used to transform the gray images to binary images in order to provide a better condition for trash detection. Finally, the binary edge image was processed using morphologic operator to remove noisy objects, as the previous work suggests getting more accuracy trash detection [21].
The category of each pixel in the last binary image was represented by Class Index: Where I was 0 or 1, representing the pixels of clean cotton or the pixels of trash.
After the detection of trash in step 1, color information contained clean cotton was extracted in step 2.
In step 3, Hunter color parameters (Hunter R d ab) were obtained based on the following transformation. RGB values were extracted firstly. Hunter R d ab was obtained through the conversion of RGB to CIE XYZ as shown in equations (2)-(12) [22]. This logical sequence was conducted by Matlab 2012a. Step a. Geting the normalized RGB values.
Step b. Geting the CIE XYZ values. The RGB space was converted into the CIE XYZ space through following matrix. Step c. Determination of color parameters in Hunter color space. Finally, color variables R , d + b were calculated by the equations from equations (9)- (12). For all samples, 4 additional color parameters were calculated: a index and variation of R , d a, + b, which were calculated according to following formulas. 21 20 1 20 12 y In this step, variable f y was determined by Y, values of K a and K b were 175 and 70 respectively.

Effect of trash detection
In HVI trash detection module, pixels with reflectance values below a prescribed threshold are regarded as trash [23]. The disadvantage of the prescribed threshold is that the trash detection results is highly depend on lamp since it will change over time.
In figure 3, cylinders represent the distribution of pixels in grayscale color space. The 1, 2, 3 on x-coordinate separately represented the distribution of pixels in grayscale of defined three kinds of trash and 4 represents clean cotton. The color of the first category was dark brown, including seed, seed coat fragment, bark, and bearded motes. The second was light yellow, including the inside layer of cotton bolls, seed skin, insect excrement, etc. The third was whitish-gray, which is caused by the internal trash covered by cotton fiber on the surface. No overlap in grayscale values between the first, third kind of trash and clean cotton was found, while an overlap 0.75-0.85 between the second kind of trash and clean cotton was detected. Therefore, it is not possible to detect all trash from cotton by a fixed threshold.
According to above results, the method of fixed and Otsu's threshold was combined to detect all kinds of trash. The binarization was performed in two steps, in which the fixed threshold (0.75 and 0.85) was firstly adopted to process images. The purpose is to detect the first, third and the second kind of trash with the gray under 0.75. Second, the 'Otsu' method was employed to process the images obtained in previous step, with the aim to detect the trash of overlapping gray value as the 'Otsu' fulfills the demands of adaptability [24]. Therefore, compared with the trash detection method of HVI, the proposed method can detect trash more accurately. This trash detection effects were shown in figure 4(b), with the final images to be classified into clean cotton and trash. In the binary image, the pixels in white and black regions represented the pixels of cotton and trash, respectively.
For clarifying the influence of trash on color measurement, the change in color values of all samples before and after the trash elimination was investigated, and it was defined as: Where x and x 0 were separately the color parameters (R d , a and +b) of the cotton samples without and with trash. The detailed results of 16 samples was summarized in figure 5(a). The R d values increased after the removal of trash, demonstrating that cotton samples appeared darker in trash region. Among all the tested 16 samples, the change in +b was less obvious than a except three samples as shown in figure 5. This indicated that trash affected more significantly on parameter a to the cotton chroma. Positive and negative changes in parameter +b were detected, with most samples become less yellow after trash removing treatment. While, for some samples, trash seems to exerted almost no influence on color parameters because this samples seems yellow originally, as shown in figure 5(a). The change in parameters (R d , a and +b) was varied from −2% to 5%, however, figure 5(b) suggests that when the point (R d , +b) is graded near the boundary between grades on cotton color diagram, the influence of trash cannot be ignored. Figure 5(b) shows that after the removal of trash, the grading level of two samples becomes higher. The grading level of sample 2 # and sample 4 # changes from 23 to 14, from 13 to 12, respectively.

Comparison of color parameters obtained from the proposed device and HVI system
Although trash is of great importance in cotton color measurement, it is not removed from samples in the present methods such as HVI. 16 kinds of cotton samples were tested to clarify the effect exerted by trash on the result in this paper. Color parameters values (R d and +b) measured by HVI were plotted against those by experimental device. As shown in figure 6, correlation coefficients (r) were high to 0.96, 0.95 for R d with or without trash, and 0.94, 0.92 for +b with or without trash. The results indicated a higher correlation relationship without the removal of trash. Small differences were seen between the values of parameters (R d and +b) obtained from the experimental device and HVI, which demonstrated that the method proposed in this paper was reliable.

Conversion equations for lamp
Above investigation confirmed that color parameters R d and +b measured by the experimental device were strongly correlated with those obtained from HVI, but different values of parameters R d and +b were seen in two systems. Therefore, the result of the experimental device cannot be directly used as final measurement, and it could be applied in cotton color measurement with correction equations. Initially, a systematic differences  existed between the datas tested by the two devices, which may result from lamp because it would affect the color of objects [9]. The same color appears different when illumined by different lamps. The lamps used in HVI and the experimental device are xenon flash lamp and LED respectively, which have different spectra distribution property and color temperature.
Where variable R dc , + b c were corrected R d , + b, while values of R d , + b were determined by the experimental device, and C , were −96.66, 2.07, −4.98 and 1.41 respectively. After the parameters R d ab was corrected with the linear transformation, the final cotton color result was obtained. The above method in this paper is named LDL. LDL separately means LED lamp(L), digital CCD camera(D) and correction equations for light source(L). Figure 7 shows the comparison of color parameters between the new method and HVI. As can be seen in this figure, there were totally 20 samples, 16 samples mentioned in the previous investigation and 4 new cotton samples (numbered 17, 18, 19 and 20) were tested using the LDL method. From figure 7, it shows that changes in R d and + b obtained from the LDL method and HVI were consistent, which suggesting a perfect reliability of the LDL method.

New indicators to grade cotton
The results of 16 samples measured by the LDL method were shown in figure 8. R d values varied between 71.55 and 80.97 among all samples. +b values varied between 9.70 and 13.87. a values varied between −3.60 and −4.07. The current grading system only takes R d and + b into consideration, and the parameter a is neglected. Although the absolute value and range of parameter a were less than R d and + b, it was not a constant values among the tested 16 samples, which was different from the result reported in the previous work [25].
Experiments were performed to study the relative differences in color parameters (R d , a and +b) among two kinds of samples. To quantify the contributions of difference to color, the relative difference was defined as:  Where x represents parameters R d , a and +b, i and j represent sample number.
The purpose was to investigate which color indicator can be used to distinguish the color of cotton. As shown in figure 9, there were 120(C 16 2 ) cases and 6 (C 3 3 ) code names totally. Code name 1 and 2 represented R d values with the largest difference, which accounted for 3.33%. Code name 3 and 4 represented +b values with the largest difference, which accounted for 76.67%. Code name 5 and 6 represented a values with the largest difference, which accounted for 20%. The difference in +b was the largest among all the samples, followed by a and R d .
For the samples belonged to the code name 2 (1.67%) and 4 (49.17%), the difference in parameter a was larger than R d or +b. For the samples belonged to the code name 5 (4.17%) and 6 (15.83%), the parameter a varied greatly than R d and +b. For the cotton samples mentioned above, parameter a should be taken into consideration together with R d and +b in cotton color measurement and grading.
Current cotton color measurement machine only provides the mean color values in an image. The variability represented color evenness, which affected the ability to absorb dye. The variability and mean values of the color parameters were both obtained based on the CCD camera, as shown in figure 10, and the variability of R d was the largest, which was followed by +b and a.  The histograms of color parameters among16 samples were obtained. In general, the histograms of R d , a and +b exhibited normal distributions, as shown in figure 11. The more concentrated distribution resulted in more uniform internal color [3]. It showed that the necessity to increase variability to grade cotton, as cotton samples with similar mean color parameter values may have different variability. As shown in table 2, 6 # (84.82) and 14 # (84.08) had similar mean values in R d . While the variations in R d of the former was 5.36, which was apparently higher than that of latter. Similar phenomenon was also observed in 9 # , 10 # and 10 # , 11 # . 9 # (−3.89) and 10 # (−3.87) shown similar mean values in +b. While the variations the former was 0.39, which was apparently lower than that of latter. 10 # (13.33) and 11 # (13.31) shown similar mean values in a. While the variations in a of the former was 1.98, which was apparently lower than that of latter.

Conclusion
A fast and low-cost digital technique was used to test cotton color with high accuracy. The proposed LDL test method mainly contains LED lamps, digital CCD camera and correction equations caused by light source. Images captured by the experimental device contained the color data, from which the color parameters were obtained by image analysis. During the cotton color measurement, the influence of trash was removed based on Figure 9. Difference of Hunter parameters in any two cotton samples: code name 1 means D Rd >D +b >D a, code name 2 means D Rd >D a >D +b , code name 3 means D +b >D Rd >D a , code name 4 means D +b >D a >D Rd , code name 5 means D a >D Rd >D +b , code name 6 means D a >D +b >D Rd . Figure 10. Variability in Hunter parameters tested by LDL. the proposed two-step trash detection algorithm, which was more accurate. The trash in cotton was classified into three categories based on perceptual color, and then all kinds of trash was detected based on gray distribution. Experiment showed that the method of combination of fixed and Otsu's threshold detected trash  effectively. Experimental results tested by the LDL method were in good agreement with the standard instrument. Finally, a comprehensive evaluation system was proposed to grade cotton. This is because the neglected parameter a varies greatly among different cotton samples. Therefore, it is more reasonable to grade cotton in the 3D Hunter color space. At the same time, cotton samples with similar average color values (parameter R d and +b) may have different color variation and distribution. Therefore, the internal variation and distribution should be investigated to evaluate cotton. The proposed trash detection method has removed the influence of trash on the cotton color measurement. The method also can be applied to detect objects in other fields. The proposed additional color parameters were helpful to grade cotton. The LDL is a fast, precise and low-cost cotton color testing method.