原理
霍夫直线变换一般用来检测直线,它要在边缘检测之后才能应用。
在数学上要定义一条直线通常有2种方法:
- 笛卡尔坐标系:两点确定一条直线,即 ( x 0 , y 0 ) , ( x 1 , y 1 ) (x_0,y_0), (x_1, y_1) (x0,y0),(x1,y1);
- 极坐标:极角和极径确定一个向量 ( r , θ ) (r,\theta) (r,θ),与该向量垂直,且经过其端点的直线只有一条,即:
y = ( − cos θ sin θ ) x + ( r sin θ ) y=(-\frac{\cos \theta}{\sin \theta})x+(\frac{r}{\sin \theta}) y=(−sinθcosθ)x+(sinθr)
该式变换可得:
r = x cos θ + y sin θ r=x \cos \theta + y \sin \theta r=xcosθ+ysinθ
因此对于极坐标系中的任意一点 ( x 0 , y 0 ) (x_0,y_0) (x0,y0),经过该点的所有直线都适用下面的等式:
r θ = x 0 ⋅ cos θ + y 0 ⋅ sin θ ( 1 ) r_{\theta}=x_0 \cdot \cos \theta + y_0 \cdot \sin \theta \qquad(1) rθ=x0⋅cosθ+y