Hough transform霍夫变换

霍夫变换是一种用于图像处理的技术,常用于检测简单形状,如直线、圆或椭圆。通过将图像中的边缘点转换到参数空间,进行投票过程来识别对象。对于直线检测,霍夫变换使用极坐标系统(ρ, θ)表示直线,通过找到对应点的正弦曲线交点来确定共线点对应的直线参数。这种方法将寻找共线点的问题转化为寻找并发曲线,从而有效检测图像中的线条。" 139614140,167949,Ollama框架下运行Llama3 AI模型完全指南,"['人工智能', '自然语言处理', '模型部署', 'Docker容器', '预训练模型']

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Theory[edit]

In automated analysis of digital images, a subproblem often arises of detecting simple shapes, such as straight lines, circles or ellipses. In many cases an edge detector can be used as a pre-processing stage to obtain image points or image pixels that are on the desired curve in the image space. Due to imperfections in either the image data or the edge detector, however, there may be missing points or pixels on the desired curves as well as spatial deviations between the ideal line/circle/ellipse and the noisy edge points as they are obtained from the edge detector. For these reasons, it is often non-trivial to group the extracted edge features to an appropriate set of lines, circles or ellipses. The purpose of the Hough transform is to address this problem by making it possible to perform groupings of edge points into object candidates by performing an explicit voting procedure over a set of parameterized image objects (Shapiro and Stockman, 304).

The simplest case of Hough transform is the linear transform for detecting straight lines. In the image space, the straight line can be described as y = mx + b where the parameter m is the slope of the line, and b is the intercept (y-intercept). This is called the slope-intercept model of a straight line. In the Hough transform, a main idea is to consider the characteristics of the straight line not as discrete image points (x1y1), (x2y2), etc., but instead, in terms of its parameters according to the slope-intercept model, i.e., the slope parameter m and the intercept parameter b. In general, the straight line y = mx + b can be represented as a point (bm) in the parameter space. However, vertical lines pose a problem. They are more naturally described as x = a and would give rise to unbounded values of the slope parameter m. Thus, for computational reasons, Duda and Hart proposed the use of a different pair of parameters, denoted r and \theta (theta), for the lines in the Hough transform. These two values, taken in conjunction, define a polar coordinate.

R theta line.GIF

The parameter r represents the algebraic distance between the line and the origin, while \theta is the angle of the vector orthogonal to the line and pointing toward the half upper plane (see Coordinates). If the line is located above the origin, \theta is simply the angle of the vector from the origin to this closest point. Using this parameterization, the equation of the line can be written as[5]

y = \left(-{\cos\theta\over\sin\theta}\right)x + \left({r\over{\sin\theta}}\right)

which can be rearranged to r = x \cos \theta+y\sin \theta (Shapiro and Stockman, 304).

It is therefore possible to associate with each line of the image a pair (r,θ) which is unique if \theta \in [0,\pi)  and r \in \mathbf{R}, or if \theta \in [0,2\pi) and r \geq 0. The (r,θ) plane is sometimes referred to as Hough space for the set of straight lines in two dimensions. This representation makes the Hough transform conceptually very close to the two-dimensional Radon transform. (They can be seen as different ways of looking at the same transform.[6])

For an arbitrary point on the image plane with coordinates, e.g., (x0y0), the lines that go through it are the pairs (r,θ) with

r(\theta) = x_0 \cos \theta + y_0 \sin \theta,

where r (the algebraic distance between the line and the origin) is determined by \theta\in [0,\pi).

If r is required to be positive, then \theta must vary in [0, 2\pi). In other words, \theta is the angle of the vector from the origin and this closest point (if r\ne 0), or the angle of the vector orthogonal to the line and pointing to the half upper plane (if r=0). The lines that go through (x0y0) are then

r(\theta) = |x_0 \cos \theta + y_0 \sin \theta|.

These representations correspond to a sinusoidal curve in the (r,θ) plane, which is unique to that point. If the curves corresponding to two points are superimposed, the location (in the Hough space) where they cross corresponds to a line (in the original image space) that passes through both points. More generally, a set of points that form a straight line will produce sinusoids which cross at the parameters for that line. Thus, the problem of detecting collinear points can be converted to the problem of finding concurrent curves.[7]

Example[edit]

Consider three data points, shown here as black dots.

Hough transform diagram.png

  • For each data point, a number of lines are plotted going through it, all at different angles. These are shown here as solid lines.
  • For each solid line a line is plotted which is perpendicular to it and which intersects the origin. These are shown as dashed lines.
  • The length (i.e. perpendicular distance to the origin) and angle of each dashed line is measured. In the diagram above, the results are shown in tables.
  • This is repeated for each data point.
  • A graph of the line lengths for each angle, known as a Hough space graph, is then created.

Hough space plot example.png

The point where the curves intersect gives a distance and angle. This distance and angle indicate the line which intersects the points being tested. In the graph shown the lines intersect at the pink point; this corresponds to the solid pink line in the diagrams above, which passes through all three points.

The following is a different example showing the results of a Hough transform on a raster image containing two thick lines.

Hough-example-result-en.png

The results of this transform were stored in a matrix. Cell value represents the number of curves through any point. Higher cell values are rendered brighter. The two distinctly bright spots are the Hough parameters of the two lines. From these spots' positions, angle and distance from image center of the two lines in the input image can be determined.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值