C++ opencv remove small areas : I managed to do what I need by finding a python code (I found it in stackexchange):

 <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 <= N:
             img_white[y:y+h, x:x+w] = 0
cv2.imwrite("img_filter.png", img_white)
   </code>

It managed to remove small areas (small blobs and particles) by accessing contours elements.  

I want to do it for C++. Is it possible? I found this function: 

<code>
int connectedComponentsWithStats(InputArray image, OutputArray labels, OutputArray stats, OutputArray centroids, int connectivity=8, int ltype=CV_32S)</code>

But I don't see how to access the contours elements. 
Any tip?