How can I show the objects found in segmentation?
Mostrar comentarios más antiguos
Hello, everyone,
I'm working on a segmentation code but what I'm missing is to know how can I plot/show the segments of the image I have found in another figure, this is the code I have so far:
I=imread('Prueba1.png');
%Show original image;
figure
imagesc(I)
colormap('gray')
axis equal
title('Imagen Original')
I=double(rgb2gray(I));
figure
imagesc(I)
colormap('gray')
axis equal
title('Imagen Escala Grises')
IN=255-I;
f=bwlabel(IN,8);
figure
imagesc(f)
colormap('gray')
axis equal
g=regionprops(f,'Area','Centroid','Image');
[r,c]=size(g);
sprintf('Total of Objects: %d',r)
[r1,c1]=size(f);
figure
for o=1:r
%This is something I was trying but it just shows all of the figures:
imagesc(g(o,1).Image)
colormap('gray')
axis equal
drawnow
end
I think that I have to find where it starts and then draw it there, but I'm not quite sure about this, do you know anyway of doing this?
Thanks for your help.
P.S. This is the image I'm working on:


What I want to do is to have another image similar to the Gray Scale image here but that as the program is running I can see it's plotting. Thanks again.
Respuesta aceptada
Más respuestas (1)
Image Analyst
el 24 de Mzo. de 2017
I just answered the question here: https://www.mathworks.com/matlabcentral/answers/331538-display-each-object-in-a-binary-image-separedtly#answer_260094
Again....
See my Image Segmentation Tutorial: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862&sort=downloads_desc
Or, simply use ismember() to extract the blob you want. For example
[L, num] = bwlabel(BW);
for k = 1 : num
thisBlob = ismember(L, k);
figure
imshow(thisBlob, []);
end
Categorías
Más información sobre Region and Image Properties en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!