# An Online Image Segmentation Method for Foreign Fiber Detection in Lint

Daohong Kan, Daoliang Li, Wenzhu Yang, Xin Zhang

► To cite this version:

Daohong Kan, Daoliang Li, Wenzhu Yang, Xin Zhang. An Online Image Segmentation Method for Foreign Fiber Detection in Lint. 4th Conference on Computer and Computing Technologies in Agriculture (CCTA), Oct 2010, Nanchang, China. pp.701-709, 10.1007/978-3-642-18369-0_83 . hal-01564841

HAL Id: hal-01564841

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

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>

Distributed under a Creative Commons Attribution 4.0 International License
# An Online Image Segmentation Method for Foreign Fiber Detection in Lint

Daohong Kan*, Daoliang Li, Wenzhu Yang, Xin Zhang

College of Information & Electrical Engineering, China Agricultural University, Beijing

100083, P. R. China

**Abstract.** The image of lint containing foreign fiber features that the background (cotton fiber) is homogeneous and has a normal gray-level distribution; the object (foreign fiber) is smaller, darker than the background but its gray-level distributes is a wide range. In this paper, a Background Estimation Thresholding(BET) method is presented to segment the objects from such kind of images. The segmented objects will be used to determine the existence and measure the quantity of foreign fiber. The experimental results show that the BET is effective and fast, and can be used in the online foreign fiber inspection in volumes of lints.

**Key words:** Image segmentation, Thresholding, Cotton, Foreign fiber

## 1. Introduction

Machine vision is a technology adopted newly in cotton trade and textile industry to evaluate the cotton quality[1, 2]. The foreign fiber in lint such as plastic film, fabric patch, hemp rope, hair, polypropylene twine, feather, and etc., will seriously affect the quality of final cotton textile product and can be detected and measured by machine vision technology.

China Agricultural University, together with China Cotton Machinery & Equipment Corporation are developing a Foreign Fiber Inspection System(FFIS) to measure the content of foreign fibers in lint, according to which to grade and price, so that the cotton farmers and traders will be more willing to keep the foreign fibers away. FFIS is composed of hardware subsystem and software system, and the hardware system mainly includes lint feeder, opener, scanner, collector and computer, as shown in Fig.1.

* Corresponding author, Email: kandaohong@cau.edu.cn
Lint is fed into the opener by the feeder to generate a 2mm thick, uniform lint slice, in which foreign fiber will be exposed sufficiently and can be detected easily by the scanner. The lint slice is pushed by rollers into an iamging alleyway, which is made of glass with high transparence, and 400mm in width, 4mm in thickness. The lint slice is imaged continuously by 2 scanners which are sensitive to visible light and ultraviolet radiation respectively. The image lines are assembled into frames and then transferred to the computer. Finally, the frames are processed online by the software subsystem.

<figure><img src="image_2.png" /><figcaption>Fig. 1. Scheme of FFIS</figcaption></figure>

Image segmentation is a key step towards the foreign fiber inspection using machine vision technology. Mostly, the cotton fiber has high gray-level (bright) and the foreign fiber has low (dark), and thresholding is a reasonable choice for the segmentation of such kind of images. The thresholding method selects a gray-level T as the threshold based upon histogram (an approximation of gray-level probability distribution). If the gray-level g of a pixel is less than or equal to the T, the pixel will be marked as foreign fiber (object), otherwise as cotton fiber (background).

How to select a threshold appropriately is critical to thresholding. The commonly used technique is to select the optimal threshold according to a Criterion Function(CF). Between-class variance[3] proposed by Otsu is a widely used CF, which is based upon histogram. Otsu method met difficulties when applied to most foreign fiber images, in which the objects are thin and small, and the histograms are unimodal, or in which the gray-levels of objects vary largely, and the histograms extend to the low gray-level side
just like a long tail. Hou's research[4] shows that large differences in class variances or class probabilities will result in threshold bias towards the component with larger class variance or larger class probability. Fig. 2 shows a lint image example with one hair, and its segmentation result by Otsu method.

<figure><img src="image_3.png" /><figcaption>Fig. 2 (a) Lint containing a hair, (b) Segmentation by Otsu method, (c)(d) Histogram and its details at the bottom</figcaption></figure>

