Theoretical PartPractical PartI implemented two variants of the Hough transform for lines. The first iterates through all possible discrete values of theta and solves for rho for every non-zero pixel in the source edge image. The second takes an edge image and a gradient angle image and uses the angle to only consider one theta value (one rotated 90 degrees from the gradient). The results are displayed below for two source images, one of a telephone and one of geometric shapes. As can be seen below, the second form of the transform is able to find more lines because there is less bleed over into adjacent cells compared with the first method. This problem could be partly alleviated by zeroing of neighboring areas in the accumulator after a maximum is found to prevent finding another nearly identical maximum. The additional caveat is that you want to find the actual maximum in the local area to avoid zeroing it out. I did not implement this extension. NOTE:I was unable to perform the first method on the shapes image. Matlab would not terminate and I could find no bugs in my program. It worked on a third test image. At this point, this is still unresolved. The following are the experimental images:
Here are the transforms of the first image using the two methods:
And for the second image:
Original with the ten largest lines filled in for the first image for both methods:
And for the second image:
Computation on the second image took extremely long for the I wrote my code in Matlab, it is available here |