Lecture 6: Edge Detection: Dmitrij Csetverikov
Lecture 6: Edge Detection: Dmitrij Csetverikov
Lecture 6: Edge Detection: Dmitrij Csetverikov
Eotv
os Lorand University
Budapest, Hungary
Dmitrij Csetverikov
with help of Attila Lerch, Judit Verestoy, Zoltan Megyesi, Zsolt Janko
and Levente Hajder
http://visual.ipan.sztaki.hu
Edge localisation
Non-maxima suppression
Hysteresis thresholding
Zero-crossing edge detector
2
Edge detection
Edge
Line
Blob
Corner
blurred edge
Edge profiles.
4
Edge localisation
edge magnitude
edge orientation
original image
edge map
edge orientation
original image
edge magnitude
edge orientation
edge map
Intensity profiles along lower (left) and upper (right) lines drawn in original image
edge
normal
edge
direction
Edge filters
Edge filters are high-pass filters using spatial derivatives of intensity function to
enhance intensity variation across the edge
edge
orientation
r,c w(r, c)
=0
step edge
response
noisy edge
response
10
W1
object
original image
W2
Assume that the intensity function f (x, y) is sufficiently smooth. The intensity
gradient is the following vector:
f f
,
x y
.
f (x, y) =
= fx , f y
original image
The magnitude M (x, y) and the orientation (x, y) of the gradient vector are
obtained as follows:
M (x, y) = kf (x, y)k =
intensity surface
thresholded image
fastest growth
edge
direction
intensity surface
fx2 + fy2
gradient =
edge normal
fx
(x, y) = arctan
fy
level lines
The gradient vector gives the direction and the magnitude of the fastest growth
of intensity.
13
14
1
p
1
2p
1
Gx
0
0
0
1
p2
1
1
p
1
0
1
Gy
2p
0
p2
1
0
1
Prewitt
3
Sobel
4
Isotropic
2+ 2
When p = 2 + 2, the mask weights reflect the proximity to the mask origin.
The operator becomes less sensitive to edge orientation.
15
16
r,c Gx (r, c)
r,c Gy (r, c)
= 0.
4. Normalised response to ideal step edge of unit height: For such edge, the
output value should be 1.
Using these constraints, the above family of gradient masks can be derived from
a general unconstrained 3 3 mask: 9 free parameters reduce to 1.
The most frequently used are the Prewitt and the Sobel operators whose
X-masks are as follows:
Prewitt
Sobel
1 0 1
1 0 1
1
1
1 0 1
2 0 2
3
4
1 0 1
1 0 1
The Y -masks are obtained by 90 rotation of the X-masks.
The Prewitt operator is the simplest and the fastest.
The Canny edge detector is optimal for noisy step edge under the following
assumptions:
The edge filter is linear.
The image noise is additive, white (uncorrelated) and Gaussian.
The optimality criterion used by Canny combines
good detection and
good localisation
To satisfy the single response criterion, two post-processing (edge localisation)
operations are used:
Non-maxima suppression
Hysteresis thresholding
17
18
20
Edge localisation
Non-maxima suppression
Input: edge magnitude M (x, y) and edge orientation (x, y) in each pixel of
the image.
Due to the multiple response, edge magnitude M (x, y) may contain wide ridges
around the local maxima.
Localisation selects those maxima of M (x, y) that correspond to true edge pixels.
Can be applied after any edge filter that computes a measure of edge strength
and provides edge orientation.
Gradient: Canny, Prewitt
Non-gradient: For example, Mero and Vassy
3. If the M (A) > M (C) or M (B) > M (C), discard the pixel (x, y) by setting
M (x, y) = 0.
22
Hysteresis thresholding
normal
direction
M(C)>M(A)
pixel A
pixel B
The output of the non-maxima suppression still contains noisy local maxima.
M(C)>M(B)
pixel C
edge magnitude
result of NMS
C4
C3
C2
1. In each position of (x, y), discard the pixel (x, y) if it is weak; output the pixel
if it is strong.
2. If the pixel is a candidate, follow the chain of connected local maxima in both
directions along the edge, as long as MN M S > Tlow .
weak edge
strong edge
C1
candidate edge
original image
edge magnitude
5, 20
20, 40
26
Implementation of the zero crossing filter: Gaussian smoothing followed by
Laplacian filtering.
Steep edge
Blurred edge
f(x)
+
df
__
dx
wZ (r) = C
+
0
Double edge
___f
_d
dx 2
+
0
Zero crossing
2
r2
r
1 exp
2
2 2
C: normalisation constant
r2 = x2 + y 2: square distance from centre of mask
is scale parameter: the smaller the the finer the edges obtained
Discrete zero-crossing mask: Threshold wZ (r) at a small level.
Larger mask obtained for larger : For example, when = 4 the size of the
mask is about 40 pixels.
28
= 10
LoG absolute
LoG zero
DoG zero
29
30
= 15
= 20
Prewitt 3 3
Mero-Vassy 7 7
LoG 21 21
Canny 3 3
Canny 7 7
Canny 25 25
Examples of edge detection by different operators. The LoG result was obtained
with removal of weak edges. Mero-Vassy is a non-gradient edge detector.
32