Watershed Segmentation is resulting in more segments than necessary. How can I change this?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a ground truth image and I want to find its skeleton points and from these skeleton points I want to use watershed to recreate the ground truth image.
The problem is, when I use bwmorph(skel), the skeleton points touch each other and it results in an under segmented image. I tried to erode the image before I find the skeleton points, and this resulted in oversegmentation. The code and images are below:
img = imread('181091.jpg');
img = double(img);
seg = readSeg('181091.seg');
R = img(:,:,1);
G = img(:,:,2);
B = img(:,:,3);
[GxR,GyR] = gradient(R);
[GxG,GyG] = gradient(G);
[GxB,GyB] = gradient(B);
Grad = sqrt(GxR.^2 + GyR.^2 + GxG.^2 + GyG.^2 + GxB.^2 +GyB.^2);
img_skel = 0;
for i = 1:max(max(seg))
seg_sel = seg==(i);
seg_sel = imerode(seg_sel,ones(3,3));
img_skel1 = bwmorph(seg_sel,'skel',inf);
img_skel = img_skel + img_skel1;
end
figure, imagesc(img_skel)
watersh = imimposemin(Grad,img_skel);
Labels = watershed(watersh);
Labels = label2rgb(Labels);
The ground truth has 6 segments:
However, my result (with imerode, bwmorph, imimposemin and watershed) has 14 segments:
I want to be able to have the same number of segments. What could I add or change in my code? If I don't use imerode, the image looks like this:
0 Kommentare
Antworten (1)
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!