cv :: HoughCircles中的dp参数如何工作? [英] How exactly does dp parameter in cv::HoughCircles work?

查看:148
本文介绍了cv :: HoughCircles中的dp参数如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读了类似的

I read similar question in Stack Overflow. I tried, but I still can not understand how it works.

我阅读了OpenCV文档 cv :: HoughCircles ,这是有关dp参数的一些解释:

I read OpenCV document cv::HoughCircles, here are some explanation about dp parameter:

累加器分辨率与图像分辨率的反比.例如,如果dp = 1,则累加器具有与输入图像相同的分辨率.如果dp = 2,则累加器的宽度和高度是其一半.

Inverse ratio of the accumulator resolution to the image resolution. For example, if dp=1 , the accumulator has the same resolution as the input image. If dp=2 , the accumulator has half as big width and height.

这是我的问题.例如,如果dp = 1,则累加器的大小与图像相同,则图像中的像素与累加器中的位置之间存在一对一的一致匹配,但是如果dp = 2,则如何匹配?

Here are my question. For example, if dp = 1, the size of accumulator is same as image, there is a consistent one-to-one match between pixels in image and positions in accumulator, but if dp = 2, how to match?

谢谢.

推荐答案

这里没有一对一匹配的东西.您确实有一个带有像素和hough空间的图像,用于对圈子进行投票.此参数只是指定相对于图像大小的hough空间大小的便捷方法.

There is no such thing as a one-to-one match here. You do have an image with pixels and a hough space, which is used for voting for circles. This parameter is just a convenient way to specify the size of the hough space relatively to the image size.

请查看以下

Please take a look at this answer for more details.

您的图像具有(x,y)坐标.圆的hough空间具有(a,b,r)坐标,而(a,b)是圆心,而r是半径.假设您找到一个边缘像素.现在,您可以为每个圆圈投票,该圆圈可能会穿过该边缘像素.我发现一张很好的哈夫空间图片投票,即边缘像素(连续的情况).实际上,这种投票发生在3D累加器矩阵内.您可以将其视为此连续案例的栅格化.

Your image has (x,y)-coordinates. Your circle hough space has (a,b,r)-coordinates, whereas (a,b) are the circle centers and r are the radii. Let's say you find a edge pixel. Now you vote for each circle, which could go through this edge pixel. I found this nice picture of hough space with a single vote i.e. a single edge pixel (continuous case). In practice this vote happens within the 3D accumulator matrix. You can think of it as rasterization of this continuous case.

现在,如前所述,dp参数定义了相对于图像大小的此累加器矩阵的大小. dp参数越大,栅格化的分辨率越低.这就像以不同的分辨率拍照.如果您缩小照片的尺寸,则多个像素将减少为一个像素.如果减少累加器矩阵并分别增加dp参数,也会发生相同的情况.现在,合并了不同圆心(彼此相邻)和半径(大小相似)的多个选票,即,您确实获得了较不准确的圆参数,但投票更加稳健".

Now, as already mentioned the dp parameter defines the size of this accumulator matrix relatively to your image size. The bigger the dp parameter the lower the resolution of your rasterization. It's like taking photos with different resolutions. If you downsize your photo multiple pixels will reduce to a single one. Same happens if you reduce your accumulator matrix respectively increase your dp parameter. Multiple votes for different circle centers (which lie next to each other) and radii (which are of similar size) are now merged, i.e. you do get less accurate circle parameters, but a more "robust" voting.

请注意,OpenCV的实现稍微复杂一些(它们使用Hough梯度方法而不是标准的Hough变换),但注意事项仍然适用.

Please be aware that the OpenCV implementation is a little bit more complicated (they use the Hough gradient method instead of the standard Hough transform) but the considerations still apply.

这篇关于cv :: HoughCircles中的dp参数如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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