# An Efficient Iterative Thresholding Algorithms for Color Images of Cotton Foreign Fibers

Xin Zhang, Daoliang Li, Wenzhu Yang, Jinxing Wang, Shuangxi Liu

► To cite this version:

Xin Zhang, Daoliang Li, Wenzhu Yang, Jinxing Wang, Shuangxi Liu. An Efficient Iterative Thresholding Algorithms for Color Images of Cotton Foreign Fibers. 4th Conference on Computer and Computing Technologies in Agriculture (CCTA), Oct 2010, Nanchang, China. pp.710-719, 10.1007/978-3-642-18369-0_84. hal-01564842

HAL Id: hal-01564842

https://inria.hal.science/hal-01564842

Submitted on 19 Jul 2017

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>
An efficient iterative thresholding algorithms for Color
images of Cotton Foreign Fibers

Xin Zhang<sup>a,b</sup>, Daoliang Li<sup>a,*</sup>, Wenzhu Yang<sup>a</sup>, Jinxing Wang<sup>b</sup>, Shuangxi Liu<sup>b</sup>

a College of Information and Electrical Engineering, China Agricultural University, Beijing 100083, PR China

b College of Mechanical and Electronic Engineering, Shandong Agricultural University, Taian, Shandong
271018, China

Abstract

The goal of color image segmentation is to divide the image into homogeneous regions. Thresholding is a commonly used technique for image segmentation. Thresholding assumes that image present a number of components, each of a nearly homogeneous value, and that one can separate the components by a proper choice of intensity threshold. In this paper, we present an efficient iterative algorithm for finding optimal thresholds. In the first step, color images were captured, and the edge of color images were detected by edge detection method. In the second step, color images were converted into a gradient map, and then the regular of experience values were analyzed, at last the best threshold of the gradient map was chosen by selecting the best experience value iteratively. The experiment results indicate that the best threshold selection of the gradient map can precisely segment the high-resolution color images of cotton foreign fibers.

# 1 Introduction

The foreign fibers in cotton refer to those non-cotton fibers and dyed fibers, such as hairs, binding ropes, plastic films, candy wrappers, and polypropylene twines, etc. Foreign fibers mixed with cotton during picking, storing, drying, transporting, purchasing and processing, are difficult to remove in spinning process, and can cause yarn breakage, even reducing the efficiency. Every low content of foreign fibers in cotton, especially in lint, will seriously affect the quality of the final cotton textile products, as they may debase the strength of the yarn, and are not easy to be dyed (Yang, et al., 2009). Therefore, various techniques have been employed to implement automatic inspection and removal of foreign fibers in lint, including ultrasonic-based inspection, sensor-based inspection, and machine-vision-based inspection, etc. In recent years, machine vision systems have been applied to textile industries (Tantaswadi et al., 1999; Millman et al., 2001; Abouelela et al., 2005) for inspection and/or removal of foreign matters in cotton (Lieberman et al., 1998) or wool (Su et al., 2006).

The recognition of foreign fibers of targets is the key machine vision technology, in which
image segmentation is an important step. Thresholding is a simple and commonly used technique
for image segmentation (M. Fornasier et al., 2007). It aims to group the image pixels by checking
the pixel intensities against a set of thresholds. Searching for optimal thresholds with respect to a
particular objective function has always been one of the fundamental problems in image
processing. Numerous methods have been proposed in the past (Sankur and Sezgin, 2004;
Tancredi A. et al., 2006; Yin, 2002; Cheng et al., 2000). The methods mentioned above may work
well in their specific context, but it's not capable to segment images of cotton foreign fibers
because of the low contrast. Due to the uneven thickness of the layers of cotton and foreign fibers
of different colors and shapes, using the above conventional image segmentation methods may
lead to significant variations of segmentation for foreign fibers. It is hard to attain a satisfying
result by using one segmentation method. In this article, a novel method based on mathematical
morphology and iterative thresholding method is proposed to segment such low-contrast images.

**2. Materials and methods**

The foreign fibers used in this research were collected from cotton mills which included feathers, hair, hemp rope, plastic films, polypropylene twine, colored thread, cloth piece etc. Adequate pure lint with no foreign fibers was also prepared for making the lint layer. The experiment selected a sufficient amount of lint cotton which does not include foreign fibers.

