title: findContours(OpenCV) vs. regionprops(Matlab)
body: <p>My final purpose is to calculate moments of all connected regions in image.</p>
  
  <p>Problem: Regions storage methods in OpenCV and Matlab are different. It is clear that moments of regions and contours are different too.</p>
  
  <p>So if I want to get result of extracting regions in Matlab:</p>
  
  <pre><code>test = imread('test.bmp');    
  l = bwlabel(test, 8);
  </code></pre>
  
  <p>it is necessary follow code (OpenCV):</p>
  
  <pre><code>vector&lt;vector&lt;Point&gt;&gt; contours; 
  vector&lt;Vec4i&gt; hierarchy;
  
  Mat test = imread("..\\test.bmp", CV_LOAD_IMAGE_UNCHANGED);
  findContours(test , contours, hierarchy, CV_RETR_CCOMP , CV_CHAIN_APPROX_NONE);
  for ( int i = 0; i &lt; contours.size(); i++ )
  {
      if (hierarchy[i][3] &gt; -1)
                 continue;
      Mat imProcessing = Mat::zeros(test .size(), test .type());
      drawContours(imProcessing, contours, i, Scalar(255), CV_FILLED, 8, hierarchy, 1);
  // now imProcessing contain connected region, not contour!
  }
  </code></pre>
  
  <p>Is there a more efficient way?</p>