46
5.2. EDGE DETECTION
49
-1 0 1
1 1 1
-1 -1 -1
0 1 0
-1 0 1
0 0 0
-1 8 -1
-1 0 1
-1 0 1
-1 -1 -1
-1 -1 -1
0 -1 0
Figure 5.2: Masks Used by Faler for Edge Detection
transition point in the edge. Convolving [-1 0 1] with a line performs a type
of dierentiation or edge detection.
The number of masks used for edge detection is almost limitless. Re-
searchers have used dierent techniques to derive masks and then experi-
mented with them to discover more masks. Figure 5.3 shows four masks used
in the source code and examples in this chapter. The rst three masks are
the Kirsch, Prewitt, and Sobel masks as given in Levine’s text [5.2] (there are
dierent masks bearing the same name in the literature) [5.3]. The fourth
mask, the \quick" mask, is one I \created" while working on this process
(there is no doubt that someone else created this mask before me).
The Kirsch, Prewitt, and Sobel masks are \compass gradient" or direc-
tional edge detectors. This means that each of the eight masks detects an
edge in one direction. Given a pixel, there are eight directions to travel to
aneighboring pixel (above, below, left, right, upper left, upper right, lower
left, and lower right). Therefore, there are eight possible directions for an
edge. The directional edge detectors can detect an edge in only one of the
eight directions. To detect only left to right edges, use only one of the eight
masks. To detect all of the edges, perform convolution over an image eight
times using each of the eight masks. The \quick mask" is so named because
it can detect edges in all eight directions in one convolution. This has obvious
speed advantages. There are, however, occasions when detecting one type of
edge is desired, so use a directional mask for those occasions.
There are two basic principles for each edge detector mask. The rst
is that the numbers in the mask sum to zero. If a 3 x 3 area of an image
contains a constant value (such as all ones), then there are no edges in that
area. The result of convolving that area with a mask should be zero. If the
numbers in the mask sum to zero, convolving the mask with a constant area
will result in the correct answer of zero. The second basic principle is that
the mask should approximate dierentiation or amplify the slope of the edge.
The simple example [-1 0 1] given earlier showed how to amplify the slope of
the edge. The rst Kirsch, Prewitt, and Sobel masks use this idea to amplify