Search code examples
pythonopencvcomputer-visionpolar-coordinateshoughlines

Cartesian coordinates in Houghlines


Why can't we use Cartesian coordinates(x,y) instead of polar coordinates(r,theta) in Houghlines transformations ? Can any one clarify?


Solution

  • From what I can understand (quoted from wikipedia):

    The simplest case of Hough transform is detecting straight lines. In general, the straight line y = mx + b can be represented as a point (b, m) in the parameter space. However, vertical lines pose a problem. They would give rise to unbounded values of the slope parameter m. Thus, for computational reasons, Duda and Hart proposed the use of the Hesse normal form r = x*cos(theta) + y*sin(theta), where r is the distance from the origin to the closest point on the straight line, and theta is the angle between the x axis and the line connecting the origin with that closest point.

    A line can be detected by finding the number of intersections between curves.The more curves intersecting means that the line represented by that intersection have more points. In general, we can define a threshold of the minimum number of intersections needed to detect a line. This is what the Hough Line Transform does. It keeps track of the intersection between curves of every point in the image. If the number of intersections is above some threshold, then it declares it as a line with the parameters (theta,r_(theta)) of the intersection point. (OpenCV docs)