霍夫圆全解析HoughCircles opencv python 应用

目标

use Hough Transform to find circles in an image
通过霍夫变换找到图片里的圆们

原理说明

  • A circle is represented mathematically as (x−xcenter)2+(y−ycenter)2=r2 where (xcenter,ycenter) is the center of the circle, and r is the radius of the circle. From equation, we can see we have 3 parameters, so we need a 3D accumulator for hough transform, which would be highly ineffective. So OpenCV uses more trickier method, Hough Gradient Method which uses the gradient information of edges.
  • 一个圆的数学表现是(x−xcenter)2+(y−ycenter)2=r2, 其中Xcenter,Ycenter是圆的中心坐标,r是圆的半径。通过这个问题,我们有三个参数,所以我们需要一个3D累加器来进行霍夫变换,这样的情况大多是无效的。Opencv使用了更为巧妙的方法,霍夫梯度方法使用了边缘的梯度信息。

python接口说明

Note重要提示

Usually the function detects the centers of circles well. However, it may fail to find correct radii. You can assist to the function by specifying the radius range ( minRadius and maxRadius ) if you know it. Or, you may set maxRadius to a negative number to return centers only without radius search, and find the correct radius using an additional procedure.
通常使用这个方案来识别圆的圆心是比较好的。然而,它并不适合来找到正确的半径。你可以通过制定若你已知的半径范围(最小半径、最大半径)来辅助这个方法。或者,你可设置最大半径到一个负数来仅返回中心并不进行半径搜索,从而使用附加的处理来找到正确的半径。

Parameters指标说明

image 8-bit, single-channel, grayscale input image.
circles Output vector of found circles. Each vector is encoded as 3 or 4 element floating-point vector (x,y,radius) or (x,y,radius,votes) .
method Detection method, see HoughModes. Currently, the only implemented method is HOUGH_GRADIENT
dp 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.
minDist Minimum distance between the centers of the detected circles. If the parameter is too small, multiple neighbor circles may be falsely detected in addition to a true one. If it is too large, some circles may be missed.
param1 First method-specific parameter. In case of HOUGH_GRADIENT , it is the higher threshold of the two passed to the Canny edge detector (the lower one is twice smaller).
param2 Second method-specific parameter. In case of HOUGH_GRADIENT , it is the accumulator threshold for the circle centers at the detection stage. The smaller it is, the more false circles may be detected. Circles, corresponding to the larger accumulator values, will be returned first.
minRadius Minimum circle radius.
maxRadius Maximum circle radius. If <= 0, uses the maximum image dimension. If < 0, returns centers without finding the radius.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值