Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Finding the pixel precise area of white blobs

Dear OpenCV community,

I'm fairly new to OpenCV and I need to find the pixel precise area of white blobs in images similar to this one:

I know by now that the results returned by findCountours(...) and a subsequent call to contourArea(...) are only an approximation. (I'm passing CV_CHAIN_APPROX_NONE to the findCountours method, if this is of any relevance...)

An example of my problem: The result returned by contourArea(...) for the blob with the red bounding box is 28, but the number of white pixels is 38. How can I obtain this number in OpenCV? I know about cv::countNonZero, but in some of my images white blobs overlap with the bounding rectangle of neighbouring blobs, making it impossible to extract a rectangular ROI for said function. So, what would be the best course of action to measure the blob area as precisely as possible?

Thanks in advance for any help you are able to provide!