开发者

Connected Component Labeling in C++

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.


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.


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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