how to repeat watershed transform to improve separation

4 views (last 30 days)
I have small circle touching objects which need to be separated and analyzed. I've read Watershed transform question from tech support by Mr. Eddins. In the information he said if it's needed repeat the steps. I'm not sure how to repeat the steps. I wrote repeating steps but it still not working accurately. Here is my code. If anyone can help me to figure out where I made a mistake or how I can improve separation, I'll be really appreciate it. Thank you
bw2b = ~bwareaopen(~BWsegmentationb,10);
figure(); imshow(bw2b)
Db = -bwdist(~BWsegmentationb);
figure(); imshow(Db,[])
Ldb = watershed(Db);
figure(); imshow(label2rgb(Ldb))
bw2b = BWsegmentationb;
bw2b(Ldb == 0) = 0;
figure(); imshow(bw2b)
maskb = imextendedmin(Db,2);
firstwatershedpriim= imshowpair(BWsegmentationb,maskb,'blend')
% Home stretch, now. Modify the distance transform so it only has minima at the desired locations, and then repeat the watershed steps above.
firstwatershed= firstwatershedpriim.CData;
firstwatershedbw= imbinarize(firstwatershed);
firstwatershedbw2 = ~bwareaopen(~firstwatershedbw,10);
figure(); imshow(firstwatershedbw2)
Db2 = -bwdist(~firstwatershedbw);
figure(); imshow(Db2,[])
Ldb2 = watershed(Db2);
figure(); imshow(label2rgb(Ldb2))
firstwatershedbw2 = firstwatershedbw;
firstwatershedbw2(Ldb2 == 0) = 0;
figure(); imshow(firstwatershedbw2)
maskb2 = imextendedmin(Db2,2);
figure(); imshowpair(firstwatershedbw,maskb2,'blend')
D2b = imimposemin(Db2,maskb2);
Ld2b = watershed(D2b);
bw3b = BWsegmentationb;
bw3b(Ld2b == 0) = 0;
figure(); imshow(bw3b)

Answers (0)




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!