Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
DOC ENH + API fix on houghline transform #2089
Long story short, I got some discrepancies from the Hough line transform. For instance, if you look carefully at the gallery, it doesn't superimpose perfectly. Based on that, I started a code analysis.
The hough line peak detection has a pixel resolution. I wrote a code to make it subpixel. Once I finished a first version of it, I figured out something else.
The default theta value in hough_line() specifies not only a range, but also a bin size. That was not clearly stated in the doc. Reducing the bin size helps to improve the accuracy of the detection. Quick code that shows that:
for i in range(1, 11): print(i*90) h, theta, d = hough_line(image, theta=np.linspace(-np.pi / 2, np.pi / 2, 90*i)) angles = np.array([angle for _, angle, dist in zip(*hough_line_peaks(h, theta, d))]) print((np.abs(angles) * 180 / np.pi - 45) / 45. * 100)
Modification 1 So, I modified the docstring to hightlight that point.
Modification 2 I changed the "returned values" in the docstring to be consistent with the notations for the peak detection.
Modification 3 I noticed that the cython function had a None default value. This is not handled by the code (Didn't try, but I think it would crash). The None case is handled by the python wrapper function. So I removed that. It's an API modification, but it's an internal function, I guess we are fine with that.
To come back on the subpixel algo, at the end, it shows a better result than the actual algorithm.