Here’s connected component labelling code in C++ / OpenCV, that I whipped up, since I needed it for some other project and OpenCV doesn’t have it. Might as well just post it here for everyone.
Update: I added extra functions to find the component’s properties, such as area, centroid, and eccentricity, mostly based on the image moments derived from the blob.
It’s based on the two pass algorithm described here: http://en.wikipedia.org/wiki/Connected-component_labeling. Not the best algorithm, but fast enough, and works for what I needed, I’ll probably improve it when it’s required.
Here are some of the sample results:
Get the full code along with the examples here: https://github.com/subokita/Sandbox/tree/master/ConnectedComponent