Jump to content

Line detection

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Ectech2000 (talk | contribs) at 02:06, 25 April 2018. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

In image processing, a line is a collection of edge points that are adjacent and have the same direction.[1] Line detection is an algorithm that take a collection of n edge points and find all the lines on which these edge points lie. The most popular line detectors are the Hough transform and convolution based technique. [2]

Hough transform can be used to detect lines and the output is a parametric description of the lines in an image, for example ρ = r cos(θ) + sin(θ).[1] If we have a line in our row and column based image space, we can define that line by ρ, the distance from the origin to the line along a perpendicular to the line, and θ, the angle of the perpendicular projection from the origin to the line measured in degrees clockwise from the positive row axis. [2] Therefore, a line in the image corresponds to a point in the Hough space.[[3]]

In a convolution based technique, the line detector operator consists of a convolution masks tuned to detect the presence of lines of a particular width n and a θ orientation. The mask shown below can be used to detect lines at various orientations

a) Horizontal mask(R1)

-1 -1 -1
2 2 2
-1 -1 -1

(b) Vertical (R3)

-1 2 -1
-1 2 -1
-1 2 -1

(C) Oblique (+45 degrees)(R2)

-1 -1 2
-1 2 -1
2 -1 -1

(d) Oblique (-45 degrees)(R4)

2 -1 -1
-1 2 -1
-1 -1 2

[4]

in practice, masks are run over the the image and the responses are combine given by the following equation:

R(x, y) = max(|R1 (x, y)|, |R2 (x, y)|, |R3 (x, y)|, |R4 (x, y)|)

If R(x, y) > T, then discontinuity

Example:

File:Crazyline.png
Example
File:Crazypic.jpg
Example
Horizontal line convolved image
0 0 0 0 - - - -
1 1 1 1 = - 6 6 -
Mask * 0 0 0 0 - - - -
-1 -1 -1
2 2 2
-1 -1 -1
* Vertical line convolved image
0 0 1 0 - - - -
0 0 1 0 = - 0 0 -
0 0 1 0 - - - -

These masks above are tuned for light lines against a dark background, and would give a big negative response to dark lines against a light background.[4]

Example:

clear all
clc
%benzene = imread('benzene.png');
%building = imread('building.tif');
crazy=imread('crazypic.jpg');
building=rgb2gray(crazy);
tol = 5;%define a tolerance in the angle to account for noise or edge
        % that may look vertical but when the angle is computed
        %it may not appear to be
[~,angle] = imgradient(building);
out = (angle >= 180 - tol | angle <= -180 + tol);
out_filter = bwareaopen(out, 50);
figure,imshow(crazy),title('Original Image');
figure,imshow(out_filter),title('Detected Lines');
  1. ^ a b E., Umbaugh, Scott (2011). Digital image processing and analysis : human and computer vision applications with CVIPtools. Umbaugh, Scott E. (2nd ed ed.). Boca Raton, FL: CRC Press. ISBN 9781439802052. OCLC 491888664. {{cite book}}: |edition= has extra text (help)CS1 maint: multiple names: authors list (link)
  2. ^ "Hough transform - MATLAB hough". www.mathworks.com. Retrieved 2018-04-23.
  3. ^ http://vision.stanford.edu/teaching/cs231a_autumn1112/lecture/lecture4_edges_lines_cs231a_marked.pdf
  4. ^ a b "Line Detection". homepages.inf.ed.ac.uk. Retrieved 2018-04-23.