Eliminating small blobs leaving bigger ones intact
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.
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.
so your fear is , that the small 'pertubations' on your larger object will get eroded away, too ?
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 did you find an efficient way to solve your question ?
Not really, but I think a custom well-thought filter would do the trick.