Digital Image Processing

Project 3: Feature Detection: Lines

Click here for the source code and my working SGI executable.
Click here for the informational "report" I turned in with my assignment.

This was the third project for my Digital Image Processing class. The idea was to write a program that can detect lines in images, both synthetic and actual photographs. We were supposed to use some sort of edge detector, and then feed the results into a Hough Transform to get an analytical expression for the lines. We weren't required to determine the extent of the lines however, though it would be relatively easy to implement. However, since it is finals week and I don't have time to work on this project too much more, I doubt that I'll get around to it.

First off, I'm going to show some results of my edge detector. I used a Marr-Hildreth edge detector (a Laplacian of a Gaussian). I did this the easiest way possible: I applied a Gaussian blur to the image first (in the Fourier domain, since I already had code to do this from Project 2) and then applied a Laplacian kernel.

Click for example edge detection images.
Click for example hough transform images.
Click for example final results.
Click for comparisons and other analysis.
Click for results of varying std. dev. of Gaussian applied to input image.



Edge Detection Images

Click on the images below to see the original:


An image of the University of Minnesota Marching Band in the Metrodome



Another image from the Minnesota Band, during rehearsal



An image of the University of Utah Marching Band, the trumpet section



Yours truly...



An image from Arches National Park



The Cornell Box. I had to use this image. Plus, it has lots of lines



And OpenGL image from my Graphics II class last year



A cathedral somewhere in Europe. Found this image online



Accumulator Space Images

Below are the results of applying the Hough Transform to images run through the edge detector (like those above). The accumulator space has theta running along the X axis, from -pi to pi, and R running along the Y axis from 0 at the top to a computed maximum (for the input image) at the bottom.

Click on the images below to see the original:


Cornell Box

Cornell Box's Hough Transform

Me

My Hough Transform

A cathedral

The cathedral's Hough Transform

Utah trumpet section

The trumpet section's Hough Transform

Zelda

Zelda's Hough Transform

Chicago

Chicago's Hough Transform

In a cemetary

Monolith's Hough Transform



Final Result Images

Below are images with the detected lines on them. Note that these images were the best that I could get by tweaking the parameters. I'm sure better results could be found, but I had a limited amount of time to play with each of the images.

Some of the obvious lines are not found (and sometimes I didn't find them ever during my testing). Sometimes, they were found, but to get rid of extraneous lines, I had to change the parameters so that some lines were ignored. Also, I found a number of not so obvious lines. To determine the reason my method found them, see the section below and compare the line that this method found to the Marr-Hildrith edges, and you'll see why.

Click on the images below to see the original:


Before

After

Before

After

Before

After

Before

After

Before

After

Before

After

Before

After



Comparisons and Analysis

Below is a table with the various stages of the process during the computation. Note that some images gave really good results, and some images only gave so-so results. Probably the biggest problem was determining what level of blur to use before the edge dectection. If too little blur was used, too many edges were found, causing more edge pixels to be detected. This added more noise edges to the Hough Transform, which complicated detecting actual lines, and made detection of spurious lines more likely. Images depicting the change in results due to variations in blur levels follows the chart comparing results on various images.

Once a good blur level was found, the size of the accumulator space needed to be determined based upon the number of edge pixels used. Lots of edge pixels require a large accumulator space, since each edge pixel translates into a curve in accumulator space which increments the corresponding pixels by one. Since I used a greyscale accumulator space image with 256 grey levels, more than 256 curves intersecting at a single point resulted in lost information.

All of the accumulator space images below are 256 x 256 to save space, but for the actual image, the size indicated below the image was used.

Original ImageEdges DetectedHough TransformResult
1)
512 x 512
2)
1024 x 512
3)
2048 x 2048
4)
512 x 512
5)
1024 x 1024
6)
512 x 512
7)
256 x 256
8)
512 x 512
9)
512 x 512
10)
512 x 512
11)
512 x 512
12)
256 x 256
13)
512 x 512
14)
512 x 512
15)
512 x 512



Effects of Changing Initial Blur Parameter

So, you might ask how I got the results you see in the previous table. Well, for most of the images, it was playing with the parameters through trial and error to get results that look reasonable. The hardest problem was getting rid of spurious lines, which appear because a little too much noise was on the same line, or there were just too many edge points added to the accumulator space, and the "actual" lines merged together to form a non-existant line.

In fact, I'm sure all of the results above (which were my best results before I did this section) could be improved by more or less systematically going through parameter space. But, since I didn't have time for that (and some of the images require long run times), I had to settle for my best guess. However, for the Cornell Box image, I tried systematically playing with one parameter -- the standard deviation of the Gaussian filter applied to the input image before detecting edge pixels. Below is a table showing my results:

Note that with Gaussians that blur the input more, you detect fewer more accurate lines. As the filter blurs less, you get more (generally less accurate) lines. Interestingly, some lines are only detected at a particular parameter value and not elsewhere. This is really what makes getting good results particularly tedious.

Note that the parameter isn't exactly the standard deviation of the Gaussian, but rather is proportional to it. However, results are organized from most blurry to least blurry:

Param:Edges:Lines:
10.0)
20.0)
30.0)
40.0)
60.0)
70.0)
90.0)
From last chart
120.0)
140.0)
160.0)
200.0)


Last Modified: Monday, December 11, 2000

Chris Wyman (wyman@cs.utah.edu)