I've been thinking of an algorithm for object recognition but it would relies heavily on straight non-noisy lines and as far as I know this is hard to obtain with edge detection algorithms. What's the best edge detection algorithm to obtain lines as straight as possible?


2 Answers 2


You're probably looking for the Hough transform or one of it's extensions.

The simplest version of this transform is linear and appropriate for detecting straight lines.

In the transformed space (Hough space), angles and distances are found as points where curves intersect.

Libraries for calculating the Hough transform exist in

Related Questions and Answers

See this previous answer for more help on understanding the Hough transform.

  • $\begingroup$ Just one addition concerning libs: latest version of OpenCV not just has C++ bindings, but uses C++ classes in its core. Also consider using [new OpenCV website](opencv.org) for references. $\endgroup$
    – ffriend
    Aug 7, 2012 at 11:14
  • $\begingroup$ @ffriend: Cheers, updated answer $\endgroup$
    – jmetz
    Aug 8, 2012 at 15:02
  • $\begingroup$ The scikit-image link is out of date. Here is the example I think you mean to reference: scikit-image.org/docs/dev/auto_examples/edges/… $\endgroup$
    – lanery
    Feb 23, 2018 at 11:26

you can use LSD line detector http://www.ipol.im/pub/algo/gjmr_line_segment_detector/


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.