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 :**

**The result/output image which I want to obtain :**

but when I applied the above code, the result was

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.
↧