CS-565 Computer Vision
Nazar Khan
Lecture 15
Line Segment Detection
•
•
•
•
Edge detector gives potential edge pixels.
Hough transform gives potential infinite lines.
But we see line segments.
In this lecture, we study a Line Segment
Detector.
Rafael Grompone von Gioi, Jeremie Jakubowicz, Jean-Michel Morel, Gregory
Randall , LSD: a Line Segment Detector, Image Processing On Line, 2 (2012), pp.
35{55. http://dx.doi.org/10.5201/ipol.2012.gjmr-lsd
LSD
• Aimed at detecting line segments
– locally straight contours on images.
• Contours – zones of the image where the gray
level is changing fast.
Line Support Regions
• Compute the level-line angle at each pixel to produce a
level-line field.
• Segment level-line field into connected regions of
pixels that share the same level-line angle up to a
certain tolerance .
• These connected regions are called line support
regions.
Region Growing
Line Support Rectangles
• Each line support
region is a candidate
for a line segment.
• Associate a rectangle
with each region.
– The principal inertial
axis of the line
support region is
used as main
rectangle direction
– The size of the
rectangle is chosen to
cover the full region.
Aligned Points
• For the line support rectangle, count the
number of aligned points
– Level-line angle within radians of rectangle
angle.
Validation
• The total number of pixels in the rectangle, n,
and its number of aligned points, k, are
counted and used to validate the rectangle as
a detected line segment.
Helmholtz Principle
• The so-called Helmholtz principle states that
no perception (or detection) should be
produced on an image of noise.
The a contrario Approach
• Rough idea: if a random level-line field can
produce more alignments than in the
observed image rectangle, then the rectangle
does not represent a line segment.
• In other words, accept a line segment only if it
can’t occur by chance.
• More formally, lines are outliers in a random
level-line model H0.
The a contrario Approach
• The noise model H0 has the following
properties
1. {LLA(j) }jPixels is composed of independent
random variables.
2. LLA(j) is uniformly distributed over [0; 2]
where LLA(j)=level-line angle for pixel j.
• Under hypothesis H0, the probability that a
pixel on the a contrario model is an aligned
point is p=/. (Why?)
The a contrario Approach
• Let i=input image, I=random image.
• Let r be a rectangle with n(r) pixels.
• Let k(r,i) be the number of aligned points within r in
observed image i
• Let k(r,I) be the number of aligned points within r in a
random image I
• P(k(r,I)>= k(r,i)) represents the probability of the event
that number of aligned pixels in observed rectangle is
less than random alignments.
• If this probability is high then the rectangle does not
represent a valid line segment in input image i.
The a contrario Approach
• k(r,I) = # aligned points in r in random image I
Probability of j random
alignments in rectangle r
Probability of more
random alignments than
observed
Expected number of
rectangles under
random model that are
as good as observed
rectangle. These are all
false alarms!
n j
Pk r,I j p (1 p) n j
j
n
n j
Pk r,I k r,i p (1 p ) n j
j k ( r ,i ) j
N test Pk r,I k r,i
The a contrario Approach
N test MN
5
2
LSD
• Grow line support regions based on seed
pixels with large gradients
• Form line support rectangles
• Validate each rectangle if the number of
aligned points within the rectangle cannot be
due to chance.
LSD
Weaknesses
• Lines can still be broken because of the region
growing process.
• Intersections are missed.
• Requires post-processing.
© Copyright 2026 Paperzz