Equivalent Matlab Bwareaopen feature in OpenCV

Am I trying to find a similar or equivalent function to the Matlabs Bwareaopen " function in OpenCV?

In MatLab, Bwareaopen (Image, P) removes from the binary image all connected components (objects) that have less than P pixels.

In my 1-channel image, I just want to remove small areas that are not part of the larger ones? Is there a trivial way to solve this problem?

+5
source share
2 answers

Take a look at cvBlobsLib , it has functions to do what you want. In fact, the sample code on the first page of this link does exactly what you want, I think. Essentially, you can use CBlobResultto mark connected components in your binary image and then call Filterto exclude drops according to your criteria.

+3
source

There is no such function, but you can 1) find the contours 2) Find the area of โ€‹โ€‹the contours 3) filter all external contours with an area less than the threshold 4) Create a new black image 5) Draw on it the left contours 6) Lubricate it with the original image

0
source

All Articles