title: Calculating image pixel values (e.g. the mean) of Contour-inliers using mask & ROI in OpenCV
body: <p><strong>The problem</strong><br>
  I want to calculate the mean value of the pixel values belonging to a contour given as a vector of Points in OpenCV. The image is rather big compared to the contour, so I would like to first set a ROI as big as the bounding box of the contour and do the masking afterwards. However, this does not really work and I get zeros as result for mean calculation.</p>
  
  <p><strong>The code with line numbers</strong></p>
  
  <pre><code>1)  Mat crop = Mat(*img, bounding_box); //img is the original image (may be 1024*1024)  
  2)  Mat mask = Mat::zeros(crop.rows, crop.cols, CV_8UC1); //the mask with the size of cropped image  
  3)  vector&lt;vector&lt;Point&gt; &gt; contours;  
  4)  contours.push_back(*cv_contour);   
  5)  drawContours(mask, contours, -1, Scalar(255), CV_FILLED, CV_AA, noArray(), 1, bounding_box.tl());   
  6)  double mean_ = sum(mean(crop, mask))[0]; // returns wrong results (0)
  </code></pre>
  
  <p>Btw: Is there a way to avoid the creation of a new array (line 3&amp;4) for <code>drawContours</code> if I only want to draw ONE contour?</p>