PROCESAMIENTO DIGITAL DE
IMAGENES Y VISION ARTIFICIAL
Semana 9 – sesión 1
Detección de curvas simples
Objetivos de la sesión
Desarrollo de algoritmos de detección de curvas simples
Detecting Lines and SimpleCurves
⚫ Many man‐made objects exhibits simplegeometric
forms: lines, circles, ellipses
Hough Transform
⚫ Hough transform: Find any shape that can be defined
parametrically within a distribution of points(Paul Hough)
⚫ Example: lines, circles, ellipses.
⚫ Used to find line segments in edge maps
⚫ Why isn’t displaying results of edge detection adequate?
Difficulty of linefitting
• Extra edge points (clutter),
multiple models:
– which points go with which
line, if any?
• Only some parts of each line
detected, and some parts
are missing:
– how to find a line that bridges
missing evidence?
• Noise in measured edge
points, orientations:
– how to detect true underlying
parameters?
Hough Transform
⚫ Equation of aline slope intercept
⚫ If points p1 and p2 on same line, same k andd
Hough Transform
⚫ Equation of aline slope intercept
⚫ Hough transform:
⚫ start with edge point(x,y)
⚫ Find (slope k, intercept d) that passes through the most
edge points
Hough Transform
⚫ Consider the point (x,y) =(1,1)
⚫ Many lines of different slope k and intercept d canpass
through (1,1)
⚫ Thus we can rewrite equation of line through (1,1) as
1 = k.1 +d (image) => d = ‐k + 1 (parameter space)
⚫ Set of all lines passing through (1,1) (left)
can be shown as line in parameter space (right)
Parameter space
Image space k
Hough Transform:Example
⚫ Suppose image has 5 points: (1,0), (1,1), (2,1), (4,1) and (3,2)
⚫ Each of these points corresponds to the following lines that
can be plotted
d Parameter
(1,0) ‐> d = ‐k space
Image space
(1,1) ‐> d = ‐k + 1
(2,1) ‐> d = ‐2k + y
1 (4,1) ‐> d = ‐4k (3,2)
Combinations
(values) k and d
+1 (3,2) ‐> d = ‐3k (1,1) (2,1) (4,1) that intersect max
number of edges
+2
k
(1,0) x
Note: Lines in parameter space great for searching
for optimal values of k and d
Hough Transform:Example
⚫ After finding optimal values of k and d, we can draw them as
lines in image space
⚫ In example: (k,d) = (0,1) and (1,‐1) each intersect 3 lines
⚫ Converting to image space: (0,1) ‐> y = 1, (1,‐1) ‐> y = x ‐1
d
Combinations
y
(values) k and d
that intersect max (3,2)
number of edges
(1,1) (2,1) (4,1)
k
Parameter (1,0) x
space
Image space
Accumulator Array
⚫ Accumulator array: discrete representation ofparameter
space as 2D array
⚫ Given a point in image, increment all points on it’s
corresponding line (draw line) in parameterspace
⚫ A line in image will be intersection of multiple lines in
parameter space.
Hough Transform
⚫ A Problem: The form of line cannot express
vertical line (slope k =infinity)
⚫ Alternate line representation in terms ofr, ϴ:
⚫ r, perpendicular distance of line fromorigin
⚫ ϴ, angle of line’s perpendicular to x axis
⚫ If we allow negative r, then ‐90 < ϴ< 90
Hough Transform
⚫ Point (p,q) where perpendicular to line meets line
= (rcosϴ, rsinϴ)
⚫ Consider (x,y), another point on line, gradient of line is
⚫ Gradient of perpendicular istanϴ
(rcosϴ, rsinϴ)
⚫ So gradient of lineis
⚫ Putting these two expressionstogether
Hough Transform
⚫ If we multiply these fractions, we obtain
⚫ And this equation can be rewritten as
⚫ Below is required equation for the line as
called Hessian Normal Form
Implementing Hough Transformusing Hessian Normal Form of
line
⚫ Each point (x,y) that falls on line with (r, ϴ) must satisfy equation
below
⚫ To implement Hough transform,
⚫ Choose discrete set of ϴvalues
⚫ For instance, for image shown considerϴvalues
⚫ For each pixel (x,y) in image, computer as
Implementing Hough Transformusing Hessian Normal Form of
line
⚫ For each pixel (x,y) in image compute r as
ϴ
⚫ Put results in a table
⚫ Accumulator array (below): contains number of times each value
of (r, ϴ) appears in table(above)
Hough Transform
⚫ Two largest values occurat
⚫ The corresponding lines are:
Visualizing Image Space toParameter SpaceRepresentation
⚫ Image Space and parameter space using HNF representation
for
⚫ If image center is reference, then range of r limited to half of
diagonal. E.g. for image of width M and height N
Hough TransformAlgorithm
⚫ 2 main implementationstages
1. Create 2-dimensional
accumulator array
2. Search accumulator
array for maximum values
Return parameters for
k strongest lines
Hough Transform:Noise
⚫ 4 lines (left) correspond to 4 darkest points (right)
⚫ Results are noisy
⚫ Max (r, ϴ) values do not occur at exactly one point, but in a small area
⚫ Caused by rounding. Difficult to pinpoint one exact maxima
⚫ Two strategies for dealing withnoise:
⚫ Thresholding
⚫ Non‐maximum suppression
Dealing with Noise:Thresholding
(b) Thresholding (image b):
threshold using 50% of the
maximum value
(c ) Non‐maxima
suppression (image d):
⚫ Compare every cellin
Acc(r, ϴ) to its neighbors
⚫ If greater than allneighbors,
keep cell
⚫ Otherwise set cell to 0
⚫ Can also apply thresholding
afterwards
Hough Transform on Circles
Hough Transform on Circles
Improvement of Brute ForceApproach
⚫ Observation: If we know the radius, the locations of all
possible centers lie on acircle
⚫ Improvement: For each image point p = (u, v), increment
(search) only cell values along edge of appropriate circle on
each ρ plane of accumulatorarray
Hough Transform of Circles
Hough Transform of Ellipses
Hough Transform onEllipses
⚫ 5‐dimensional parameter space can yield verylarge
data structure
⚫ If 128 = 27 steps used in each dimension
⚫ requires 235 accumulator cells
⚫ If 4‐byte int values, requires 237 bytes (128 gigabytes)
memory
⚫ Generalized Hough Transform better, requires4‐
dimensional space
Ejercicios
Desarrollar algoritmos detectores de líneas y círculos
Cierre
References
⚫ Wilhelm Burger and Mark J.Burge, Digital Image Processing, Springer,
2008
⚫ Robert Collins, CSE 486 slides, Penn State University
⚫ University of Utah, CS 4640: Image Processing Basics, Spring 2012
⚫ Rutgers University, CS 334, Introduction to Imaging and Multimedia, Fall
2012
⚫ Gonzales and Woods, Digital Image Processing (3rd edition), Prentice Hall