Azzera filtri
Azzera filtri

Gain information about individual objects in an image

1 visualizzazione (ultimi 30 giorni)
I have a binary image which contains several separated regions. I want to put a threshold on the Area (number of pixels) that these regions occupy, in the way that: a region would be omitted if it has fewer pixels than the threshold. I already have tried these codes (using bwconncomp and labelmatrix):
[...]
% let's assume threshold = 50
CC = bwconncomp(my_image);
L = labelmatrix(CC);
A = cell( size(CC.PixelIdxList,1) , size(CC.PixelIdxList,2) );
A = CC.PixelIdxList;
for column = 1 : size(CC.PixelIdxList,2)
if numel(CC.PixelIdxList{column}) < 50, A{column} = 0;
end
end
But at this point I don't know how to convert cell C back to the shape of my image and then show it! Are there any tricks to do that?
Is there any easier and straighter way to gain information about objects in an image than this one I used in here?
I also need to know length and width (number of pixels in x and y direction) of these objects. These objects do not necessarily have any specific geometrical shape!
Thanks in advance

Risposta accettata

Image Analyst
Image Analyst il 13 Set 2013
Yes, Use Area rather than PixelIdxList. Then you can threshold on the areas and use ismember to filter objects based on their area. See my Image Segmentation Tutorial for an example of exactly that. Image Analyst File Exchange

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by