**2.1 Materials preparation**

The Image Acquisition System is the most important part in this experiment platform. It consist mainly of two cameras, two light sources, one shaft encoder, one synchronizing amplifier, two image acquisition boards and a computer, as shown in Figure 1.

By observing the images obtained, it was easy to find that the opened foreign fibers appears in three typical forms, as shown in Fig. 2a-c, (1) sheet, such as plastic films, papers, etc., (2) wirelike, such as hair, color thread, etc., and (3) villiform, such as hemp rope, chemical fibers, etc.

<figure><img src="image_2.png" /><figcaption>Fig. 1 The image acquisition system</figcaption></figure>

<figure><img src="image_3.png" /><figcaption>Fig. 2 Acquired color image examples: (a) opened plastic film, (b) opened hair, and (c) opened hemp rope.</figcaption></figure>
## 2.2 Iterative method principle

The identification of cotton foreign fibers is done through real-time monitoring, however, when it is in different circumstances, it will have different light intensity. Therefore, the target segmentation for foreign fibers can not be through a fixed thresholding value to segment. In this case, the thresholding was automatically selected by iterative method in this paper.

Thresholding is the most widely used image segmentation method. Thresholding algorithm has histogram bimodal method(also known as the mode method), Otsu method and the iterative threshold method, etc. Histogram bimodal method is used to some simple images, which appear two separate peaks in histograms, and then the troughs which correspond gray value between two peaks was selected as threshold value.

Iterative threshold method is the improved method of histogram bimodal, and it is an automatic process of selecting threshold, which is described as follows:

(1) The gradient map can be acquired through the edge detection method of mathematical morphology. To calculate the min gray value $Z_1$ and max gray value $Z_k$ of this gradient map, defined thresholding to initial value:

$$T^0 = \frac{Z_1 + Z_k}{2} \qquad (1)$$

(2) Gray gradient map is divided into two parts, object and background, through the thresholding $T^k$, and then calculating the target average gray value $Z_0$ and the background average gray value $Z_B$;

$$Z_0 = \frac{\sum_{z(i,j)<T^k} z(i,j) \times N(i,j)}{\sum_{z(i,j)<T^k} N(i,j)} \qquad (2)$$

$$Z_B = \frac{\sum_{z(i,j)>T^k} z(i,j) \times N(i,j)}{\sum_{z(i,j)>T^k} N(i,j)} \qquad (3)$$

In the above formulas, $z(i, j)$ is $(i, j)$ point on gray value of gray gradient map, $N(i, j)$ is weight coefficient of $(i, j)$ point, $N(i, j)=1.0$;

(3) Obtaining a new adaptation thresholding of cotton foreign fibers:

$$T^{k+1} = n \times (Z_0 + Z_B) \qquad (4)$$

The value $n$ of conventional iterative threshold method is 0.5, but this value is not suitable for images of cotton foreign fibers, hence, this paper presents the experienced value method for selecting value $n$.

## 3. Results and discussion

Seven typical foreign fibers, namely, plastic film, feather, polypropylene twine, hair, color
thread, hemp rope and cloth piece, were selected for the experiments. Ten samples were prepared for each type of foreign fibers. That is to say, there are totally 70 foreign-fiber samples. Matlab 7.0 was used to implement and validate the algorithm. An Intel Core 2 Duo CPU personal computer with 2GB SDRAM was chosen as the test environment and Windows XP was selected as the operation system.

## 3.1 Analysis of the improved threshold selection of iterative method

In order to increase the range of differences as far as possible, the range is defined from 0.1 to 0.9.
Table1 to Table3 are the final iteration threshold $T_{next}$ and the previous threshold comparison of the results between wirelike, villiform and sheet foreign fibers.

<table><caption>Tab. 1 Comparison of experiment results of hair</caption><thead><tr><th>experience value</th><th>0.1</th><th>0.2</th><th>0.3</th><th>0.4</th><th>0.5</th><th>0.6</th><th>0.7</th><th>0.8</th><th>0.9</th></tr></thead><tbody><tr><th>T</th><td>0.012128</td><td>0.13321</td><td>0.50269</td><td>0.50269</td><td>0.50269</td><td>0.50269</td><td>0.50269</td><td>0.50269</td><td>0.50269</td></tr><tr><th>T<sub>next</sub></th><td>0.066604</td><td>0.063806</td><td>0.19981</td><td>0.26641</td><td>0.33302</td><td>0.39962</td><td>0.46623</td><td>0.53283</td><td>0.59943</td></tr></tbody></table>

