get pixel index from region props
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
majed majed
el 12 de Jun. de 2015
Comentada: Image Analyst
el 9 de Abr. de 2019
If someone help or try help to me ,I'll be so thankful : as shown in the image , I used 'regionprops' function to divide it into five regions. I want to copy any region (say the second region)from this image and put in a new image which has the same size as original image ,how can I get the pixel indices of that region . thank you.
2 comentarios
Benjamin Drewry
el 9 de Abr. de 2019
this is how I do it, but there are probably better ways. I.e. to separate out the 'jacket' region of the matlab provided pout image
img=imread('pout.tif');
mask=img>130;
bwlabel(mask);
figure(); imagesc(ans);
stats=regionprops(mask, 'all');
bkdg=zeros(img);
y=stats(25).PixelList(:,2);
x=stats(25).PixelList(:,1);
for i=1:length(I)
bkdg(y(i),x(i))=1;
end
figure(); imagesc(bkdg);
final=double(img).*bkdg;
figure(); imagesc(final);
Image Analyst
el 9 de Abr. de 2019
Benjamin, please fix the code (so it at least runs), and put it down in the official "Answers" section, not up here in the comments section where we ask posters for additional clarification.
Respuesta aceptada
Image Analyst
el 12 de Jun. de 2015
You can do that, but it's not the most efficient way, so I won't go into it (besides, it's more complicated). The way you want to do it is with ismember(). You use your labeled image and create the 5 new images with ismember
[labeledImage, numRegions] = bwlabel(binaryImage);
binaryRegion1 = ismember(labeledImage, 1) > 0;
binaryRegion2 = ismember(labeledImage, 2) > 0;
binaryRegion3 = ismember(labeledImage, 3) > 0;
binaryRegion4 = ismember(labeledImage, 4) > 0;
binaryRegion5 = ismember(labeledImage, 5) > 0;
3 comentarios
Image Analyst
el 17 de Jun. de 2015
majed's "Answer" moved here:
thanks a lot , your technique works good . but how can i remove any region from the original image and put in zeros image(with the same size as original one) in the same position(indices) as the original one.
Más respuestas (0)
Ver también
Categorías
Más información sobre Convert Image Type en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!