4

I need to use the connected component labeling algorithm on an image in a C++ application. I can implement that myself, but I was trying to use Boost's union-find/disjoint sets implementation since it was mentioned in the union-find wiki article.

I can't figure out how to create the disjoint_sets object so that it'll work with the image data I have (unsigned shorts). What am I missing? The examples in the Boost documentation aren't making any sense to me. Do I need all the extra Graph mumbo-jumbo in those examples when I have an image? OR, is there already an OpenCV connected component labeling implementation. Currently we're using OpenCV 1.1pre1 and Boost 1.37.

Jay Sheridan
  • 668
  • 8
  • 15

4 Answers4

3

Surprisingly, there is no CCL in OpenCV. However, there is a workaround that is described in the reference manual. See the example for cvDrawContours. When I tried to use it, I had some strange behaviour on first and last rows and columns of an image, but I probably did something wrong.

An alternative way is to use cvBlobs library.

Roman Shapovalov
  • 2,785
  • 1
  • 25
  • 30
  • The example with cvDrawContours is not quite what I'm looking for. The cvBlobs library might be, but I'm not sure if we want to add another library for this yet. I'll keep it in mind though. Thanks. – Jay Sheridan Jan 29 '10 at 19:11
1

Another possibility is to use the source codes provided provided by Ali Rahimi, and you can have a look at this.

feelfree
  • 11,175
  • 20
  • 96
  • 167
1

We ended up writing the algorithms for CCL and Union-Find ourselves using the descriptions found on Wikipedia and elsewhere. It seemed easier and faster than adding another library to our application just for this purpose.

Jay Sheridan
  • 668
  • 8
  • 15
0

I was able to use disjoint_sets of the boost library for the connected component labeling. But to test, I was trying to create an image with pixel intensities having the value same as its label. This led to the problem which I haven't been able to handle yet. Have a look at the thread.

Community
  • 1
  • 1
Kaushik Acharya
  • 1,520
  • 2
  • 16
  • 25