Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Suppose you already found the contour,

Then using the code,

 int min_area=500; // area threshold
 for( int i = 0; i< contours.size(); i++ ) // iterate through each contour.
 {
   double area=contourArea( contours[i],false);  //  Find the area of contour
   if(area<min_area)
    contours.erase(contours.begin() + i);
 }

you can iterate through contours and remove. I hope it will work.

Suppose you already found the contour, contours,

Then using the code,

 int min_area=500; // area threshold
 for( int i = 0; i< contours.size(); i++ ) // iterate through each contour.
 {
   double area=contourArea( contours[i],false);  //  Find the area of contour
   if(area<min_area)
    contours.erase(contours.begin() + i);
 }

you can iterate through contours and remove. I hope it will work.

Suppose you already found contours,

Then using the code,

 int double min_area=500; // area threshold
 for( int i = 0; i< contours.size(); i++ ) // iterate through each contour.
 {
   double area=contourArea( contours[i],false);  //  Find the area of contour
   if(area<min_area)
    contours.erase(contours.begin() + i);
 }

you can iterate through contours and remove. I hope it will work.