I use bwareaopen
to remove small objects. Is there a function to remove the big objects? I'm trying to adapt bwareaopen however haven't been successful so far. Thanks
For ref: Here's a link to the help of bwareaopen.
I use bwareaopen
to remove small objects. Is there a function to remove the big objects? I'm trying to adapt bwareaopen however haven't been successful so far. Thanks
For ref: Here's a link to the help of bwareaopen.
I found an easy way to tackle this problem described here:
"To keep only objects between, say, 30 pixels and 50 pixels in area, you can use the BWAREAOPEN command, like this:"
LB = 30;
UB = 50;
Iout = xor(bwareaopen(I,LB), bwareaopen(I,UB));
Another way if you don't want to use
bwareaopen
is to useregionprops
, specifically with theArea
andPixelIdxList
attributes, filter out the elements that don't conform to the area range you want, then use the remaining elements and create a new mask.Area
captures the total area of each shape whilePixelIdxList
captures the column major linear indices of the locations inside the image that belong to each shape. You would use theArea
attribute to perform your filtering while you would use thePixelIdxList
attribute to create a new output image and set these locations totrue
that are within the desired area range: