Page 72 -
P. 72
46 Chapter 2 ■ Edge-Detection Techniques
In this specific case, the situation is clear. The direction of the gradient is
horizontal, and the neighboring pixels used in the comparison are exactly the
left and right neighbors. Unfortunately, this does not happen very often. If the
gradient direction is arbitrary, then following that direction will usually take
you to a point in between two pixels. What is the gradient there? Its value
cannot be known for certain, but it can be estimated from the gradients of the
neighboring pixels. It is assumed that the gradient changes continuously as a
function of position, and that the gradient at the pixel coordinates are simply
sampled from the continuous case. If it is further assumed that the change in
the gradient between any two pixels is a linear function, then the gradient at
any point between the pixels can be approximated by a linear interpolation.
C
X
X X y X
Ay
y B
A Ax
(a) (b) (c)
Figure 2.13: Non-maximum suppression. (a) Simple case, where the gradient direction is
horizontal. (b) Most cases have gradient directions that are not horizontal or vertical, so
there is no exact gradient at the desired point. (c) Gradients at pixels neighboring A are
used to estimate the gradient at the location marked with ‘‘+.’’
A more general case is shown in Figure 2.13b. Here, the gradients all point
in different directions, and following the gradient from the center pixel now
takes us in between the pixels marked ‘‘x’’. Following the direction opposite
to the gradient takes us between the pixels marked ‘‘y’’. Let’s consider only
thecaseinvolving the‘‘x’’ pixels, as shown in Figure 2.13c, since the other
case is really the same. The pixel named A is the one under consideration, and
pixels B and C are the neighbors in the direction of the positive gradient. The
vector components of the gradient at A are A x and A y ,and thesamenaming
convention will be used for B and C.
Each pixel lies on a grid line having an integer x and y coordinate. This
means that pixels A and B differ by one distance unit in the x direction. It must
be determined which grid line will be crossed first when moving from A in the
gradient direction. Then the gradient magnitude will be linearly interpolated
using the two pixels on that grid line and on opposite sides of the crossing