我一直在想为什么霍夫变换使用 rho=xcos(theta) + ysin(theta)
来表示一条直线 (y=mx+b)
。我试图自己推导(并查看了维基百科的文章),但是找不到如何从一个式子推导出另一个式子。
有人知道如何从一个式子推导出另一个式子吗?
提前谢谢。
我一直在想为什么霍夫变换使用 rho=xcos(theta) + ysin(theta)
来表示一条直线 (y=mx+b)
。我试图自己推导(并查看了维基百科的文章),但是找不到如何从一个式子推导出另一个式子。
有人知道如何从一个式子推导出另一个式子吗?
提前谢谢。
推导:
方程 x/a + y/b = 1
:
从三角学中,回想一下如何通过旋转角度 t
的光线根据 (angle=t, radius=1) -> (x=cos(t), y=sin(t))
* 投影到x和y轴上。
在标记点处绘制切线。三角学(或甚至是相似三角形的几何学)告诉我们,切线交于 x=1/cos(t)
,y=1/sin(t)
。因此,距离1的直线将具有 a=1/cos(t)
和 b=1/sin(t)
,并因此由 x/(1/cos(t)) + y/(1/sin(t)) = 1
描述...
... 这只是 cos(t) x + sin(t) y = rho
,其中 rho=1
您可以看到,rho
对应于该直线距原点的距离(通过玩弄方程或注意到这里的乘法只是按相同数量缩放所有值,从而有效地重新调整网格)。
sin(theta)/cos(theta)
,不是吗? - Jonathan My=mx+b
线的斜率,那么这将是正确的。然而,您并没有这样做,而 y=mx+b
线的斜率等于从该线到原点的正切线的负倒数。如果您查看 ninjagecko 的答案,您会发现这意味着 m = -(cos(theta)/sin(theta))
。 - CanSpicex = rho cos theta ----(1)
y = rho sin theta ----(2)
请参考这里了解更多信息。
我们如何得到上述方程?
这些方程使用直角三角学的概念。
请参见这里的图片。
cos theta = adjacent-side/hypotenuse = x/rho, thus we get (1)
sin theta = opposite-side/hypotenuse = y/rho, thus we get (2)
and Pythagorean theorem says,
hypotenuse^2 = adjacent side ^2 + opposite side^2, so
rho^2 = x^2 + y^2 ----(3)
rho^2 = x^2 + y^2 ---- from (3)
rho^2 = x*x + y*y
rho^2 = x(rho cos theta) + y (rho sin theta) ---- from (1) and (2)
rho^2 = rho(x cos theta + y sin theta)
rho = x cos theta + y sin theta
每对 rho, theta
都与给定直线上的一个 x,y
对相关联,其中距离原点的距离 rho
在角度 theta
处将您放置在该直线上的 x,y
坐标。
使用 rho, theta
方程而不是 y=mx+b
方程,以便可以将一系列 rho, theta
值放入方程中,而不会出现计算问题,这些问题在 y=mx+b
方法中出现,其中斜率未定义(即,该直线是垂直的)。