Translation to plot line with hough transform when using polar coordinates

huangapple go评论66阅读模式
英文:

Translation to plot line with hough transform when using polar coordinates

问题

我有点难以理解使用极坐标进行Hough变换后如何绘制线条。

OpenCV示例中,他们这样做:

a = math.cos(theta)
b = math.sin(theta)
x0 = a * rho
y0 = b * rho
pt1 = (int(x0 + 1000*(-b)), int(y0 + 1000*(a)))
pt2 = (int(x0 - 1000*(-b)), int(y0 - 1000*(a)))

我理解他们在同一条线上取两个远离的点,但我难以理解x点的“投影”/乘以sin以及y点的乘以cos。

有人能为我解释一下吗?

英文:

I have a bit of trouble understanding how lines are plotted after doing a Hough Transform using polar coordinates.

On the OpenCV example they do it like this:

a = math.cos(theta)
b = math.sin(theta)
x0 = a * rho
y0 = b * rho
pt1 = (int(x0 + 1000*(-b)), int(y0 + 1000*(a)))
pt2 = (int(x0 - 1000*(-b)), int(y0 - 1000*(a)))

I understand that they are taking two points far apart on the same line, but I have trouble understanding the "projection"/ multiplication by the sin for the x point and the cos for the y point.

Can anyone enlighten me?

答案1

得分: 0

“r”和“theta”的定义如下。

因此,蓝线方向单位向量V(cos(theta), sin(theta)),并且该线上的一个点可表示为r * **V**(在您的描述中为(x0, y0))。

沿着该点移动可以得到该线上的其他点。沿着垂直于V的方向单位向量U,它可以表示为(-sin(theta), cos(theta))(sin(theta), -cos(theta))

因此,该线上的点为:

r * **V** + k * **U**

其中,标量k的值是任意的移动量。(在您的描述中,使用的k值为1000-1000


因此,对于

x点的sin和y点的cos

答案是,U:沿着该线的单位方向向量。

英文:

Definitions of r and theta are as shown.

So, the blue line directional unit vector V is ( cos(theta), sin(theta) ),
and one point on the line is given as <code>r * V</code> (In your description, this is (x0,y0) ).

Points on the line can be obtained by moving along the line from this point.
The along directional unit vector U (which is perpendicular to V) , is ( -sin(theta), cos(theta) ) or ( sin(theta), -cos(theta) ).

So, points on the line is :

<code>r * V + k * U</code>

where, value of the scalar k is arbitrary amount of movement. (In your description, used k values are 1000 and -1000)


Therefore, short answer for

> the sin for the x point and the cos for the y

is, U : the unit directional vector along the line.

huangapple
  • 本文由 发表于 2023年5月30日 01:00:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/76359124.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定