There are many attempts to overcome the threshold bias of Otsu CF in the past decades, including modifying the Otsu CF or suggesting a totally new one. Several important CFs are valley-emphasis Otsu CF[5], class variance CF[4], entropy CF[6, 7], fuzziness CF[8], minimum error CF[9], and etc..

When thresholding according to CF, the image segmentation is considered as a classification problem. All of the CFs above assume that the gray-level probability distributions of objects and background are both normal, and the number of classes is predictable (that is how many kinds of objects in the background should be known before thresholding). FFIS can generate uniform lint slice and the lighting is well controlled. The gray-level of cotton fiber, which is background, distributes normally.
But the gray-level of foreign fiber, which is object, varies in a wide range and its distribution can not be considered as normal. The class number is also unpredictable in foreign fiber inspection because there may be or not be foreign fiber, and there may be one kind or many kinds of foreign fibers. So the two assumptions obstruct the application of such thresholding methods in foreign fiber inspection, which may occur in other similar situations.

A segmentation method may be suitable to some kinds of images, but there is not yet an universal method for all kinds of images. In this paper, a Background Estimation Thresholding(BET) method is developed specially for foreign fiber inspection. The experimental results show that the BET is effective and fast, and can be used in the online foreign fiber inspection in volumes of lint. The paper is organized as follows. In Section 2, we describe the BET method and its implementation. Section 3 gives the experimental results and the analysis comparing with valley-emphasis Otsu method. Finally, the paper is concluded in Section 4.

## 2. BET method and its implementation

### 2.1 Method

FFIS scans the uniform lint slice under well controlled lighting and the gray-level of cotton fiber distributes normally. Foreign fiber is darker than cotton fiber and its gray-level is lower. The histogram of a lint image containing foreign fibers is close to normal but extends to the dark side like a tail.

Given a lint image with 256 gray-levels, the proportions of cotton fiber and foreign fiber are denoted by Pb and Po respectively, where Pb+Po=1. The gray-level distribution of cotton fiber can be formulated as:

$$p_b(g) = \frac{1}{\sqrt{2\pi}\sigma} \exp\left(-\frac{(x-\mu)^2}{2\sigma^2}\right) \quad (1)$$

where μ is mean and σ is standard deviation, g=0,1,2,...,255.

The gray-level distribution of foreign fiber, denoted by po(g), is unknown, which may be any form. For a threshold T, the lint image is segmented as follows. For every pixel, if its gray-level g<T, the pixel is marked as object, otherwise marked as background. The error ratio is given by:
$$e(g | T) = \begin{cases} P_b \sum_{g=0}^{T-1} p_b(g), & g < T \quad (a) \\ P_o \sum_{g=T}^{255} p_o(g), & g \ge T \quad (b) \end{cases} \qquad (2)$$

(2.a) gives the error ratio where the background is marked as object and (2.b) gives the error ratio where the object is marked as background. Decreasing T can decrease (2.a) while increase (2.b), and vice versa. Pb(g) is a normal distribution and its mean and standard deviation can be estimated (described below), so (2.a) can be estimated. po(g) is unknown and therefore (2.b) can not be estimated.

(2.a) can be estimated and controlled, it is realistic to select T based only on (2.a), which is a partial error ratio, not the whole error ratio commonly used. (2.a) can be controlled under an acceptable level by choosing T. For example, if $T = \mu - 3\sigma$, (2.a) will be under 0.2%Pb; if $T = \mu - 4\sigma$, (2.a) will be under 0.005%Pb. Such threshold T locates near the darkest gray-level of background. Decreasing T further has little help to decrease (2.a) while increase (2.b) rapidly.

If the background is separable by gray-level value from the object, or their histogram do not overlap or overlap little each other, a T near the darkest gray-level of background will keep the error ratios of (2.a) and (2.b) low both, and the segmentation succeeds. Otherwise if their histogram overlap each other, (2.a) will be low while (2.b) high, which means many object pixels are marked as background, and the segmentation fails. Actually, segmentation will fail for any threshold choice in the latter, which means thresholding is not suitable for such kind of images. Fortunately, most foreign fibers are separate from the cotton fiber in gray-level and can be segmented by thresholding. White polypropylene twine is one inseparable from cotton fiber and can not be ignored in foreign fiber inspection in China. The ultraviolet scanner in FFIS is equipped specially for the detection of foreign fibers like this, which is separable from cotton fiber in the ultraviolet image.

