Hough transform is used to detect lines in an image. It uses the parametric representation of a line:
where rho is the distance of the line from the origin and theta is the angle between the x-axis and the vector perpendicular to the line.
Fortunately, there are built-in functions in MATLAB that are useful for this activity.
Let us start with this image, taken in Cibo. The design of the place uses a lot of lines.
First, convert the image above to grayscale and use the edge function to detect the edges in the image. I tried the Canny algorithm.
So now we have the edges in the image. Let us now implement the hough function. The hough function returns this plot:
The x- and y- axis are theta and rho, respectively. The bright spots correspond to the most prominent lines in the image.
To detect the brightest spots or the peaks, let us use the function houghpeaks. The function returns a list of theta and rho coordinates that correspond to the peaks in the hough transform plot.
Shown in the figure above are the three peaks. To plot the lines that correspond to these peaks, we use the function houghlines. The figure below shows the superposition of the plotted lines on the grayscale of the original image. We can see that the lines coincide with the lines in the ceiling and the table. The lines from the table are somewhat unexpected because visually, the ceiling lines are more prominent. I expected that before the lines from the table will be detected, all the ceiling lines will be detected first.
I also noticed that the detected lines depend on the edge detection algorithm. Shown below are the different results for the different edge detection methods.
I give myself 10 points for this activity. The hough transform was used to identify and draw the lines detected in the image. I also investigated the effect of using different edge detection algorithms, although I cannot explain the differences yet.
Sunday, April 11, 2010
Hough Transform
Posted by irene at 5:59 PM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment