Wednesday, December 9, 2009

Activity 2: Hough Transform

I. Theory

The Hough Transform was patented by--surprise!--Paul Hough in 1960. The classic Hough transform was concerned with the identification of the lines in an image. It was later developed and popularized, two decades after, with its application to any arbitrary shape like circles and ellipses. It is now widely used in a variety of related methods for shape detection since it is tolerant of gaps in feature boundary descriptions and is relatively unaffected by image noise. This feature extraction technique is used in a wide range of fields including computer vision, image analysis and digital image processing.


II. Experiment

We were tasked to capture a gray scale image of a scene with straight lines. The image I chose was that of a lion inside a steel cage taken in the Baluarte mansion of then Ilocos Sur governor Chavit Singson. I had to first binarize the image (convert into its black and white version) and did edge detection before proceeding with the Hough transform technique. A successful implementation of this technique will result in an image with lines properly superimposed on straight edges in the image.



Figure 1. Image of a lion inside a cage taken in Balaurte, Ilocos Sur (image size: 450 x 600).


Figure 2. Black and white version of the sample lion image using the im2bw command in Matlab.
Figure 3. The edges in the lion image using the edge detection algorithm available in Matlab.


The Hough transform is designed to detect lines using the parametric representation of a line:

rho = x * cos(theta) + y * sin(theta) (1)

Rho is the distance from the origin to the line along a vector perpendicular to the line and theta is the angle between the x-axis and this vector.

We then used Hough Transform function in Matlab to create an accumulator matrix based on the parameters r and θ. Then we found the peaks in the accumulator matrix and converted the r and θ values into the equation of a line.
Figure 4. Computed Hough Transform of our image in 'hot' color map version with the peaks represented by the small squares

Figure 5. Superimposed lines on the original image indentified using the Hough Transform.


Figure 5 shows the superimposed lines on the cage, in the original image identified by the Hough Transform technique. The blue line represents the longest identified straight edge while the green lines represent the other straight edges. Comparing Figures 1 and 5, we notice that the Hough transform reconstructed the thin straight edges and those that easily blend with the background(faint ones).


Tips:

1. The hough function in Matlab easily generates a parameter space matrix whose rows and columns correspond to the rho and theta values respectively.

2. After computing for the Hough transform, use the houghpeaks function to find the peak values in the parameter space. The peaks represent potential lines in the input image

3. Use houghlines to find the endpoints of the line segments corresponding to the peaks in the Hough transform. The function automatically fills in gaps in the line segments.



We were successful in
identifying the straight edges in our cage image by using the classic Hough transform. I give myself a grade of 10 in this activity. This activity is much easier than the first one, adaptive segmentation and tracking using the color locus, mainly because the functions needed are readily available in Matlab.


References:

[1] http://www.cogs.susx.ac.uk/users/davidy/teachvision/vision4.html
[2] Maricor Soriano, Applied Physics Lectures: Hough transform. 2009
[3] MATLAB R2008a

For teaching concerns please visit: https://sites.google.com/site/alongjas/

No comments:

Post a Comment