You are on page 1of 5

Proceedings of the 7th World Congress on Intelligent Control and Automation June 25 - 27, 2008, Chongqing, China

Improved Watershed Algorithm for Dowels Image Segmentation*


Yuqian Zhao 1, 2, Jianxin Liu 2, **, Huifen Li 2 and Guiyuan Li 1
1. Cancer Research Institute; 2. School of Info-Physics and Geomatics Engineering Central South University Changsha, Hunan Province, China
@mail.csu.edu.cn

Abstract- Watershed algorithm is applied widely to image segmentation for its fast computing and high accuracy in locating the weak edges of adjacent regions. But classical watershed segmentation is sensitive to noise and can leads to serious over-segmentation. Aiming at the limitation of watershed segmentation, this paper presented an algorithm of watershed transformation based on opening-closing operation and distance transform. It improved the classical watershed segmentation algorithm based on distance transform, overcoming over-segmentation. The experiment result demonstrated that this method for segmentation inherits the advantage of watershed algorithm based on distance transform that it successfully segment out each dowel in the image bringing convenience to computer vision and auto-counting of dowels. It also overcame over-segmentation existed in traditional watershed segmentation preserving the original edges of each dowel in the image completely. Index Terms - Watershed, distance transformation, openingclosing filtering, segmentation

segmentation result apparently superior to the approach of employing watershed simply based on distance transformation [4]. BASIC CONCEPTS AND FUNDAMENTALS A. Watershed Segmentation Algorithm

. INTRODUCTION Watershed is an algorithm for image segmentation developed in recent years based on mathematical morphology [1], and has draw great attention for its fast computing and high accuracy in locating the weak edges of adjacent regions. But classical watershed segmentation is sensitive to noise and can leads to serious over-segmentation. Therefore, many researchers has proposed various methods continually for improving, such as a preprocessing step of calculating distance transform for the binary image before watershed transformation [2], or agglomerating regions after segmentation following watershed transformation [3]. Nevertheless, owing to the influence of person or device in practical process of image making, the useful information of adjacent districts is not average distributed which makes some improving steps necessary for segmentation result. In this paper we present a method for segmentation utilizing watershed algorithm based on morphological opening-closing filtering and distance transformation. The application of this method for segmenting dowels image overcomes over-segmentation effectively, and produces a satisfactory

Watershed algorithm, which is based on mathematical morphology, is first proposed by S. Beucher and L. Vincent and is developed rapidly in image segmentation field in recent years [5- 6]. It is sensitive to weak edges, and is capable of acquiring one-pixel connected and closed contours with exact location [7- 8]. Fig.1 illustrates the classical model of one dimensional watershed algorithm: immersion simulation [9]. Consider the model shown in Fig.1 (a) as a topographical map. Firstly search out all the local minima where to pierce holes. And then dip the model into a lake at a uniform speed as the time. The water begins to pour into the holes at the local minima to construct catchment basins as shown in Fig.1 (b). To prevent the fusion of two catchment basins corresponding to different regional minima, a dam is erected between them at the points where they meet each other as shown in Fig.1 (c). After all the topographties are immerged into the lake, watershed lines in the form of dams are constructed as shown in Fig.1 (d). One dimensional watershed corresponds to the local maxima; and two-dimensional watershed corresponds to a series of saddle points and local extremes. For digital images of two-dimensional discrete grid, watershed constitutes closed contour of one-pix wide. Strict mathematical description of watershed algorithm can be found in [10- 11]. For the further understanding of fundamentals of watershed segmentation, consider light pixels of the image as peaks of the mountains immersed into the lake and the black pixels as valleys. Unlike simple threshold segmentation, watershed segmentation is an adaptive iterative threshold algorithm used for segmentation. A profile is shown in Fig.2 that two peaks of higher gray level correspond to the objects O1 and O2 respectively. The segmentation aims at extracting two objects from

