MATLAB Answers

The Watershed Transform::separate objects::please help

9 views (last 30 days)
mangood UK
mangood UK on 18 Jul 2013
i try to use Watershed Transform to separate touching objects
i read The Watershed Transform: Strategies for Image Segmentation
By Steve Eddins, MathWorks
i follow exact his code as below but no result i get
i think their a basic error in code
------------generate toching object-------
center1 = -10;
center2 = -center1;
dist = sqrt(2*(2*center1)^2);
radius = dist/2 * 1.4;
lims = [floor(center1-1.2*radius) ceil(center2+1.2*radius)];
[x,y] = meshgrid(lims(1):lims(2));
bw1 = sqrt((x-center1).^2 + (y-center1).^2) <= radius;
bw2 = sqrt((x-center2).^2 + (y-center2).^2) <= radius;
bw = bw1 | bw2;
imshow(bw), title('bw');
%----------------separate object------------
D = ~bwdist(~bw);
BW(L == 0) = 0;
title('Distance transform of ~bw')


Sign in to comment.

Accepted Answer

Iain on 18 Jul 2013
Should BW be bw?


mangood UK
mangood UK on 18 Jul 2013
same problem no result
can you test it for me
Jeff E
Jeff E on 18 Jul 2013
You've got a few steps wrong, and are missing a few in the middle.
doc watershed - example 1 has basically the same code and works for me. You should just be able to copy and paste to replicate. If you have an older version of Matlab, you can find it on the web:
mangood UK
mangood UK on 18 Jul 2013
it work
but i test it with another image look to the result
why the cycle was separated ??? do this need any processing to solve it

Sign in to comment.

More Answers (0)

Sign in to answer this question.