Here we describe how to estimate the mean and standard deviation of Pb(g), which is called background estimation. The cotton fiber is dominant in lint image and its gray-level distribution is normal, it is reasonable to take the gray-level with maximal probability in histogram as the estimation of mean. Most foreign fibers are darker than cotton fiber and all pixels with gray-level between ~ 255 are considered as background. These pixels constitute one half of the background samples, and then the
another half can be mirrored centering at means . The standard deviation can be evaluated finally by Bayersian Estimation based on the background samples.

BET method first do background estimation, and then select a threshold T to control
the error ration of (2.a) under a predefined level (acquired by experiments). The
background of lint image is stable and its gray-level distribution can be estimated, BET
actually extracts the background by a threshold T, which depends on Pb(g) and a
predefined limitation of error ratio.

## 2.2 Implementation

The steps of segmentation by BET are as follows:

Step 1. Computing the histogram h(g), g=0, 1, ..., 255;

Step 2. Mean estimation: =m, where $h(m) = \max_{0 \le g \le 255} \{h(g)\}$;

Step 3. Standard deviation estimation:

$$
\begin{align*}
P_b &= 2 \times \sum_{g=\mu+1}^{255} h(g) + h(\mu) \\
D &= 2 \times \sum_{g=\mu+1}^{255} h(g)(g - \mu)^2 \\
\sigma &= \sqrt{D / P_b} \quad ;
\end{align*}
$$

Step 4. Computing T: $T = k\sigma, 3 \le k \le 4$, where k is predefined;

Step 5. Segmentation: For every pixel in lint image, if its gray-level g<T, then it is marked as object (foreign fiber); otherwise marked as background (cotton fiber).

3. Experiment results

The lint images in our experiment can be divided into three categories, they are cotton fibers only, cotton fibers mixed with foreign fibers whose gray-levels distribute narrowly, and cotton fibers mixed with foreign fibers whose gray-levels distribute widely, which correspond to one class (unimodal), two classes (bimodal) and multiple classes (multimodal) in classification, respectively. The BET method is evaluated against all three categories of lint images. This section gives one example and its comparison with the valley-emphasis Otsu (VEOtsu) thresholding for each category.

At the end of this section, the execution speed of BET is also discussed.
## 3.1 Unimodal

Fig. 3 shows a lint image containing cotton fibers only, whose histogram demonstrates a normal distribution (202.69 in mean, 6.88 in standard deviation). Otsu method will split it at the mean and half of the image will be considered as foreign fiber. It will cause the measurement results meaningless because most lint images do not conrain foreign fiber.

<figure><img src="image_4.png" /><figcaption>Fig. 3 (a)Lint containing cotton fibers only, (b)Histogram</figcaption></figure>

VEOtsu marks all pixels as object, where T=233. BET marks all pixels as background, where the estimated $=203.00$, $=6.87$, predefined k=3.5, and the final T=179. Both of VEOtsu and BET can segment the unimodal image correctly, but VEOtsu sometimes does wrong marking and BET never.

## 3.2 Bimodal

Fig. 2 shows a lint image containing a black hair and a small patch of cotton leaf, whose gray-level distributions are similar by chance. It is bimodal and Fig. 4 shows its segmentations by VEOtsu and BET.
<figure><img src="image_5.png" /><figcaption>Fig. 4 Segmentation of Fig. 2(a), (a) by VEOtsu, (b) by BET</figcaption></figure>

Both of VEOtsu and BET can segment the bimodal image correctly and the BET is closer to human beings. Several black points, labeled in a circle in Fig. 4(b), are contton fibers but segmented as foreign fibers by BET wrongly, because the thickness of lint slice is not uniform fully. These points should be removed in the postprocessing.

**3.3 Multimodal**

