Hough transform

Hough transform#

The objectives of this exercise are:

  • to detect lines in an image with the Hough transform

  • to know how to interpret a Hough transform

The Hough transform is applied to binary images, which must highlight the lines of the image. Also, an edge detection is needed. We apply the Canny detector (with the default parameters).

../_images/c7509e06886ccf0d0e8c1b764cbf0833852c77bcdcccda1955a9f29f75f1c0d1.png

The function hough_line returns the accumulator and the corresponding x-axis and y-axis.

../_images/d8c699c948e1c3fd44caa9a63eb1a33b71022eb9970590045308ca9d54846898.png

We can see clearly the sinusoids, each corresponding to a white pixel of the image of the contours (actually, we have done an image transformation to bring out the sinusoids). When the sinusoids intersect, they increase the intensity of the intersection pixel. The brightest pixels of the transform correspond to the main lines of the edges. The function hough_line_peak brings these pixels: the most important are represented by the green circles on the accumulator, and correspond to the lines shown in the image below.

../_images/098a4088d63bee2d82be2b52727ebc67a8c4b81d41dfea62d3b91784cf81c82c.png

Can you identify where the non-detected lines of the image are on the accumulator?

Try to detect the central circle of the object.