title: Remove small areas with OpenCV in C++
body: <p>I managed to do what I need with Python code I found on Stack Overflow:</p>
  
  <pre><code>gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
  labelnum, labelimg, contours, GoCs = cv2.connectedComponentsWithStats(gray)
  for label in xrange(1, labelnum):
      x,y,w,h,size = contours[label]
      if size &lt;= N:
           img_white[y:y+h, x:x+w] = 0
  cv2.imwrite("img_filter.png", img_white)
  </code></pre>
  
  <p>It managed to remove small areas (small blobs and particles) by accessing contours elements.  </p>
  
  <p>I want to do this in C++. Is it possible? I have found this function: </p>
  
  <pre><code>int connectedComponentsWithStats(InputArray image, OutputArray labels, OutputArray stats, OutputArray centroids, int connectivity=8, int ltype=CV_32S)
  </code></pre>
  
  <p>But I don't see how to access the contours elements. 
  Any tip?</p>