The application of the Roberts cross operator to the image of the square is shown in Figure 4.6.
The two templates provide the results in Figure 4.6(a) and (b) and the result delivered by the
Roberts operator is shown in Figure 4.6(c). Note that the corners of the square now appear in
the edge image, by virtue of the diagonal differencing action, whereas they were less apparent
in Figure 4.2(d) (where the top left corner did not appear).
(a) M
(b) M
+
(c) M
Figure 4.6 Applying the Roberts cross operator
An alternative to taking the maximum is simply to add the results of the two templates
together to combine horizontal and vertical edges. There are of course more varieties of edges
and it is often better to consider the two templates as providing components of an edge vector:
the strength of the edge along the horizontal and vertical axes. These give components of a
vector and can be added in a vectorial manner (which is perhaps more usual for the Roberts
operator). The edge magnitude is the length of the vector, and the edge direction is the vector’s
orientation, as shown in Figure 4.7.
M
Mx
θ
My
Figure 4.7 Edge detection in vectorial format
4.2.3 Prewitt edge detection operator
Edge detection is akin to differentiation. Since it detects change it is bound to respond to noise,
as well as to step-like changes in image intensity (its frequency domain analogue is high-pass
filtering, as illustrated in Figure 2.26c). It is therefore prudent to incorporate averaging within
the edge detection process. We can then extend the vertical template, Mx, along three rows,
Low-level feature extraction (including edge detection) 121
1111
00
–1
–1 –1
–1
–1
–1
0
0
0
0
1
1
(a) Mx (b) My
Figure 4.8 Templates for Prewitt operator
and the horizontal template, My, along three columns. These give the Prewitt edge detection
operator (Prewitt and Mendelsohn, 1966), which consists of two templates (Figure 4.8).
This gives two results: the rate of change of brightness along each axis. As such, this is the
vector illustrated in Figure 4.7: the edge magnitude, M, is the length of the vector and the edge
direction, , is the angle of the vector:
Mx y =
Mxx y
2
+Myx y
2
(4.12)
x y = tan
1
Myx y
Mxx y
(4.13)
Again, the signs of Mx and My can be used to determine the appropriate quadrant for the edge
direction. A Mathcad implementation of the two templates of Figure 4.8 is given in Code 4.2.
In this code, both templates operate on a 3 ×3 subpicture (which can be supplied, in Mathcad,
using the submatrix function). Again, template convolution could be used to implement this
operator, but (as with direct averaging and basic first order edge detection) it is less suited to
simple templates. Also, the provision of edge magnitude and direction would require extension
of the template convolution operator given earlier (Code 3.5).
Prewitt33_x(pic):=
2
y=0
pic
y,0
2
y=0
pic
y,2
2
x=0
pic
0,x
2
x=0
Prewitt33_
y(pic):=
pic
2,x
(a)Mx (b)My
∑∑
Code 4.2 Implementing the Prewitt operator
When applied to the image of the square (Figure 4.9a), we obtain the edge magnitude and
direction (Figure 4.9b and d, respectively, where part d does not include the border points, only
the edge direction at processed points). The edge direction in Figure 4.9(d) is shown measured
in degrees, where 0
and 360
are horizontal, to the right, and 90
is vertical, upwards. Although
the regions of edge points are wider owing to the operator’s averaging properties, the edge data
is clearer than the earlier first order operator, highlighting the regions where intensity changed
in a more reliable fashion (compare, for example, the upper left corner of the square which was
not revealed earlier). The direction is less clear in an image format and is better exposed by
Mathcad’s vector format in Figure 4.9(c). In vector format, the edge direction data is clearly
122 Feature Extraction and Image Processing

Get Feature Extraction & Image Processing, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.