MATLAB: How to find hough lines in gradient image

hough transformationImage Processing Toolboxline detection

I want to use gradient image as the representative of edges and outlines of the normal image to find lines by hough transformation. Hough function needs edge map to find lines while gradient magnitude generated by imgradient function is not binary.
[Gmag, Gdir] = imgradient(ImgResamp2,'sobel'); [H,T,R] = hough(Gmag); %here Gmag is not binary image

Best Answer

Try edge() - it uses imgradient() and then thresholds it to get a binary image. See the demo where they start out with the gantry crane image.