Contours opencv : How to eliminate small contours in a binary image

c, c++, image-processing, opencv, visual-c++

Solution

Ok, I believe your problem could be solved with the bounding box demo recently introduced by OpenCV.

As you have probably noticed, the object you are interested at should be inside the largest rectangle draw in the picture. Luckily, this code is not very complex and I'm sure you can figure it all out by investigating and experimenting with it.

Problem

I am currently working on image processing project. I am using Opencv2.3.1 with VC++. I have written the code such that, the input image is filtered to only blue color and converted to a binary image. The binary image has some small objects which I don't want. I wanted to eliminate those small objects, so i used openCV's `cvFindContours()` method to detect contours in Binary image. but the problem is I cant eliminate the small objects in the image output. I used `cvContourArea()` function , but didn't work properly.. , erode function also didn't work properly. So please someone help me with this problem.. The binary image which I obtained : The result/output image which I want to obtain :

Original source