Professional Documents
Culture Documents
Edge Detection 2
Edge Detection 2
Given a discrete image I (~n), consider the smoothed continuous image B (~x) defined by
X
B (~x) = G(~x; r2 ) I (~n) G(~x ~k; r2 )I (~k); (1)
~k
~x 2
. Here j~xj is the 2-norm for the vector ~x That is, j~xj
j j
Note that G(~x) does not satisfy the interpolation conditions G(~0) = 1 and G(~ n) = 0 for integer
valued ~n 6= 0. Therefore B (~x) does not in general interpolate the original discrete image I (~n) (i.e.,
~
generally B (~n) 6= I (~n) for integer valued image coordinates ~n). Instead B (~x) provides a smoothed
approximation of the image I (~n) at ~x = ~n.
The gradient of a smooth image B (~x) is defined to be the vector of partial derivatives,
@B @B
r~ B (~x) (
@x
(~
x);
@y
x))T :
(~ (2)
Note the derivative of a 2D Gaussian is the separable product of a 1D Gaussian times the derivative
of a 1D Gaussian, as in
@G x
(~
x; r2 ) = G(~x; r2 )
@x r
2
x
= G(x; r ) G(y ; r ) ;
2 2
r2
where G(x; r2 ) = p21 e x =(2r ) is a one-dimensional Gaussian. Therefore separable convolution
2 2
r
can be used to compute the image gradient according to equations (2), (3) and (4) above.
Implementation Details. Typically the radius K of the discrete filter support is taken to be K =
3r . This gives 1D filter kernels of length 2K + 1. Moreover, in order to avoid strong discretization
artifacts in sampling the Gaussian, typically r 1 is used. The smallest gradient filters of this type
are therefore 7 1 and 1 7, which are used for r =1 (see cannyTutorial.m).
320: Edge Detection Notes: 12
Properties of Gradients
What does the image gradient r
~ B (~x) tell us about the local image brightness? To understand this,
consider the directional derivative of the image at ~x in the direction ~u = (u1 ; u2 )T , defined by
dB
D~u B (~x) x + ~ut)jt=0 ;
(~
dt
@B d @B d
= (~
x + ~ut) (x + u1 t) + x + ~ut) (y + u2 t)
(~ by the chain rule;
@x dt @y dt t=0
T
= r~ B (~x) ~u: (5)
Therefore, given the gradient, we can easily compute the directional derivative in any direction ~u.
Note that from equation (5) we see D~u B (~x) = 0 for directions ~u orthogonal to the gradient r
~ B (~x).
The image gradient is therefore orthogonal to curves of constant intensity, i.e. contours satisfying
B (~x(t)) = c, for any constant c.
The steepest ascent direction ~u (at a particular value of ~x) is defined to be the unit vector which
maximizes the directional derivative D~u B (~x). From equation (5) this steepest ascent direction is
given by
~u = r
~ B (~x)=jr
~ B (~x)j; (6)
p
where jw
~j = w12 + w22 denotes the Euclidean norm (i.e., 2-norm). Thus the gradient points in the
steepest ascent direction.
If the gradient r
~ B (~x) =~
0, then ~x is said to be a stationary point of B (~x). Typically this is a local
minimum, maximum or saddle point in B (~x). At a stationary point ~x, the directional derivative
D~u B (~x) = 0 for any direction ~u, and therefore the steepest ascent direction is undefined at such an
~x (i.e., a divide by zero occurs in equation (6)).
~u(~x)
R~ (~x) :
jR~ (~x)j
=
x
In practice, the search for local maxima of S (~ ) takes place on the
discrete sampling grid. Given ~x , with normal ~n , compare S (~x ) to
0 0 0
nearest integer.
l l l l l
l l l l l
l l l l l
x n
The red circle depicts points ~ 0 2 sin(1=8) ~ 0. Normal directions be-
tween (blue) radial lines all map to the same neighbour of ~ 0. x
320: Edge Detection Page: 15
Canny Edge Detection
Algorithm:
R~ (~x) x
(R1 (~ ); R2(~x) )T = r~ G(~x; r ) I (~x) :
2
p
2. Compute response magnitude, S (~ ) = x R12(~x) + R22(~x) .
3. Compute local edge orientation (represented by unit normal):
(
~n(~x) =
x
(R1 (~ ); R2(~x))=S (~x) x
if S (~ ) > threshold
~0 otherwise
Gradient in x Gradient in y
Colour gives gradient direction (red – 0Æ; blue – 90Æ; green – 270Æ)
Edgels (x 2) Edgels (x 4)
Approach:
John Canny, ”A computational approach to edge detection.” IEEE Transactions on PAMI, 8(6):679–
698, 1986.
James Elder and Richard Goldberg, ”Image editing in the contour domain.” IEEE Transactions on
PAMI, 23(3):291–296, 2001.