<table><caption>Tab. 2 Comparison of experiment results of feather</caption><thead><tr><th>experience value</th><th>0.1</th><th>0.2</th><th>0.3</th><th>0.4</th><th>0.5</th><th>0.6</th><th>0.7</th><th>0.8</th><th>0.9</th></tr></thead><tbody><tr><th>T</th><td>0.066206</td><td>0.13241</td><td>0.51063</td><td>0.51063</td><td>0.51063</td><td>0.51063</td><td>0.51063</td><td>0.51063</td><td>0.51063</td></tr><tr><th>T<sub>next</sub></th><td>0.020063</td><td>0.075758</td><td>0.19862</td><td>0.26482</td><td>0.33103</td><td>0.39724</td><td>0.46344</td><td>0.52965</td><td>0.59585</td></tr></tbody></table>

<table><caption>Tab.3 Comparison of experiment results of plastic film</caption><thead><tr><th>experience value</th><th>0.1</th><th>0.2</th><th>0.3</th><th>0.4</th><th>0.5</th><th>0.6</th><th>0.7</th><th>0.8</th><th>0.9</th></tr></thead><tbody><tr><th>T</th><td>0.065354</td><td>0.13071</td><td>0.48571</td><td>0.48571</td><td>0.48571</td><td>0.48571</td><td>0.48571</td><td>0.48571</td><td>0.48571</td></tr><tr><th>T<sub>next</sub></th><td>0.013167</td><td>0.073519</td><td>0.19606</td><td>0.26142</td><td>0.32677</td><td>0.39212</td><td>0.45748</td><td>0.52283</td><td>0.58819</td></tr></tbody></table>

Table 1 to Table 3 show that when the value $n$ is between 0.3 to 0.9, no matter what wirelike, villiform and sheet foreign fibers in the previous thresholds are equal, that is, only when $n > 0.2$, the value $T$ began to significantly change, therefore, $n = 0.2$ is the mutation point of thresholding selection.

The following images are intuitively verifying this experience value.

The Fig. 3 are the typical images of wirelike, villiform and sheet foreign fibers. The range of experience value is from 0.1 to 0.5, step is 0.1. The follows are the effected images.

<figure><img src="image_4.png" /></figure>
<figure><img src="image_5.png" /><figcaption>Fig.3 Original color images and its effected images</figcaption></figure>

(a1)-(a3) Original color images (b1)-(b3) n =0.1 (c1)-(c3) n =0.2 (d1)-(d3) n =0.3 (e1)-(e3) n =0.4 (f1)-(f3) n =0.5

From the above Fig. 3 shows that, when n > 0.2, the clarity of target image decreased gradually, and when n = 0.6 ~ 0.9, the effected images for all kinds of foreign fibers become increasingly unobvious , so that wirelike form foreign fibers is difficult to see the target image, thus this paper doesn't list this range images. When n = 0.1, as it is too small, the binary images are acquired almost black.

From analysis above, it is concluded that , when n =0.2, the selected thresholding is fit for most gray gradient maps for foreign fibers, and then getting the most clearly binary object images, formula (13) can be written as:

$$T^{k+1} = 0.2 \times (Z_0 + Z_B)$$

(4) If $T^k = T^{k+1}$, it is terminated, or letting $K \leftarrow K+1$, go to step (2).

## 3.2 Analysis of optimal threshold selection

Fig. 4 are color images of hair and the plastic film for cotton-fiber and its histogram. Histogram analysis in Fig.4 shows that almost all histograms are single peak. The main reason for the histogram being of single peak is that the content of the foreign fiber in lint is very low, and it leads to small number of pixels for foreign fibers in the image. Therefore, it can not be acquired thresholding according to double peaks method.
<figure><img src="image_6.png" /><figcaption>Fig.4 Original color images and its histogram</figcaption></figure>

(a) original color image of blue polypropylene

(b) histogram of blue polypropylene image

(c) original color image of hemp rope

(d) histogram of hemp rope image

The Otsu's method (Otsu, 1979), which is also called maximum between-group variance method, is a kind of adaptive thresholding method which has the optimal threshold according to the statistics. The defect of Otsu's method is when the target and background gray scale difference is not obvious; it will lead to error segmentation, even losing the whole image information. The segmentation of hemp rope for cotton foreign fibers belongs to this case. Fig.5 is color image of hemp rope and its segmented image by Otsu's method for cotton foreign-fiber.

Based on above analysis of experimental and theoretical, in order to solve a problem when object and background gray scale difference is not obvious leading to loss of image information, this paper presents a new approach for image segmentation which includes several steps. In the first step, color images were captured, and the edge of color images were detected by edge detection method. In the second step, color images were converted into a gradient map, and then the regular of experience values were analyzed, at last the best threshold of the gradient map was chosen by selecting the best experience value iteratively. Fig.5 are original color images of three typical foreign fibers and their gray gradient maps, and segmented images by iterative thresholding method.

<figure><img src="image_7.png" /></figure>
<figure><img src="image_8.png" /><figcaption>Fig.5 Original color images and its segmented image by iterative threshold method</figcaption></figure>

(a)-(c) Original color images of hair, hemp rope and plastic film

(d)-(f) gray gradient images of hair, hemp rope and plastic film

(g)-(i) segmented images by iterative threshold method of hair, hemp rope and plastic film

## 4. Conclusion

In this paper, research and analysis of the relationship and regularity of thresholding for final iteration and the previous iteration, which are after the iteration for wirelike, villiform and sheet foreign fibers. At last the experience value is determined, which is fit for the gray gradient map of most foreign fibers, thus the clear binary image is obtained. The segmentation results indicate that the method of this paper can content the premise accuracy for image segmentation of foreign-fiber.

The mandate of speed is a key factor for the online visual inspection system. Hence, in addition to ensuring the segmentation accuracy, algorithms with faster speed is now being studied.

## Acknowledgements

The authors would like to thank The National Natural Science Foundation of the People's Republic of China (30971693), and New Century Excellent Talents of Ministry Education (NCET-09-0731) for their financial support.
References:

Abouelela, A., Abbas, H.M., Eldeed, H., Wahdam, A.A., Nassar, S.M., 2005. Automated vision system for localizing structural defects in textile fabrics. Pattern Recognition Letters 26 (10), 1435 – 1443.

Cheng, H.D., Chen, Y.H., Jiang, X.H., 2000. Thresholding using twodimensional histogram and fuzzy entropy principle. IEEE Trans.Image Process. 9, 732–735.

Lieberman, M.A., Bragg, C.K., Brennan, S.N., 1998. Determining gravimetric bark content in cotton with machine vision. Textile Research Journal 68 (2), 94 – 104.

Millman, M.P., Acar, M., Jackson, M.R., 2001. Computer vision for textured yarn interlace (nip) measurements at high speeds. Mechatronics 11 (8), 1025 – 1038.

M. Fornasier, F. Pitolli, Adaptive iterative thresholding algorithms for magnetoenceophalography (MEG), J. Comput. Appl. Math. (2007), doi:10.1016/j.cam.2007.10.048, in press.

Sankur, B., Sezgin, M., 2004. A survey over image thresholding techniques and quantitative performance evaluation. J. Electron. Imaging 13 (1),146–165.

Su, Z.W., Tian, G.Y., Gao, C.H., 2006. A machine vision system for on-line removal of contaminants in wool. Mechatronics 16 (5), 243 – 247.

Tantaswadi, P., Vilainatre, J., Tamaree, N., Viraivan, P., 1999. Machine vision for automated visual inspection of cotton quality in textile industries using color isodiscrimination contour. Computers & Industrial Engineering 37 (1 – 2),347 – 350.

Tancredi, A., Anderson, C., O'Hagan, A., 2006. Accounting for threshold uncertainty in extreme value estimation. Extremes 9, 86 – 106.

Yang, W., et al., A new approach for image processing in foreign fiber detection. Comput. Electron. Agric. (2009), doi:10.1016/j.compag.2009.04.005

Yin, P.Y., 2002. Maximum entropy-based optimal threshold selection using deterministic reinforcement learning with controlled randomization. Signal Process. 82, 993–1006.