Fig. 5(a) shows a lint image containing a feather and a small patch of cotton leaf, whose gray-level distributions in a wide range. Fig. 5(b) shows that the histogram drags a long but thin tail, which is multimodal. Fig. 5(c, d) are the segmentations by VEOtsu and BET respectively.

<figure><img src="image_6.png" /></figure>
<figure><img src="image_7.png" /><figcaption>Fig. 5 (a) Lint containing feather, (b) Histogram in detail at the bottom, (c) Segmentation by VEOtsu, (b) Segmentation by BET</figcaption></figure>

In multimodal case, VEOtsu selects multiple thresholds and the implementation is different from the bimodal. Whether the lint image is unimodal, bimodal, or multimodal is unpredictable, so the bimodal implementation is used commonly by VEOtsu. The feather, shown in Fig. 5(c) is lost excessively by the VEOtsu. The BET selects only one threshold and the implementation is same regardless of the image modality. Fig. 5(d) demonstrates that the BET can segment multimodal image better than the VEOtsu.

## 3.4 Execution speed

To find out the optimal threshold, the VEOtsu needs compute the CF, which includes 2 means and 2 variances, each for every 256 gray-levels. The BET needs find out the gray-level with the maximal probability and compute variance one time. The computation of VEOtsu is more than the BET's and Table 1 shows their execution time for 1 million threshold selections(Intel Mobile Pentium 4 CPU, 2.0 Ghz), where the BET reduces the computation of the VEOtsu to 35.8%.

<table><caption>Table. 1 Execution time of VEOtsu and BET</caption><thead><tr><td>Method</td><td>Execution time (Sec.)</td></tr></thead><tbody><tr><td>VEOtsu</td><td>8.46</td></tr><tr><td>BET</td><td>23.62</td></tr></tbody></table>
## 4. Conclusions

The lint image containing foreign fiber features that the background (cotton fiber) is homogeneous and has a normal gray-level distribution; the object (foreign fiber) is smaller, darker than the background but its gray-level distributes is a wide range. The BET method can extract the foreign fibers from lint image well, which makes the detection and measurement by machine vision technology possible.

Comparing with other thresholding methods such as Otsu, the BET can segment image with higher performance where the existence or types of object are unpredictable, and is suitable for foreign fiber inspection and other similar applications.

The BET method can be applied in foreign fiber inspection online in volumes of lints, where the simplicity and fast speed are greatly concerned.

The thickness of lint slice is not uniformly and the BET segments some cotton fibers wrongly as foreign fibers. This problem is left unresolved and the related researches are going on.

**Acknowledgements.** This research was funded by National Natural Science Foundation of China (30971693) and Ministry of Education of People's Republic of China (NCET-09-0731).

## References

1. Wenzhu Yang, Daoliang Li, Liang Zhu, Yuguo Kang, Futang Li, 2009. A new approach for image processing in foreign fiber detection. Computers and Electronics in Agriculture 68 (1) 68-77.

2. 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.

3. Nobuyuki Otsu, 1979, A threshold selection method from gray-level histograms. IEEE Trans. On Systems, Man, and Cybernetics, Vol. SMC-9, No.1, Jan. 1979, 62-66.

4. Z. Hou, Q. Hu, W.L. Nowinski, 2006, On minimum variance thresholding. Pattern Recognition Letters. 27 (2006), 1732-1743.

5. Hui-Fuang Ng, 2006, Automatic thresholding for defect detection. Pattern Recognition Letters 27 (2006) 1644-1649.
6. J. N. Kapur, P. K. Sahoo, A. K. C. Wong, 1985, A new method for gray-level picture thresholding using the entropy of histogram. Computer Vision, Graphics, and Image Processing. 29, 273-285.

7. T. Pun, 1980, A new method for grey-level picture thresholding using the entropy of the histogram. Signal Processing, 2(1980), 223-237.

8. Liang-Kai Huang, Mao-Jiun J. Wang, 1995, Image thrsholding by minimizing the measures of fuzziness. Pattern Recognition, Vol. 28, No. 1, 41-51.

9. J. Kittler, J. Illingworth, 1986, Minium error thresholding. Pattern Recognition, Vol. 19, No. 1, 41-47.