* This work is partially supported by Hunan Provincial Natural Science Foundation of China under Grant No.06JJ30013, Hunan Provincial Science and Technology Program Foundation of China under Grant No.05SK3055 and Postdoctoral Foundation of Central South University ** Corresponding author. E-mail: zyq@csu.edu.cn.

978-1-4244-2114-5/08/$25.00 2008 IEEE.

7644

(a) One dimensional model

(b) Punching at regional minima

catchment basins

dam

(c) Water pours into basins from the holes

(d) A dam is erected to avoid fusion

dams

(e) Build the right dam while heighten the left dam

(f) watershed in the form of three dams

Fig.1 Immersion model for one dimensional watershed algorithm.

background and dividing them from each other. At first choose a threshold of high value with which O1 and O2 can be separated from background yet too large a gap between objects occurs. If a threshold of smaller value is set for use, the edges of O1 and O2 would expand toward each other which allow two objects to meet at last. Hence decrease the value of the threshold until when the two objects are to merge with one another, and for the time being the reserved sets of pixels just make up ultimate edges of the objects. Choose of the initial threshold is critical. A threshold too high as Tb shown in Fig.2, in the beginning, will lead to the disappearing of objects with low contrast which will be merged during the process of lowering threshold. On the contrary, with an initial threshold too small, as Ta shown in Fig.2, the objects will be merged in the start of the process. Besides, choose for an ultimate threshold is also significant which will determine the degree of final edges correspondence with the objects. In practical application, minima of morphological gradient (or other gradients) are taken as markers of flooding. Due

to the noise or local irregularities of grayscale of original signal, there may be many incorrect minima in gradient image which will cause over-segmentation. Although smoothening is done to the image, the number of minima is often larger than the number of objects in original image. In this situation markers should be obtained by other preprocessing approaches instead of being set equal to the minima in gradient image. Actually the process of setting markers could be completed
f (x)
O1 O2

Tb

Ti

Ta
x

Fig.2 principle of watershed segmentation.

7645

interactively. Though the set of makers may be a subset of minima in gradient image, there is no demand for it. Once markers are decided watershed segmentation could be carried out. As an extension of this method, the marker points are labeled first, and then dam is erected only with points of diverse labels to pretend regions from merging. In this way over-segmentation could be prevented. B. Opening-Closing Filtering Opening-closing operation is a kind of iterative calculation of erosion and dilation. The opening operation of image f by structure element b can be denoted as f $ b , which is defined as: (1) f $ b ( f4b) b . It means that, erode f by b at first and then apply dilation operation to the erosion result using structure element b. Analogous with this, the closing operation of f by structure element b can be defined as: (2) f x b ( f b)4b . In practical application, opening operation usually is used to remove light spots of smaller size than structure element while keep features of larger regions and all gray levels changeless. Erosion operation can eliminate the smaller light details while darkening the image. If the result is performed by dilation operation, it would lighten the image no longer bringing in fractions that has already been got rid of. On the contrary, closing operation is often used to eliminate the dark spots of smaller size than the structure element while gray value of larger regions is maintained. Dilation at the start can eliminate smaller dark details as it lightens the image. And the

following erosion will darken the image and never import the removed portion again. Therefore, a combination of opening and closing operation, which is called opening-closing filtering, can be utilized to smooth images and eliminate the noise. To clarify the property of opening-closing filtering, taking a flat structure element for example, we apply opening-closing operation to the input signal with many peaks and valleys. Fig.3(c) shows that the signal f is well smoothened by the flat structure element g in opening operation that the underside of the signal curve is influenced. And Fig.4(c) shows that the signal f is well smoothened by the flat structure element g in closing operation however the upper side of the signal curve is changed comparing with opening operation. C. Distance Transformation Distance transformation is a kind of transformation based on geometry information of the image and was first put forward by Rosenfeld and Pfaltz [12]. It reflects the location feature of pixels in the image. Now distance transformation has been widely used in the fields of image analysis, model recognition and computer vision, and is progressively becoming a basic operation and research hotspot in those domains to accomplish object thinning, skeleton extraction, image merging, segmentation and registration, and so on [13-15]. In two-dimensional space, an image of size n n can be regarded to be made up of two classes of pixels: background and feature. The former is called black point while the latter light point. Distance transformation seeks to find out the nearest pixel of light point for each pixel in the image and calculate the distance between them.

