From: Image Analyst on
"Anh son" <pason2009(a)yahoo.de> wrote in message <hgatc7$rh8$1(a)fred.mathworks.com>...
> Is that what u need?
> help bwareaopen
> BWAREAOPEN Morphologically open binary image (remove small objects).
> Hope that it helps.
> Son
-------------------------------------------------------------------
I know that's what it's documentation says, but that's not the way it does it. If you look at the code for bwareaopen, it essentially labels the objects and calculates the number of pixels in each object, then it removes objects with less than the prescribed number of objects. It does not do it by doing a morphological opening (which would not retain the exact shapes of the original blobs), nor does it do it by a morphological erosion followed by a morphological reconstruction (which would retain shapes). This latter way is one way to do it so I guess that the labeling way must be faster most of the time. Maybe it used to be done via morphological opening but they changed when they realized that way would change the shape of the retained blobs, hence the "open" in the name. I'm not sure why they didn't correct the documentation to reflect the actual way it appears to be done. The
way bwareaopen actually works is essentially like what us said - it labels, regionprops, and then filters based on size (you can use ismember() for this). In fact if you're going to eventually label and call regionprops, you woudn't want to call bwareopen, because then you'd be doing the labeling twice.