title: How to filter small segments from image in OpenCV?
body: <p>I am printing the Contours in the following way:</p>
  
  <pre><code>std::vector&lt;std::vector&lt;cv::Point&gt; &gt; contours;
  std::vector&lt;cv::Vec4i&gt; hierarchy;
  cv::findContours( mask, contours, hierarchy, cv::RETR_CCOMP, cv::CHAIN_APPROX_TC89_KCOS);
  for ( size_t i=0; i&lt;contours.size(); ++i )
  {
      cv::drawContours( img, contours, i, Scalar(200,0,0), 1, 8, hierarchy, 0, Point() ); 
      cv::Rect brect = cv::boundingRect(contours[i]);
      cv::rectangle(img, brect, Scalar(255,0,0));
  }
  </code></pre>
  
  <p>Once I have a binnary image, I want to eliminate the smaller contours. Any suggestions on how to do so?</p>
  
  <p><strong>MY INPUT PICTURE:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/lXrBw.jpg" alt="enter image description here"></p>
  
  <p><strong>WHAT I WANT TO ACHIEVE:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/acTFy.png" alt="enter image description here"></p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I am trying to get rid of the smaller segments. Any hints?</p>