Polar representation of an horizontal line

analytic geometryimage processingpolar coordinates

I'm studying the Hough transform which is an algorithm for finding lines in images. In general it is common to use the Polar representation $\left(d = x\cos(\theta) + y\sin(\theta)\right)$ of the line, due to the problems caused by the vertical lines in the cartesian representation ($Y = aX + b$, vertical lines have a tending to infinity).

But when implementing this algorithm I figured out that the horizontal lines cause problems to Polar form due to $\sin(0)\to\infty$. So, how to represent a horizontal line in a polar form using this equation: $$Y = \frac{d – X\cos(\theta)}{\sin(\theta)}?$$

Thanks.

Best Answer

I don’t really see a problem here.

Calling your equation a “polar representation” of the line is something of a misnomer, I think, and might be causing some confusion. You’re still working in Cartesian, not polar, coordinates. Your equation is just the general equation $ax+by=d$ of a line in the plane with the coefficients normalized so that $a^2+b^2=1$. (This makes the normal vector $(a,b)$ a unit vector.) It looks like the parameter $\theta$ measures the angle that the line makes with the $x$-axis, with positive angles measured clockwise, which is a somewhat unconventional choice, but likely makes sense in context.

The Cartesian equation of a horizontal line is simply $y=d$, and this is entirely compatible with your representation: just set $\theta=\pi/2$.