ImageLines implements the Hough transform, but how do I search for only lines within some threshold of a certain angle(s)?

  • 1
    $\begingroup$ Could you please post some sample images, code you have written so far? You might try to find all the lines and simply take the ones within your threshold. $\endgroup$
    – s0rce
    Commented Apr 22, 2013 at 17:25
  • 1
    $\begingroup$ You could do the Radon transform which allows specification of the range over which to look. $\endgroup$
    – bill s
    Commented Apr 22, 2013 at 17:50
  • $\begingroup$ There's a Radon function might be a start point. $\endgroup$
    – Silvia
    Commented Apr 22, 2013 at 17:53
  • $\begingroup$ An explanation and example appear in an answer on the stats site. $\endgroup$
    – whuber
    Commented Apr 22, 2013 at 19:50
  • $\begingroup$ Angle from what, horizontal? $\endgroup$ Commented Apr 22, 2013 at 23:37

1 Answer 1


To search only for lines at given angles, say between theta0 and theta1, you could:

  1. Compute the Hough transform using Radon[img, dims, {theta0, theta1}, Method -> "Hough"]
  2. Detect peaks in the Hough transform, ie. the local maxima with high values (MaxDetect and Binarize may help, for example)
  3. Extract the positions of the detected peaks and convert them from the image coordinate systems to {rho, theta} values (Rescale may help)

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.