views:

288

answers:

1

hi!

Im trying to find similar or equivalent funtion of Matlabs "Bwareaopen" function in OpenCV?

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

In my 1 channel image i want to simply remove small regions that are not part of bigger ones? Is there any trivial way to solve this?

Thank you!!

+1  A: 

Take a look at the cvBlobsLib, it has functions to do what you want. In fact, the code example on the front page of that link does exactly what you want, I think. Essentially, you can use CBlobResult to perform connected-component labeling on your binary image, and then call Filter to exclude blobs according to your criteria.

tzaman
thanks tzaman for quick answer and ur right cvBlobsLib is exactly what i need. but now the thing is Im not shure i can import those cvBlobsLib in my Xcode project (iPhone) libraries and i already had a lot of work even with importing opencv libs. Do you think i can just copy parts of code out of libs that i'll be needing?
Miha
I haven't actually used cvBlobsLib myself (or Xcode!), but it's distributed as source, so you should be able to just add all the `.cpp` and `.h` files to your project, `#include` the appropriate headers, and take it from there.
tzaman
Also, don't forget to accept / upvote the answer if it was helpful! :)
tzaman
No go for just including .cpp and .h files to project :(I guess i need version for mac though!
Miha