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; endend
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
Best Answer