which output is the segmented image?

6 visualizzazioni (ultimi 30 giorni)
Gowsalya Arumugam
Gowsalya Arumugam il 25 Mar 2014
Commentato: Image Analyst il 26 Mar 2014
function wateralgo(img)
F=imread();
F=im2double(F);
%Converting RGB image to Intensity Image
r=F(:,:,1);
g=F(:,:,2);
b=F(:,:,3);
I=(r+g+b)/3;
imshow(I);
%Applying Gradient
hy = fspecial('sobel');
hx = hy';
Iy = imfilter(double(I), hy, 'replicate');
Ix = imfilter(double(I), hx, 'replicate');
gradmag = sqrt(Ix.^2 + Iy.^2);
figure, imshow(gradmag,[]), title('Gradient magnitude (gradmag)');
L = watershed(gradmag);
Lrgb = label2rgb(L);
figure, imshow(Lrgb), title('Watershed transform of gradient magnitude (Lrgb)');
se = strel('disk',20);
Io = imopen(I, se);
figure, imshow(Io), title('Opening (Io)');
Ie = imerode(I, se);
Iobr = imreconstruct(Ie, I);
figure, imshow(Iobr), title('Opening-by-reconstruction (Iobr)');
Ioc = imclose(Io, se);
figure, imshow(Ioc), title('Opening-closing (Ioc)');
Iobrd = imdilate(Iobr, se);
Iobrcbr = imreconstruct(imcomplement(Iobrd), imcomplement(Iobr));
Iobrcbr = imcomplement(Iobrcbr);
figure, imshow(Iobrcbr), title('Opening-closing by reconstruction (Iobrcbr)');
fgm = imregionalmin(Iobrcbr);
figure, imshow(fgm), title('Regional maxima of opening-closing by reconstruction (fgm)');
I2 = I;
I2(fgm) = 255;
figure, imshow(I2), title('Regional maxima superimposed on original image (I2)');
se2 = strel(ones(7,7));
fgm2 = imclose(fgm, se2);
fgm3 = imerode(fgm2, se2);
fgm4 = bwareaopen(fgm3, 20);
I3 = I;
I3(fgm4) = 255;
figure, imshow(I3), title('Modified regional maxima superimposed on original image (fgm4)');
bw = im2bw(Iobrcbr, graythresh(Iobrcbr));
figure, imshow(bw), title('Thresholded opening-closing by reconstruction (bw)');
D = bwdist(bw);
DL = watershed(D);
bgm = DL == 0;
figure, imshow(bgm), title('Watershed ridge lines (bgm)');
gradmag2 = imimposemin(gradmag, bgm | fgm4);
L = watershed(gradmag2);
I4 = I;
I4(imdilate(L == 0, ones(3, 3)) | bgm | fgm4) = 255;
figure, imshow(I4), title('Markers and object boundaries superimposed on original image (I4)');
Lrgb = label2rgb(L, 'jet', 'w', 'shuffle');
figure, imshow(Lrgb), title('Colored watershed label matrix (Lrgb)');
figure, imshow(I), hold on
himage = imshow(Lrgb);
set(himage, 'AlphaData', 0.3);
title('Lrgb superimposed transparently on original image');
the segmented image output should be taken to find out the shape features so i need to known which output to be taken....
  1 Commento
Walter Roberson
Walter Roberson il 25 Mar 2014
Which variable did you store the segmented image into when you wrote the code?

Accedi per commentare.

Risposte (1)

Image Analyst
Image Analyst il 25 Mar 2014
It looks like Marker controlled watershed segmentation as explained on this page: http://www.mathworks.com/help/images/examples/marker-controlled-watershed-segmentation.html
The variable L holds the segmented image. Each blob has it's own ID number in that image.
  3 Commenti
Walter Roberson
Walter Roberson il 26 Mar 2014
You do not need to segment the image before calculating the shape features. On the other hand, segmenting the image is one of the techniques that can be used to make it much easier to calculate the shape features.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by