Search code examples
opencvimage-processingcomputer-visionhough-transform

Line Segment Detector vs Probabalistic Hough Transform


In OpenCV, there are two methods of detecting lines that give similar results in the form of a vector of endpoints - the Line Segments Detector (LSD) and the Probabilistic Hough Transform. (Discounting the standard Hough transform as the output given is in terms of equations, not line endpoints.)

I haven't been able to find a compare and contrast of these two line detection methods and their pros/cons. Thus - what is the difference between these two functions? Are there any particular benefits to using one method as opposed to the other?

Additionally, are there other lesser-known line detection methods (like LSD) that might be advantageous in some use cases?


Solution

  • Line Segments Detector (LSD)

    (Progressive) Probabilistic Hough Transform

    • Takes a binary image as input
    • Has several tuning parameters; distance resolution (rho), angle resolution (theta), an accumulator threshold parameter (only those with enough votes are returned), minimum line length and maximum line gap
    • Time performance depends on parameters (but is improved over standard Hough transform)
    • Several runs may yield different results due to randomised nature
    • Useful for more specific line finding; parameters allow for tuning, and has option to combine segments (via maximum line gap parameter) to return single longer lines
    • The OpenCV implementation is the Progressive Probabilistic Hough Transform (with thanks to Dr. D.'s answer on this question)

    Other algorithms

    • EDLines: a linear time line segment detector that utilises an edge detector. No OpenCV implementation as far as I know.

    (With thanks to Micka's comment for pointing out the differences in input and potential uses)