### Segmentation using thesholding and watershed

The rough segmentation of the image is divided into two steps. The first step is to separate starch granules from background using automatic thresholding. The second step is to use watershed algorithm to roughly segment the image.

From the microscopic images of starch granules in Fig. 1(a), we can know that the starch granules are dark with low gray values while background is light gray with high gray values. Its histogram in Fig.1 (b) shows that there are two peaks corresponding to starch granules and background respectively. Therefore it will facilitate watershed to extract the objects if starch granules can be separated from background. We employ automatic thresholding or dynamic thresholding to separate the two dominant parts. The algorithm is from [11] and is described as follow:

**Step 1.** Select an initial threshold T0 and stopping criterion ε. T0 is set as the mean of whole image, and the stopping ε is set as a very small value;

**Step 2**. Let the current threshold T equal to T0;

**Step 3.** Segment the image with threshold T as follows: If a pixel has a gray value less than T, it is classified into class C1 (starch grain part), and if the pixel has a gray value more than T, then it is classified into C2(background part).

**Step 4.** Compute the average values μ_{1} and μ_{2} for the pixels in regions C1 and C2 respectively by

(1)

where *f*(.) is the gray values of an image, *M*, *N* are the numbers of the pixels in classes C1 and C2 respectively.

**Step 5.** Compute a new threshold value by

(2)

Repeat step 3 through 5 until the difference in T in successive iterations is smaller than ε.

After the starch granules have been separated from background, a binary image is generated which 0 means the starch grain part and 1 means the background. After we obtain the binary image, we calculate the Chamfer distance of the binary image. Chamfer distance transformations rely on the assumption that it is possible to deduce the value of the distance at a pixel from the value of the distance at its neighbors [12][13]. Chamfer distance transforms are a class of effective discrete algorithms which offer a good approximation to the desired Euclidean distance transform which is computationally very intensive[13]. After the Chamfer distance map of the binary image is obtained, it is used as the input of watershed algorithm for object segmentation. The basic idea of watershed algorithm comes from field of topography [14]: a drop of water falling on topographical surface follows a steepest descent line until it reaches a local minimum[14]. Watershed lines are considered as divide lines to attract the drops of water. Water will fill up basins starting at these local minima and dams will be built when water coming from different basins meets [15]. The surface is partitioned into regions or basins are separated by these dams. For image segmentation, intensity gradient is usually considered as a topographic surface, each regional minimum of the gradient image is the attraction point of a catchment basin. In our algorithm, Meyer’s watershed algorithm [14] is adopted. The regions after watershed segmentation are called a region.

### Identification of oversegmentation

One of the big issues of watershed algorithm is oversegmentation when it is used for image segmentation. Oversegmentation happens when a granule is segmented into two or more segments. These segments from the same granule are called oversegments in this paper.

In order to alleviate oversegmentation, we develop a hybrid algorithm to reduce it. The proposed algorithm for reducing oversegmentation is divided into two stages. The first stage is to identify the oversegments and the second stage is to merge the oversegments to the objects which they belongs to. In the first stage, we use both shape information and gradient vector flow to identify the oversegments automatically.

Since the shape of a starch granule is round or nearly round, the roundness of an oversegment should likely be small because it’s only one part of a round object. Thus, we use the roundness values of segments to identify oversegments. The roundness is computed as

(3)

where S and L are the area and perimeter of a segment respectively. If a segment has a roundness value less than some threshold, it is classified as an oversegment.

However, the use of roundness values of the starch granules is not enough to identify all the oversegments because some oversegments may have big roundness values. In order to alleviate this difficulty, we use the critical points of the GVF (gradient vector flow) field of segments [16] to further identify the oversegments which have not been identified using the roundness criteria. The proposed method is based on the fact that each granule should have a critical point. We consider a segment to be an oversegment if there is no critical point inside it. In order to use this method, we need to compute the GVF field of the image and then use it to compute the critical points of the objects. The GVF used in this paper is obtained using the method developed in [17][18]. Let GVF be defined as the vector field **v**(*x*, *y*) = (*u*(*x*, *y*), *v*(*x*, *y*)), then it can be obtained by minimizing the following energy functional[17][18]

(4)

To solve the above GVF functional, the following Euler equations can be obtained using calculus of variations [17][18]

(5)

(6)

