C++ 中的连接组件标签
我需要在 C++ 应用程序中的图像上使用 连接组件标签 算法.我可以自己实现,但我试图使用 Boost 的 union-find/disjoint sets 实现,因为它在 union-find wiki 中被提及文章.
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.
我不知道如何创建 disjoint_sets 对象,以便它可以处理我拥有的图像数据(无符号短裤).我错过了什么?Boost 文档中的示例对我来说没有任何意义.当我有图像时,我是否需要这些示例中所有额外的 Graph mumbo-jumbo?或者,是否已经有 OpenCV 连接组件标签实现.目前我们正在使用 OpenCV 1.1pre1 和 Boost 1.37.
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.
推荐答案
奇怪的是,OpenCV 中没有 CCL.但是,参考手册中描述了一种解决方法.请参阅 cvDrawContours 的示例.当我尝试使用它时,我在图像的第一行和最后一行和最后一列有一些奇怪的行为,但我可能做错了什么.
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.
另一种方法是使用 cvBlobs 库.
An alternative way is to use cvBlobs library.
相关文章