|
|
Remove small objects from binary image without erode.
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
|
|
0
|
|
|
|
Reply
|
Ironic
|
12/16/2009 12:17:03 AM |
|
On Dec 15, 7:17=A0pm, "Ironic Prata" <lixodoiro...@hotmail.com> wrote:
> 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. Plann=
ing on using region props and check each area region, but that seems slow a=
nd inefficient...
>
> Tks
---------------------------------------------------------------------------=
---------------------------------------------------------------------------=
------------------------------------
You can use bwareaopen(). Despite the name it doesn't use a
morphological opening, but rather uses the regionprops method, that
you want to avoid. I don't know of any faster methods. Why do you
say it's slow? It doesn't seem slow when I use it - just takes a
fraction of a second. How large are your images, how many blobs are
in them, and how long is it taking on your computer? Maybe you can
get a faster computer.
|
|
0
|
|
|
|
Reply
|
ImageAnalyst
|
12/16/2009 1:35:59 AM
|
|
ImageAnalyst <imageanalyst@mailinator.com> wrote in message <99896c54-e824-4fc6-9b92-3eb8fa8c7704@x20g2000vbn.googlegroups.com>...
> On Dec 15, 7:17?pm, "Ironic Prata" <lixodoiro...@hotmail.com> wrote:
> > 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
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> You can use bwareaopen(). Despite the name it doesn't use a
> morphological opening, but rather uses the regionprops method, that
> you want to avoid. I don't know of any faster methods. Why do you
> say it's slow? It doesn't seem slow when I use it - just takes a
> fraction of a second. How large are your images, how many blobs are
> in them, and how long is it taking on your computer? Maybe you can
> get a faster computer.
the problem is that this is to be used in a loop, so i want efficiency.
but at least that function will clear up the code. tks
|
|
0
|
|
|
|
Reply
|
Ironic
|
12/16/2009 2:28:03 AM
|
|
On Dec 15, 9:28=A0pm, "Ironic Prata" <lixodoiro...@hotmail.com> wrote:
> the problem is that this is to be used in a loop, so i want efficiency.
> but at least that function will clear up the code. tks
---------------------------------------------------------------------------=
----------------------
You're implying that the bwareaopen function is inefficient. What's
the basis for saying that? Do you have a more efficient method? Why
is this method too slow for you? Again, what kind of speed do you
require and what kind of speed are you getting?
|
|
0
|
|
|
|
Reply
|
ImageAnalyst
|
12/16/2009 2:54:06 AM
|
|
Hi
Other possibility, aside the suggestion made by ImageAnalyst, is to use a small median filter. You can "efficiently" apply it multiple times in a loop.
Igor
"Ironic Prata" <lixodoironic@hotmail.com> wrote in message <hg98tv$2m$1@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
|
|
0
|
|
|
|
Reply
|
Novae
|
12/18/2009 4:54:04 PM
|
|
"Ironic Prata" <lixodoironic@hotmail.com> wrote in message <hg98tv$2m$1@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! ;)
|
|
0
|
|
|
|
Reply
|
Simone
|
4/13/2010 2:00:26 PM
|
|
|
5 Replies
1026 Views
(page loaded in 0.195 seconds)
|
|
|
|
|
|
|
|
|