Ask Your Question

Jon Snow's profile - activity

2015-06-23 08:39:45 -0600 commented answer Finding the pixel precise area of white blobs

Btw, I noticed that cv::floodfill runs about 10 times faster when I pass 0 instead of 4 (the default) for its "flags" parameter. It still returns the correct blob size!

The documentation states: Operation flags. The first 8 bits contain a connectivity value. The default value of 4 means that only the four nearest neighbor pixels (those that share an edge) are considered. A connectivity value of 8 means that the eight nearest neighbor pixels (those that share a corner) will be considered. The next 8 bits (8-16) contain a value between 1 and 255 with which to fill the mask (the default value is 1). For example, 4 | ( 255 << 8 ) will consider 4 nearest neighbours and fill the mask with a value of 255.

2015-06-22 08:59:34 -0600 answered a question Finding the pixel precise area of white blobs

Thanks guys! I think I will use floodfill for really small blobs where precision is important to me and findContours for the larger ones. This twofold solution may not be elegant, but it is precise enough for me, it's reasonably fast and above all very easy to implement!

2015-06-16 07:00:40 -0600 received badge  Student (source)
2015-06-16 04:53:06 -0600 commented question Finding the pixel precise area of white blobs

Thanks a lot boaz001, I like your answer because it's so simple. ;-) Indeed, this seems to work perfectly, why on earth is this undocumented?

The only downside to this approach is speed. Some of my images are huge (4096 x 10000 is not uncommon) and it can take up to 1000 ms to floodfill all blobs, which is unacceptable in my case.

Does anyone know of a more performant solution?

2015-06-16 03:52:48 -0600 asked a question 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:

http://abload.de/img/partkgs9p.png

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!