Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

How to eliminate small contours in a binary image?

$
0
0
I am currently working on image processing project. I am using Opencv 3.x.x with VC++. My code: Mat result; vector>contours; vectorhierarchy; int savedContour = -1; double maxArea = 0.0; // Find the largest contour findContours(binarayImage, contours, hierarchy, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE, Point()); for (int i = 0; i< contours.size(); i++) { double area = contourArea(contours[i]); if (area > maxArea) { maxArea = area; savedContour = i; } } // Create mask drawContours(result, contours, savedContour, Scalar(255), CV_FILLED, 8); **The binary image which I obtained :** ![image description](/upfiles/14829832527683783.jpg) **The result/output image which I want to obtain :** ![image description](/upfiles/14829832772776027.jpg) but when I applied the above code, the result was ![image description](/upfiles/14829836548278665.jpg) did not look like I expected. Help me! Thank you! P/s: I know this problem is caused by drawContours. But I have no way to fix it.

Viewing all articles
Browse latest Browse all 19555

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>