where ∇^{2} is the Laplacian operator. The GVF field can be obtained by treating *u* and *v* as a function of time *t*[17][18]

(7)

(8)

After the GVF field is obtained, we use it to find the critical points in the segments, which are obtained by watershed segmentation. Because each object has a center, thus we will find the critical points around the center. Based on the research in [16], the 8-neighbourhood gradient vectors of an critical point should point to eight different directions outward and the critical point should has zero gradient vector in the GVF field as shown in Fig.2.

Let *S =* (*S*_{
x
}, *S*_{
y
}) be a candidate of a critical point, be the *i*-th pixel in the 8-neighbourhood of pixel be the gradient vectors obtained at pixel *N*_{
i
}(*i* = 1,2…,8). In order to determine whether *S* is a critical point, we compute the cosine similarity between two directions, which is defined as[19][20]:

(9)

where • is dot product and, || || denotes magnitude of a vector, is the directional vector pointing from *S* to *N*_{
i
},which is obtained by

(10)

The cosine similarity is from 0 to 1, and bigger cosine similarity means higher similarity of two directions as in Fig.2. In our experiments, if the similarity value between two directions is more than 0.90, it can be considered similar enough or the same. A critical point can be detected if there are more than 6 directions similar enough to the 8-neighborhood directions as in Fig.2. If the segment doesn’t have critical point, then it is identified as an oversegment.

After roundness criterion and critical point criterion are used to identify the oversegments, there are still some oversegments which are not identified. In the experiments, we found that an oversegment which is not identified by the two criteria is the segment which occupies more than half of an object. Thus, after identification processing, the segments are classified into three types: (1) oversegments identified; (2)oversegments unidentified; (3) single objects. We call the second and the third types of segments core segments because they are segments with big round values and critical points.

### Merging oversegments

After the oversegments are detected, the fuzzy c-mean classifier is applied to merge them. In classical cluster analysis, each datum must be assigned to exactly one cluster [17]. Fuzzy cluster analysis relaxes this requirement by allowing the gradual memberships to improve the efficiency and robustness of classification. The most widely used clustering method is FCM(fuzzy c-means) [21], which allows the number of clusters to be automatically adjusted during the iteration by merging similar clusters and splitting clusters with large standard deviations. Given a set of data pattern, , the algorithm tries to minimize the weighted within group sum of squared error object function *J(U,V)*[21]

(11)

where *x*_{
k
} is the *k*-th *p*-dimensional data vector, *v*_{
i
} is the center of class *i*, *u*_{
ik
} is the degree of membership of *x*_{
k
} in the *i-th* class, *m* is the weighting exponent on each fuzzy membership, *d*(*x*_{
k
}*,v*_{
i
}) is the distance between data pattern *x*_{
k
} and the cluster center *v*_{
i
}, *n* is the number of data and *c* is the number of clusters. Here *u*_{
ik
} satisfies

(12)

Minimization of objective functional in (11) can be solved by an iterative process as follows[21]:

(13)

(14)

Fuzzy c-means is a data clustering technique based on the features of the observed objects, thus effective features selection plays a vital role in merging similar clusters and splitting clusters. Since intensity and position are the main features to distinguish different segments, the mean intensity, intensity variance are the two primary features of a segment. The space position is also important to investigate the relationship between segments. After being clustered by the watershed, the center of each segment is obtained. We can calculate the distance between segment center and the center of region of interest (ROI), which includes the supposed oversegments. In order to indicate the importance of the features, we can assign weight to each feature. The distance should be given bigger weight for it’s more important when two or more adjacent segments are determined to merge. In our experiment, the weights are 0.25, 0.25, 1.0 for mean intensity, variance of intensity and centers distance.

Our proposed method can be described as follows:

**Step 1.** Separate background and starches using automatic thresholding and obtain a binary image;

**Step 2.** Calculate Chamfer distance of the binary image;

**Step 3.** Segment objects using watershed algorithm based on Chamfer distance map;

**Step 4.** Compute the roundness of the segments by watershed method, and then identify the oversegments with small roundness;

**Step 5.** Analyze the GVF fields of segments with big roundness and search critical points so as to identify the oversegments without critical points.

**Step 6.** Extract the features for segments.

**Step 7.** Initialize cluster centers using centers of core segments.

Step 8. Merge the oversegments identified to the core segments by Fuzzy c-means clustering.