From: Simone on
"Ironic Prata" <lixodoironic(a)hotmail.com> wrote in message <hg98tv$2m$1(a)fred.mathworks.com>...
>
> Is there a function that removes objects binary image based only on their pixel area?
>
> I want to maintain lines, so erode or close is out of the question. Planning on using region props and check each area region, but that seems slow and inefficient...
>
> Tks

Like this:

stats = regionprops(binary, 'Area', 'PixelIdxList');
cleaned = binary;
for region = 1 : length(stats)
if stats(region).Area < MIN_AREA
cleaned(stats(region).PixelIdxList) = 0;
end
end

I can guarantee this is REALLY fast! ;)