EdgeDetection Final
EdgeDetection Final
Definition of Edges
• Edges are significant local changes of intensity in an
image.
What Causes Intensity Changes?
• Geometric events
– surface orientation (boundary) discontinuities
– depth discontinuities
– color and texture discontinuities
(centered at x)
(centered at x+1)
ramp edge
roof edge
Edge Detection Using First Derivative (Gradient)
2D functions:
• The first derivate of an image can be computed using the
gradient:
f
Gradient Representation
• The gradient is a vector which has magnitude and direction:
(approximation)
or f f
| || |
x y
(x+1/2,y)
good approximation
(x,y+1/2)
at (x+1/2,y) *
*
good approximation
at (x,y+1/2)
Approximating Gradient (cont’d)
3 x 3 neighborhood:
d
I
dx
d
I
dy
Another Example (cont’d)
2 2
d d
I I
dx dy
Threshold 100
Practical Issues
• Noise suppression-localization tradeoff.
– Smoothing depends on mask size (e.g., depends on σ for
Gaussian filters).
– Larger mask sizes reduce noise, but worsen localization (i.e.,
add uncertainty to the location of the edge) and vice versa.
smaller mask larger mask
Effect Smoothing on Derivates
In this example,
we can find the
license plate
candidate after
edge linking
process.
Hough Transform
y i =mx i +c
42
Line detection
y Y = mx + n Y1=m x1+n
Y2=m x2+n
P(x1,y1)
P(x2,y2)
x
YN=m xN+n
43
Image and Parameter Spaces
y Y = mx slope
Y1=m x1+n
Y =+m’x
n + n’
m’
Y2=m x2+n
n
n’
intercept
x m
YN=m xN+n
44
Hough Transform Technique
Given an edge point, there is an infinite number of lines
passing through it (Vary m and n).
These lines can be represented as a line in parameter space.
slope
y n = (-x) m + y
P(x, y) n
intercept
x m
Parameter Space
45
n
m
Edge Linking and Boundary Detection
Hough Transform Example
Local Analysis proximity
50
Hough Transform slope-intercept
parametrization
An Edge Pixel in Real Space would vote into Hough Space all possible
lines that contain that point
y = kx + q
Continue to Add Votes for different Edge Pixels
Intersection gives Equation for line
Edge Detected Image (real space)
Hough Space
51
HT - parametric representation
y = kx + q
(x,y) - co-ordinates
k - gradient
q - y intercept
Any straight line is characterized by k & q
use : ‘slope-intercept’ or (k,q) space not (x,y) space
(k,q) - parameter space
(x,y) - image space
can use (k,q) co-ordinates to represent a line
52
Looking at it backwards …
Image space
Fix (m,n), Vary (x,y) - Line Y = mx + n
P(x1,y1)
x
53
Looking at it backwards …
Parameter space
slope
m’
n
n’
intercept
m
54
Hough Transform for lines
55
Image Parameter Spaces
56
Hough Transform
Philosophy
H.T. is a method for detecting straight lines, shapes and
curves in images.
•Main idea:
Map a difficult pattern problem into a simple peak detection
problem
57
Criteria for Optimal Edge Detection
(and direction)
Canny edge detector - example
original image
Canny edge detector – example (cont’d)
Gradient magnitude
Canny edge detector – example (cont’d)
Thresholded gradient magnitude
Canny edge detector – example (cont’d)
Thinning (non-maxima suppression)
Non-maxima suppression
(i,j)
Hysteresis thresholding
• Standard thresholding:
th
tl th
tl
Use edge
“direction” for
linking edges
Hysteresis Thresholding/Edge Linking (cont’d)
detect zero-crossings
Properties of Laplacian
• It is an isotropic operator.
• It is cheaper to implement than the gradient (i.e., one
mask only).
• It does not provide information about edge direction.
• It is more sensitive to noise (i.e., differentiates twice).
Laplacian of Gaussian (LoG)
(Marr-Hildreth operator)
• To reduce the noise effect, the image is first smoothed.
(inverted
LoG)
• It can be shown that:
2σ2
Laplacian of Gaussian (LoG) - Example
(inverted LoG)
(inverted LoG)
filtering zero-crossings
Decomposition of LoG
• It can be shown than LoG can be written as follows:
2 g ( x, y )
2 g ( x, y )* I ( x, y )
Decomposition of LoG (cont’d)
Steps
Difference of Gaussians (DoG)
• The Laplacian of Gaussian can be approximated by the
difference between two Gaussian functions:
approximation
actual LoG
Difference of Gaussians (DoG) (cont’d)
ramp edge
Gradient vs LoG (cont’d)
f
Compute
derivative
in direction u
Directional Derivative (cont’d)
Directional
derivative is a
linear
combination of
(From vector calculus)
partial
derivatives.
+ =
Directional Derivative (cont’d)
||u||=1
+ =
cosθ sinθ
Higher Order Directional Derivatives
f f
f ( x, y ) cos sin
'
x y
2 2 2
f f f
f ( x, y ) 2 cos 2
'' 2
cos sin 2 sin 2
x xy y
3 f 3 f 3 f 3 f
f''' ( x, y ) cos3 3 cos 2 sin 3 cos sin 2
sin 3
x3 x 2 y xy 2
y 3
Edge Detection Using Directional Derivative
Direction of gradient:
f
x cos
f sin
y
Second Directional Derivative
(along gradient direction)
2 2 2
f f f
f'' ( x, y ) 2
cos 2
2 cos sin 2
sin 2
x xy y
f
x cos
f sin
y
Edge Detection Using Second Derivative
Laplacian:
or
z=f(x,y)
Facet Model (cont’d)
Steps
(1) Fit a bi-cubic polynomial to a small neighborhood of
each pixel (this step provides smoothing too).
Third derivative
negative implies:
Edge Detection Using Facet Model (cont’d)
Steps
Anisotropic Filtering
(i.e., edge preserving smoothing)
• Symmetric Gaussian smoothing tends to blur out edges
rather aggressively.
original
σ=4
σ=2
σ=16
σ=8