title: Contour area does not show all the relevant areas
body: <p>I am trying to identify all circles in an image. After enhancing contrast, use threshold, use canny edges I find all contours and loop through them, which ever has area>0 I present on the result image. The results are not good. Please assist...</p>
  
  <pre><code>#include &lt;opencv2/opencv.hpp&gt;
  
  using namespace cv;
  using namespace std;
  void changeGain(cv::Mat&amp;,double,int);
  
  
  int main(int argc, char** argv)
  {
  
  // Load the original image and make a duplication
  cv::Mat rawImage = cv::imread("..\\3.png");
  cv::Mat duplicateImage= rawImage.clone();
  
  // Add contrast
  changeGain(duplicateImage,1.9 ,-240);
  
  
  // Apply thershold
  cv::threshold( duplicateImage, duplicateImage, 150, 200, cv::THRESH_BINARY );
  
  
  // Use canny edges
  cv::Mat img_canny;
  cv::Canny(duplicateImage,img_canny,150,200);
  
  // Find all the contours from the canny image
  vector&lt;vector&lt;cv::Point&gt;&gt; contours;
  findContours(img_canny, contours, RETR_TREE, CHAIN_APPROX_SIMPLE);
  
  // Approximate contours to polygons + get circles
  vector&lt;vector&lt;Point&gt; &gt; contours_poly;
  
  for( int i = 0; i &lt; contours.size(); i++ )
  {
      double area = contourArea(contours[i],true);
      if (area &gt; 0 )
          contours_poly.push_back(contours[i]);
  }
  
  // Draw the circles on the image
  drawContours(rawImage, contours_poly, -1, Scalar(rand() &amp; 255, rand() &amp; 255, rand() &amp; 255));
  
  // Show result
  cv::imshow("Final Result", rawImage);
  cv::waitKey(0);
  imwrite("..\\contour_result.jpg",rawImage);
  
  }
  
  void changeGain(cv::Mat&amp; image,double alpha, int beta)
  {
  //cv::Mat new_image = cv::Mat::zeros( image.size(), image.type() );
  
   /// Do the operation new_image(i,j) = alpha*image(i,j) + beta
   for( int y = 0; y &lt; image.rows; y++ )
   {
       for( int x = 0; x &lt; image.cols; x++ )
       {
           for( int c = 0; c &lt; 3; c++ )
               image.at&lt;cv::Vec3b&gt;(y,x)[c] =
                       cv::saturate_cast&lt;uchar&gt;( alpha*( image.at&lt;cv::Vec3b&gt;(y,x)[c] ) + beta );
  
      }
   }
  
   return;
  </code></pre>
  
  <p>}</p>
  
  <p>This is the original image</p>
  
  <p><a href="https://i.stack.imgur.com/31Xjr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/31Xjr.png" alt="This is the original image"></a></p>
  
  <p>This is the result when showing all contours</p>
  
  <p><a href="https://i.stack.imgur.com/IAZyk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IAZyk.jpg" alt="This is the result when showing all contours"></a></p>
  
  <p>This is the result when showing only contours with area >0</p>
  
  <p><a href="https://i.stack.imgur.com/YGTmN.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YGTmN.jpg" alt="This is the result when showing only contours with area &gt;0"></a></p>
  
  <p>An image after thershold</p>
  
  <p><a href="https://i.stack.imgur.com/21eGW.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/21eGW.jpg" alt="An image after thershold"></a></p>
  
  <p><a href="https://i.stack.imgur.com/OEcM4.jpg" rel="nofollow noreferrer">Image after canny</a></p>