How to remove the small blobs?
I want to erase the small white spots areas to keep the largest area (white colour) in the picture:
Before
I used findContours and found the largest area then used drawContours. I got the following result:
My code
findContours(image, vtContours, vtHierarchy, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);
for (int i = 0; i < vtContours.size(); i++)
{
double area = contourArea(vtContours[i]);
if (area <= 100) {
continue;
}
// Get only one
if (area > dMaxArea)
{
dMaxArea = area;
nSavedContour = i;
}
}
if (nSavedContour == -1)
{
return false;
}
image = Scalar::all(0);
drawContours(image, vtContours, nSavedContour, Scalar(255), CV_FILLED, 8);
Can you show me the other idea or my fault? Thank for supporting!