Vous êtes sur la page 1sur 18

Line Detection

By: Tom Madison


Line Detection Methods
1. Edge detection:
1. Erosion and Dilation
2. Roberts cross, Sobel, Compass, Canny
3. Laplacian, gradient
2. Line Detection Masks (project topic)
3. Hough Transform (parametric space)
Basic Line Detection Steps
• Convert to gray scale
• Optional: Smooth the image
• Apply each mask to the image
– Convolution
– Now you have 4 separate filtered images, 1 for each mask
• Threshold each filtered image
• Add the images together
Line Detection Masks

a) Horizontal mask
b) Vertical mask
c) 45 degrees
d) -45 degrees

•The above masks are use to detect light lines on a dark background
•To detect dark lines on a white background simply negate the masks
Addition of Images
Examples
Original Horizontal Mask Threshold

Final Result
Original: After applying line detection masks:

Smoothed then filtered using Canny edge detection (uses smoothing


line detection masks: and second order derivatives)
Hough Transform
• Useful in isolating specific features within an image
– Classic Hough Transform: Lines, circles, ellipses
– Generalized Hough Transform: used in cases where detecting
simple shapes isn’t good enough.
• Better then Edge detectors:
– Edge detectors tend to leave gaps in lines, the Hough Transform
can bridge those gaps.
– Good for noisy images due to the ability of bridging gaps.
• Applications:
– Anything that needs a boundary detected: Medical Imaging,
Manufacturing, etc.
Parameter Space

y=ax + b b = -xa + y
a and b known x and y known
Unfortunately b = -xa + y isn’t good enough as the slope
approaches infinity as the slope becomes vertical.
Hough Transform

r is the length of a normal from the origin to the line


Theta is the orientation of the normal with respect to the x axis
Steps
1. Apply Edge detection to the original image (canny
edge detector).
2. Apply the Hough Transform
3. De-Hough
Matlab Implementation
• Makes use of the radon transformation
– [R,xp] = radon(I,theta);
– R is the length of the normal, xp is the orientation.
– I is the image, theta is orientation of the lines you want to detect.
• In the case of the Hough transform you want to detect lines so you
use:
– theta = 0:179;
Examples
Original: Edge Detection:

Hough Transform
Simple Shape

Basic Image
Simple Shape
Edge Detection Hough Transform De-Hough + original
Noisy Images
Edge Detection + noise Hough Transform De-Hough + original
Broken Edges
Broken Edge Detection Hough Transform De-Hough + Original
References
• http://cs-alb-pc3.massey.ac.nz/notes/59318/l10.html
• http://www.cse.unr.edu/~bebis/CS791E/Notes/LineDetection.pdf
• http://homepages.inf.ed.ac.uk/rbf/HIPR2/linedet.htm
• Matlab Help
• http://www.ece.utk.edu/~gonzalez/ipweb2e/downloads/classroom_presentat
ions/Chapter10-Art.zip

Vous aimerez peut-être aussi