f $g

(a) Structure element

(b) Input signal Fig.3 Opening operation with a flat structure element.

(c) Opening filtering

.
f xg

(a)Structure element

(b) Input signal Fig.4 Closing operation with a flat structure element.

(c) Closing operator filtering

7646

A binary image of size n n can be represented by a two dimensional matrix A [a ij ] , if pixel (i, j) is a light point,

1 , else a ij 0 . Denote all the light points as F {( x , y) | a xy 1} , and distance transformation is to calculate the distance for all pixels in the binary image by (3). (3) d ij min D[(i, j), ( x , y)]
( x , y )F

then a ij

Where D[(i, j), ( x, y)] is the distance from (i, j) to ( x , y) . In the following, we take pixel Pi in binary image a ij for example. Distance transformation aims to search out the nearest light point near Pi and calculate the distance between them: (4) D[(i, j), ( x, y)] (i  x ) 2  ( j  y) 2 If Pi is a light point, its nearest light point would be itself and consequently the value of its distance transformation is 0; If Pi is not a light point, then search for any light point among 4 pixels in 4-neighborhood of Pi. If there is at least one existing 4-neighborhood point then the distance between Pi and the light point is 1; On the other hand, if there is none out of the 4 pixels, proceed scanning and search within a contour region which is a square region of size (2r+1) (2r+1)(r=1,2, ,n-1) centered at Pi, and where r represents the distance from pixel in the center to the contour. Let r=1 then the contour region is 8-neighborhood and search is carried out counter-clockwise according to the sequence of points P0 , P1 , , P7 , P0 as shown in Fig.5. If there is no light point found in the contour region of size (2r+1) (2r+1) when r=1, then the side length of the search rectangle need to be expanded to form a contour region of size 5 5, that is r=2 in (2r+1) (2r+1). A new scanning and search is proceeded in this rectangle in direction shown in Fig.6, i.e. starting from P0 counter-clockwise as the arrows point to, P0 , P1 , , P14 , P15 in turn until back to P0. By the same token, if no light point has yet been found after finishing searching within the contour region of size 5 5, the rectangle would be expanded again by increasing the value of r, until the nearest light point is found and distance transformation is achieved. . MATERIALS AND METHODS
Fig. 5 search within contour region of size 3 3 centered at Pi.

P0 P1 P2 P3 P4

P15

P14

P13

P12 P11

Pi

P10 P9

P5

P6

P7

P8

Fig. 6 search within contour region of size 5

5 centered at Pi.

watershed algorithm, and add up the result to binary image obtained in step 2; Step6. Detect the edges of image obtained in step 5, and add the edges to original image to acquire a final segmentation result. . EXPERIMENT RESULT AND DISCUSSION

In our experiment, we apply the algorithm proposed in this paper to segment the dowel image. The method suggested follows these steps: Step1. Apply opening-closing filtering to the image with a structure element of size 3 3. Step2. Select a proper threshold for the filtered image and obtain a binary image, wherein the threshold is 0.45. Step3. Implement distance transformation depicted above, and then negate the result image. Step4. Calculate distance transformation to produce a new grayscale image; Step5. Segment the grayscale image employing negative

Fig.7 (a) is the original dowel image. Segmentation result directly using watershed algorithm is shown in Fig.7 (b) and from it we can find that serious over-segmentation makes the result meaningless. Figre7 (c) is segmentation result using watershed algorithm based on distance transform[4], and it is evident that the result is better than the one obtained by direct watershed algorithm, yet over-segmentation is still notable. Apply the method described in previous section to segment the dowel image shown in Fig.7 (a). The whole process is illustrated from Fig.8 (a) to Fig.8 (f), and from them we can see that the result is satisfactory, successfully segmenting each dowel out whatever its size, with nearly no over-segmentation existing. . CONCLUSIONS

