gpt4 book ai didi

java - 如何实现霍夫变换?

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:22:40 26 4
gpt4 key购买 nike

如何实现 Hough transform在文字图片上?我正在寻找伪代码(最终这将在 java 中)。

这里是一些背景信息:

给定一幅图像,确定一条线的方程 y = mx + b。通常,霍夫变换以极坐标表示,例如 Rho = y*sin(theta) + x*cos(theta)。 (我不太确定 XY 值对应于图像)。

我们只对 Rhotheta 值感兴趣并绘制它们。累加器中有很多点的位置(我知道一些实现,而不是执行)被认为是一条线。

我不明白的问题是如何找到用于更新累加器的 rhotheta

最佳答案

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 and can be graphically plotted for each pair of image points (x, y)

所以这告诉您 xy 对应于图像中的背面。

In the Hough transform, a main idea is to consider the characteristics of the straight line not as image points (x1, y1), (x2, y2), ..., but instead, in terms of its parameters, such as the slope parameter m and the intercept parameter b.

Based on that fact, the straight line y = mx + b can be represented as a point (b, m) in the parameter space. However, one faces the problem that vertical lines give rise to unbounded values of the parameters m and b. For computational reasons, it is therefore better to use a different pair of parameters, denoted and (theta), for the lines in the Hough transform.

The parameter rho represents the distance between the line and the origin, while theta is the angle of the vector from the origin to this closest point.

这告诉您 rhotheta 对应什么:它们是您试图在图像中描述的直线的斜率和截距的极坐标表示。


关于 SourceForge你可以找到 hough 变换的 C++ 实现。

您应该能够从中解释我在上一个链接中指出的代码的描述如下:

The Hough transform algorithm uses an array, called an accumulator, to detect the existence of a line y = mx + b.

For example, the linear Hough transform problem has two unknown parameters: m and b.

For each pixel and its neighborhood, the Hough transform algorithm determines if there is enough evidence of an edge at that pixel. If so, it will calculate the parameters of that line, and then look for the accumulator's bin that the parameters fall into, and increase the value of that bin.

By finding the bins with the highest values, typically by looking for local maxima in the accumulator space, the most likely lines can be extracted

关于java - 如何实现霍夫变换?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9592818/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com