问题
I followed the 2-D Watershed example in Mathworks.com to separate the connected objects, like the image below:
The code is summarize as:
bw = imread('some_binary_image.tif');
D = -bwdist(~bw);
D(~bw) = -Inf;
L = watershed(D);
The result is:
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:
Using chessboard will result in:
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...
回答1:
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:
回答2:
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.
来源:https://stackoverflow.com/questions/20622368/over-segmentation-of-watershed-algorithm