OpenCV的分组白色像素 [英] OpenCV grouping white pixels

查看:178
本文介绍了OpenCV的分组白色像素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经做了艰苦的工作,把我的iSight摄像头在我的MacBook成一个红外摄像头,将它转换,设置阈值等。现在有一个看起来像这样的图片:

I've done the hard work, turning my iSight camera on my MacBook into an infrared camera, converted it, set the threshold etc.. and now have an image that looks something like this:

alt文字

我现在的问题是;我需要通过分组白色像素知道有多少斑点是我的形象。我不想使用 cvBlob / cvBlobsLib ,我宁愿只是用的是已经在OpenCV中。

My problem is now; I need to know how many blobs are on my image by grouping the white pixels. I don't want to use cvBlob/cvBlobsLib, I'd rather just use what is already in OpenCV.

我的可以的通过为(阈值处理)检查触摸白色像素的像素和它们分组循环,但我猜有可能是来自OpenCV的做这个的非常简单的方法?

I can loop through the pixels and group them by checking for (thresholded) touching white pixels, but I'm guessing there is probably a really easy way of doing this from OpenCV?

我猜我不能使用 cvFindContours ,因为这会检索所有白色像素在一个大的阵列,而不是将它们分成组。谁能推荐一下吗? (注意,这些圈,距离小红外发光二极管发出的光)

I'm guessing I can't use cvFindContours as this will retrieve all the white pixels in one big array, rather than separating them into "groups". Could anyone recommend? (Note these are not circles, just the light emitted from little IR LEDs)

在提前非常感谢!
结果tommed

Many Thanks in advance!
tommed

推荐答案

循环通过图像寻找白色像素。当你遇到一个你使用 cvFloodFill 与像素作为种子。然后填充值递增为每个区域,使每个区域有不同的颜色。这就是所谓的标签

Loop through the image looking for white pixels. When you encounter one you use cvFloodFill with that pixel as seed. Then increment the fill value for every region so that each region has a different color. This is called labeling.

这篇关于OpenCV的分组白色像素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