Hough Circle 中的参数表示什么以及如何知道使用什么值?

What do the parameters in Hough Circle signify and how to know what values to use?

在使用霍夫圆的过程中,我不太明白如何定义霍夫圆的参数?我什至不知道它们表示什么参数。据我所知

其余的参数我都没看懂。谁能帮我解释一下。

问得好!

这是 opencv-python 教程中的 HoughCircles() 函数示例。详细看一下

HoughCircles(image, method, dp, minDist[, param1[, param2[, minRadius[, maxRadius]]]]])

图片

这是您要从中检测圆圈的输入图像。强烈建议使用灰度图,因为HoughCircles()使用Canny()函数来检测图像中的边缘。

方法

这是用来求圆的数学公式。 HoughCircle 中唯一可用的公式是 cv2.HOUGH_GRADIENT,因此您别无选择,只能使用它。

dp

查看此答案 。如果您无法理解,请不要担心。霍夫变换是一个广泛的子集,如果你想知道这个变量是什么意思,我建议你更详细地研究它,但无论如何,这个变量应该在 0 到 2 之间并且是双精度类型,所以尝试使用像 0.6 或 1.3 这样的数字.

最小距离

这是要检测的圆心之间的最小距离。您图像中的圆圈有多近?您希望该功能检测紧密连接的圆圈还是圆圈之间的距离?

参数 1 和参数 2

如前所述,HoughCircles() 内部使用 Canny() 函数。这些参数指定您想要检测边缘的积极程度。

The thresholder used in the Canny operator uses a method called "hysteresis". Most thresholders used a single threshold limit, which means if the edge values fluctuate above and below this value the line will appear broken (commonly referred to as ``streaking''). Hysteresis counters streaking by setting an upper and lower edge value limit. Considering a line segment, if a value lies above the upper threshold limit it is immediately accepted. If the value lies below the low threshold it is immediately rejected. Points which lie between the two limits are accepted if they are connected to pixels which exhibit strong response.

最小半径和最大半径

圆的大小用它的半径表示。半径越大,圆越大,反之亦然。这些参数指定要检测的圆的大小范围。

终于

当您使用 HoughCircles() 和其他类似函数时,您将花费大量时间调整这些参数以找到最佳数字组合来检测图像中的圆圈。因此,如果您认为参数有误,请不要沮丧。