Aiming at the limitation of watershed segmentation, this paper presents an algorithm of watershed transformation based on opening-closing operation and distance transform. It improves the classical watershed segmentation algorithm based on distance transform, overcoming over-segmentation. The experiment result demonstrates that this method for segmentation inherits the advantage of watershed algorithm based on

7647

(a)

(b)

(c)

Fig.7 (a) Original image; (b) Classical watershed segmentation algorithm; (c) Watershed segmentation based on distance transformation.

(a) Binary image

(b) Distance transformation

(c) Watershed lines of (b)

(d) Watershed segmentation of binary image

(e) Edge detection of (d)

(f) Final segmentation result

Fig.8 watershed segmentation based on opening-closing operation and distance transformation.

distance transform that it successfully segment out each dowel in the image bringing convenience to computer vision and auto-counting of dowels. It also overcome over-segmentation existed in traditional watershed segmentation preserving the original edges of each dowel in the image completely. REFERENCES
[1] XM Chen, GQ Guo, and MQ Liu, On infrared image segmentation algorithm based on watershed, Journal of Optoelectronics.laser, vol. 12, no. 10, pp. 1072-1075, 2001. SH Liu, LB Zeng, B Liu, and Y Fang, Separating algorithm for overlapping granule images, Computer Engineering, vol. 28, no. 2, pp. 198-199, 2002. XH Tang, Modified watershed based on recursive merging, Computer Engineering and Applications, vol. 41, no. 1, pp. 84-86, 2005. Ratael C.Gonzalez, Richard E. Woods, and Steven L.Eddins, Digital Image Processing Using Matlab. Prentice Hall, Upper Saddle River, Version 1.0, 2004. L Vincent, and P Soille, Watersheds in digital spaces: an efficient algorithm based on immersion simulations, IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 13, no. 6, pp. 583-589, 1991. S Beucher, Watershed, hierarchical segmentation and. waterfall algorithm, In Serra, J. and Soille, P., Mathematical. Morphology and Its

[7]

[8] [9]

[10]

[2]

[11]

[3] [4]

[12] [13] [14]

[5]

[15]

[6]

Applications to Image Processing, Kluwer. Academic Publishers, Netherlands, 1994, 171~203. FY Xie, ZG Jiang, and FG Zhou, Immune cell image segmentation based on mathematical morphology, Journal of Image and Graphics, vol.7, no. 11, pp. 1119-1122, 2002. ZM Ma, and CK Tao, Artificial object detection in natural background, Chinese Journal of Lasers, vol.27, no.3, pp. 237-242, 2000. L. Najman, and M. Schmitt, Geodesic saliency of watershed contours and hierarchical segmentation, IEEE Transaction on Pattern Analysis and Machine Intelligence, vol. 18, no. 12, pp. 1163-1173, 1998. A. Bleau, L J Leon, Watershed-based segmentation and region merging, Computer Vision and Image Understanding, vol. 77, no. 3, pp. 317-370, 2000. J.B. Roerdink, A. Meijster, The watershed transform: definition, algorithms and parallelization strategies, Fundamental Information, vol. 41, no.1, pp. 187-228, 2001. A Rosenfeld, J L Pfaltz, Sequential operations in digital picture processing, Journal of the ACM, vol. 13, no. 4, pp. 471-494, 1966. A Rosenfeld, J Pfaltz, Distance functions on digital picture, Pattern Recognition, vol. 1, no. 1, pp. 33-61, 1968. A FischlerM, P Barrett, An iconic transform for sketch completion and shape abstraction, Computer Graphics and Image Processing, vol.13, no. 3, pp. 334-360, 1980. QZ Ye, The signed Euclidean distance transform and its application, In: Proceeding of Ninth International Conference on Pattern Recognition, Rome, Italy, pp. 495-499, 1988.

7648

You might also like