Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Over-segmentation of Watershed algorithm

I followed the 2-D Watershed example in Mathworks.com to separate the connected objects, like the image below:

Imgur

The code is summarize as:

bw = imread('some_binary_image.tif');

D = -bwdist(~bw);

D(~bw) = -Inf;

L = watershed(D);

The result is:

Imgur

The particle in the center has been separated into two. Are there any ways to avoid the over-segmentation here?

Thanks, lennon310, chessboard does work well for most of my images, but there are still some cases that it doesn't. For example, the following binary image: Imgur

Using chessboard will result in: Imgur

As I have hundreds of images, it seems that it is difficult to find one combination of parameters that work for all images. I am wondering if I need to combine the good results got from using chessboard, cityblock, etc...

like image 302
shapeare Avatar asked Dec 16 '13 22:12

shapeare


2 Answers

Use max(abs(x1-x2),abs(y1-y2)) as the distance metric (chessboard), and use eight-connected neighborhood in watershed function:

bw=im2bw(I);

D = -bwdist(~bw,'chessboard');
imagesc(D)
D(~bw) = -Inf;

L = watershed(D,8);
figure,imagesc(L)

Result: enter image description here

like image 64
lennon310 Avatar answered Sep 18 '22 22:09

lennon310


I have been dealing with the same issue for a while. For me, the solution was to use a marker based watershed method instead. Looks for examples on watershed method given on the Matlab Blog by Steve: http://blogs.mathworks.com/steve/ This method given by him worked best for me: http://blogs.mathworks.com/steve/2013/11/19/watershed-transform-question-from-tech-support/

Now, in an ideal world, we would be able to segment everything properly using a single method. But watershed does over or under-segment some particle, no matter which method you use (unless you manually give the markers). So, currently I am using a semi-automatic segmentation method; i.e., use watershed to segment the image as best as possible, and then take that image into MSPaint and edit it manually to correct whatever under/over-segmentation remains.

Region growing seems to have been used by some people in the past. But my image processing knowledge is limited so I can't help you out with that. It would be great if anyone could post something about how to use region-growing to segment such an image.

Hope this helps.

like image 41
bhisharma72 Avatar answered Sep 17 '22 22:09

bhisharma72