Ask Your Question
1

Eliminating small blobs leaving bigger ones intact

asked 2014-05-22 10:54:14 -0600

updated 2014-05-22 11:42:48 -0600

DISCLAIMER: I can NOT use morphological (i.e. erosions) operations or drawContours to solve this problem.

I'm trying to find an efficient solution to eliminate most small blobs in this image, leaving the big blobs absolutely intact.

Blobs

The first thing that comes to my mind is to create a custom 5x5 or 7x7 or 9x9 filter that identifies small isolated blobs, but I never had the need to use such kind of specific technique, so I don't know how I would build and apply such a filter.

EXAMPLE: If I have the following custom filter:

F = [-1 -1 -1 -1 -1 
     -1 25 25 25 -1
     -1 25 100 25 -1
     -1 25 25 25  -1
     -1 -1 -1 -1 -1]

Theoretically, if I pass this filter in an isolated 3x3 squared white blob, the value on that coordinate will be 25 + 25 + 25 + 25 + 100 + 25 + 25 + 25 = 300. So, where in the resulting matrix I have the value 300, I know that I have a 3x3 square white blob. But I'm trying to generate a more robust filter to handle all kind of small blobs (as you can see in the image bellow).

Any ideas will be welcomed.

DISCLAIMER: I can NOT use morphological (i.e. erosions) operations or drawContours to solve this problem.

edit retag flag offensive close merge delete

Comments

so your fear is , that the small 'pertubations' on your larger object will get eroded away, too ?

berak gravatar imageberak ( 2014-05-22 10:58:21 -0600 )edit

Some objects are very hard to detect, so I will need to apply morphological operations to increase the number of pixels to assure blob connectivity. First I need to remove this noise (without degrading existing objects) so then I have more freedom to apply dilate operations.

Pedro Batista gravatar imagePedro Batista ( 2014-05-22 11:05:32 -0600 )edit

@Pedro Batista did you find an efficient way to solve your question ?

sturkmen gravatar imagesturkmen ( 2015-12-06 14:12:45 -0600 )edit

Not really, but I think a custom well-thought filter would do the trick.

Pedro Batista gravatar imagePedro Batista ( 2015-12-09 04:41:38 -0600 )edit

3 answers

Sort by ยป oldest newest most voted
0

answered 2014-05-23 11:59:43 -0600

isarandi gravatar image

Connected Component Labeling may be a good solution here. Take a look at this implementation.

edit flag offensive delete link more
0

answered 2014-05-23 08:51:44 -0600

Goosebumps gravatar image

You state that you do not want to use morphological operations. I am assuming this is to keep the original shape identical. If so, you could still consider using opening by reconstruction. Have a look over here: opening-by-reconstruction

I don't know how to do it in OpenCV though. Anyone?

edit flag offensive delete link more

Comments

1

I'll try this one out. If you know how to apply imreconstruct in opencv please do tell :) cheerz

Pedro Batista gravatar imagePedro Batista ( 2014-05-26 09:37:06 -0600 )edit

(2 years later) Here is my python implementation.

nicholas.b.crews gravatar imagenicholas.b.crews ( 2016-08-07 18:41:11 -0600 )edit
0

answered 2014-05-22 12:29:44 -0600

You could use findContours to detect objects and remove objects of small area. To effectively remove them, you could use fillPoly to draw (into the mask) these objects.

edit flag offensive delete link more

Comments

That would mean that I had to iterate between hundreds of contours each frame, and I have high performance requirements. Contour approaches are to avoid.

Pedro Batista gravatar imagePedro Batista ( 2014-05-22 14:09:08 -0600 )edit

Question Tools

Stats

Asked: 2014-05-22 10:54:14 -0600

Seen: 9,801 times

Last updated: May 23 '14