Presentazione di PowerPoint
Download
Report
Transcript Presentazione di PowerPoint
Edge Detection
27th November 2012
/
Computer Vision Group
Edge Detection in Images
Goal: Automatically find the contour of objects in a scene.
What For: Edges are significant descriptors, useful for classification,
compression…
06/12/2011
Computer Vision Group
Edge Detection in Images
What is an object?
It is one of the goals of computer vision to identify objects in
scenes.
06/12/2011
Computer Vision Group
Edges May Have Different Sources
06/12/2011
Object Boundaries
Occlusions
Textures
Shading
Computer Vision Group
What is an Edge
Lets define an edge to be a discontinuity in image intensity
function.
Several Models
• Step Edge
• Ramp Edge
• Roof Edge
• Spike Edge
They can be
thus detected as
discontinuities
of image
Derivatives
06/12/2011
Computer Vision Group
Differentiation and convolution
Recall
f
f x f x
lim
0
x
Now this is linear and shift
invariant. Therefore, in
discrete domain, it will be
represented as a convolution
06/12/2011
Computer Vision Group
Differentiation and convolution
Recall
f
f x f x
lim
0
x
We could approximate
this as
f xn 1 f x
f
x
x
Now this is linear and shift (which is obviously a
convolution with Kernel
invariant. Therefore, in
1 1 ; it’s not a very
discrete domain, it will be
represented as a convolution
good way to do things, as
we shall see)
06/12/2011
Computer Vision Group
Finite Difference in 2D
f x, y
f x , y f x, y
lim
0
x
f x, y
f x, y f x, y
lim
0
y
f x, y f xn 1 , ym f xn , ym
x
x
f x, y f xn , ym1 f xn , ym
y
x
Discrete Approximation
06/12/2011
Computer Vision Group
Horizontal
1
1
Vertical
1
1
Convolution Kernels
A 1D Example
Take a line on a grayscale image
06/12/2011
Computer Vision Group
A 1D Example (II)
Filter the discrete image values, convolution against
06/12/2011
Computer Vision Group
[1 -1]
Differentiating Filters
1D Discrete derivatives
fx f *
1
0
f x ( x) f ( x 1) f ( x 1)
-1
2D Discrete derivatives (separable)
fy f *
06/12/2011
1
0
-1
t
Computer Vision Group
Classical Operators : Prewitt
Horizontal
1 1
1 1
1 1
Smooth
1
1
1 0 1
1 0 1
1 0 1
Differentiate
Vertical
1 1 1
1 1 1
06/12/2011
1
1
Computer Vision Group
1 1 1
0 0 0
1 1 1
Classical Operators: Sobel
Horizontal
1 1
2 2
1 1
1
1
1 0 1
2 0 2
1 0 1
Differentiate
Smooth
Vertical
1 2 1
1 2 1
06/12/2011
1
1
Computer Vision Group
2
1
1
0
0
0
1 2 1
Another famous test image - cameraman
06/12/2011
Computer Vision Group
Horizontal Derivatives using Sobel
y1 y * h
t
06/12/2011
Computer Vision Group
Vertical Derivatives using Sobel
y2 y * h
t
06/12/2011
Computer Vision Group
Gradient Magnitude and edge detectors
| y | y * h
06/12/2011
t
y * h
2
2
Computer Vision Group
Finite differences
I x I *1 1
I
06/12/2011
Computer Vision Group
1
Iy I *
1
The Gradient Orientation
Like for continuous function, the gradient at each pixel points at the
steepest intensity growth direction.
The gradient norm indicates the inclination of the intensity growth.
Matlab…..
06/12/2011
Computer Vision Group
Finite differences responding to noise
Increasing noise ->
(this is zero mean additive Gaussian noise)
06/12/2011
Computer Vision Group
Finite differences responding to noise
Increasing noise ->
(this is zero mean additive Gaussian noise)
06/12/2011
Computer Vision Group
Finite differences responding to noise
Increasing noise ->
(this is zero mean additive Gaussian noise)
06/12/2011
Computer Vision Group
Smoothing reduces noise
Generally expect pixels to “be like” their neighbors
•
surfaces turn slowly
•
relatively few reflectance changes
Generally expect noise processes to be independent from pixel
to pixel and with zero mean
Implies that smoothing suppresses noise, (i.i.d. noise!)
Gaussian Filtering
•
the parameter in the symmetric Gaussian
•
as this parameter goes up, more pixels are involved in the
average
•
and the image gets more blurred
•
and noise is somehow suppressed
06/12/2011
Computer Vision Group
Smoothing reduces noise
Generally expect pixels to “be like” their neighbors
•
surfaces turn slowly
•
relatively few reflectance changes
Generally expect noise processes to be independent from pixel
to pixel and with zero mean
Implies that smoothing suppresses noise, (i.i.d. noise!)
Gaussian Filtering
•
the parameter in the symmetric Gaussian
•
as this parameter goes up, more pixels are involved in the
average
•
and the image gets more blurred
•
and noise is somehow suppressed
06/12/2011
Computer Vision Group
Low - Pass
The effects of smoothing
Each row shows smoothing
with gaussians of different
width; each column shows
different realisations of
an image of gaussian noise.
06/12/2011
Computer Vision Group
Gradient Magnitude and edge detectors
| y | y * h
t
y * h
2
2
Gradient Magnitute
is not a binary
image -> “shows
edges” but “does
not allow to
identify them” yet
06/12/2011
Computer Vision Group
Detecting Edges in Image
Sobel Edge Detector
Discrete Derivatives
*
1 0 1
2 0 2
1 0 1
d
I
dx
d d
I I
dx dy
2
Image I
*
06/12/2011
2
1
1
0
0
0
1 2 1
Threshold
Gradient Norms
d
I
dy
Computer Vision Group
2
Edges
Threshold
any alternative ?
Canny Edge Detector Criteria
Good Detection: The optimal detector must minimize the probability
of false positives as well as false negatives.
Good Localization: The edges detected must be as close as
possible to the true edges.
Single Response Constraint: The detector must return one point
only for each edge point. similar to good detection but requires an
ad-hoc formulation to get rid of multiple responses to a single edge
True Edge
06/12/2011
Poor robustness to noise Poor localization Too many responses
Computer Vision Group
Canny Edge Detector
Basically 3 steps
• Convolution with derivative of Gaussian
• Non-maximum Suppression
• Hysteresis Thresholding
J. Canny “A Computational Approach to Edge Detection” IEEE PAMI vol
8, no. 6, Nov. 1986
http://perso.limsi.fr/Individu/vezien/PAPIERS_ACS/canny1986.pdf
06/12/2011
Computer Vision Group
Canny Edge Detector
Smooth by Gaussian
1
G
e
2
S G * I
Compute x and y derivatives
S S
x
S Sx
y
Sy
Compute gradient magnitude and orientation
S S S
2
x
06/12/2011
T
2
y
Computer Vision Group
tan
1
Sy
Sx
T
x2 y2
2 2
Canny Edge Operator
S G * I G * I
G
G
x
G
y
G
S
*I
x
06/12/2011
T
G
*I
y
T
Computer Vision Group
Canny Edge Detector
Sx
I
Sy
06/12/2011
Computer Vision Group
An Overview on Threshold
According to the way the Threshold T is used/determined they are
divided into
• Global Threshold
• Local (or) Adaptive Threshold
According to the output they can be classified in
• Binary Threshold
• Hard Threshold
• Soft Threshold
Matlab…
06/12/2011
Computer Vision Group
Canny Edge Detector
S S x2 S y2
I
S Threshold 25
06/12/2011
Computer Vision Group
Non-Maximum Suppression: The Idea
We wish to determine the points along the curve where the gradient
magnitude is largest.
Non-maximum suppression: we look for a maximum along a slice
orthogonal to the curve. These points form a 1D curve.
There are two issues:
• which point is the maximum,
• and where is the next one?
Original Image
06/12/2011
Gradient Magnitude
Computer Vision Group
Segment orthogonal
Non-Maximum Suppression: Quantize Gradient
Directions
For each pixel compute gradient direction and quantize it in 4 main
direction, each covering 45° (orientation is not considered)
For each pixel buld up a segment following the quantized directions
0,1,2,3
2
tanθ
3
Sy
Sx
0 : -0.4142 tanθ 0.4142
1 : 0.4142 tanθ 2.4142
2 : tanθ 2.4142
3 : - 2.4142 tanθ 0.4142
06/12/2011
1
Computer Vision Group
0
Non-Maximum Suppression – Idea (II)
A segment orthogonal
to the gradient direction
in a pixel
06/12/2011
Computer Vision Group
The intensity profile along the
segment
Non-Maximum Suppression - Threshold
Suppress the pixels in ‘Gradient Magnitude Image’ which are not
local maximum
if S x, y S x, y
S x, y
M x, y
& S x, y S x, y
0
otherwise
x, y
x, y
x, y
06/12/2011
x, y and x, y are the
neighbors of x, y in S
These have to be taken on a line along the
direction orthogonal to the gradient in (x,y)
Computer Vision Group
Non-Maximum Suppression
S S x2 S y2
M Threshold 25
06/12/2011
Computer Vision Group
M
Hysteresis Thresholding
Use of two different threshold High and Low for
• For new edge starting point
• For continuing edges
In such a way the edges continuity is preserved
06/12/2011
Computer Vision Group
Hysteresis Thresholding
If the gradient at a pixel is above ‘High’, declare it an
‘edge pixel’.
If the gradient at a pixel is below ‘Low’, declare it a ‘nonedge-pixel’.
If the gradient at a pixel is between ‘Low’ and ‘High’ then
declare it an ‘edge pixel’ if and only if it is connected to
an ‘edge pixel’ directly or via pixels between ‘Low’ and ‘
High’.
06/12/2011
Computer Vision Group
Hysteresis Thresholding
M Threshold 25
M
High 35
Low 15
06/12/2011
Computer Vision Group
Examples
an image
06/12/2011
Computer Vision Group
its detected edges
In matlab..
Canny edge detector is implemented with the
edge.m command
06/12/2011
Computer Vision Group
A brief overview on Morphological
Operators in Image Processing
Giacomo Boracchi
24/11/2010
[email protected]
home.dei.polimi.it/boracchi/teaching/IAS.htm
Computer Vision Group
An overview on morphological operations
Erosion, Dilation
Open, Closure
We assume the image being processed is binary, as these operators
are typically meant for refining “mask” images.
06/12/2011
Computer Vision Group
AND operator in Binary images
06/12/2011
Computer Vision Group
OR in Binary Images
06/12/2011
Computer Vision Group
Erosion
General definition:
Nonlinear Filtering procedure that replace to each pixel value
the minimum on a given neighbor
As a consequence on binary images
E(x)=1 iff the image in the neighbor is constantly 1
This operation reduces thus the boundaries of binary images
It can be interpreted as an AND operation of the image and the
neighbor overlapped at each pixel
06/12/2011
Computer Vision Group
Erosion Example
06/12/2011
Computer Vision Group
Erosion Example
06/12/2011
Computer Vision Group
Dilation
General definition:
Nonlinear Filtering procedure that replace to each pixel value
the maximum on a given neighbor
As a consequence on binary images
E(x)=1 iff at least a pixel in the neighbor is 1
This operation grows fat the boundaries of binary images
It can be interpreted as an OR operation of the image and the
neighbor overlapped at each pixel
06/12/2011
Computer Vision Group
Dilation Example
06/12/2011
Computer Vision Group
Dilation Example
06/12/2011
Computer Vision Group
In matlab
They are performed using the
bwmorph.m script passing the name of the operation as a parameter
Examples…
06/12/2011
Computer Vision Group
Open and Closure
Open Erosion followed by a Dilation
Closure Dilation followed by an Erosion
06/12/2011
Computer Vision Group
Open
Open Erosion followed by a Dilation
• Smoothes the contours of an object
• Typically eliminate thin protrusions
06/12/2011
Computer Vision Group
Open
Figure to Open,
Structuring element a Disk
06/12/2011
Computer Vision Group
Open
First Erode,
06/12/2011
Computer Vision Group
Open
Then Dilate,
Open results, the bridge has been eliminate from the first erosion and cannot
be replaced by the dilation.
Edges are smoothed
Corners are rounded
06/12/2011
Computer Vision Group
Closure
Closure Dilation followed by an Erosion
• Smoothes the contours of an object, typically creates
• Generally fuses narrow breaks
06/12/2011
Computer Vision Group
Open
Figure to Open,
Structuring element a Disk
06/12/2011
Computer Vision Group
Close
First Dilate,
06/12/2011
Computer Vision Group
Close
Then Erode,
Close results, the bridge has been preserved
Edges are smoothed
Corners are rounded
06/12/2011
Computer Vision Group
There are several other Non Linear Filters
Ordered Statistic based
• Median Filter
• Weight Ordered Statistic Filter
• Trimmed Mean
• Hybrid Median
Thresholding
06/12/2011
Computer Vision Group
Fitting – A brief Introduction
We assume that the images are generated from a “straight lines”
word.
By performing edge detection we are only able to select those pixels
that belongs to an edge
We are not able to determine if such an edge is a straight line, and in
case it is, which are the parameters of such line
06/12/2011
Computer Vision Group
Fitting – A brief Introduction
Let now assume we are interested in detecting lines only, and we
want to determine the parameters of such a lines
Line Fitting can be performed via
• Hough Transform
• Error minimization
• Maximum Likelihood
But we have to determine first how the process generating data is:
i.e.
• Observation are noisy, how is noise affecting straight lines?
06/12/2011
Computer Vision Group
Fitting – A brief Introduction
There are different noise models
1. Noise displaces line pixels orthogonally to the straight line and it
is gaussian distributed
2. Noise displaces line pixels only along the y coordinate and it is
gaussian distributed
Then, in both case there exist a closed form solution
Or it can be performed via numerical minimization … matlab
06/12/2011
Computer Vision Group
Fitting and Convolution
One can prove that the least square fit of polynomial of 0-th order (i.e
constant) is given by
where
and thus
06/12/2011
Computer Vision Group
Frequency Response of Differential Kernel
f x
f x
x
06/12/2011
Fourier
Transform
Fourier
Transform
F f u
uF f u
Computer Vision Group
Canny Edge Detector
Difficult to find closed-form solutions.
06/12/2011
Computer Vision Group
Noise
Simplest noise model
• independent stationary
additive Gaussian noise
• the noise value at each pixel
is given by an independent
draw from the same normal
probability distribution
06/12/2011
Computer Vision Group
Issues
•
this model allows noise values
that could be greater than
maximum camera output or
less than zero
•
for small standard deviations,
this isn’t too much of a
problem - it’s a fairly good
model
•
independence may not be
justified (e.g. damage to lens)
•
may not be stationary (e.g.
thermal gradients in the ccd)
Finite differences and noise
Finite difference filters respond strongly to noise
• obvious reason: image noise results in pixels
that look very different from their neighbors
The more relevant is the noise, the stronger the
response
06/12/2011
Computer Vision Group
Finite differences and noise
06/12/2011
What is to be done?
• intuitively, most pixels in images look quite a lot
like their neighbors.
• this is true even at an edge; along the edge
they’re similar, across the edge they’re not.
• suggests that smoothing the image should help,
by forcing pixels different to their neighbors
(=noise pixels?) to look more like neighbors.
Computer Vision Group
Gaussian Filter
x2 y2
G x, y
exp
2
2
2
2
1
i k 12 j k 12
H i, j
exp
2
2
2
2
1
where H i, j is 2k 1 2k 1 array
06/12/2011
Computer Vision Group