constraints on the design of template masks for edge detection

10
Pattern Recognition Letters 4 (1986) 11 I-120 North-Holland April 1986 Constraints on the design of template masks for edge detection E.R. DAVIES Pattern Recognition & Industrial Inspection Group, Department of Physics, Royal Holloway & Bedford New College, Egham Hil, Egham, Surrey TW20 OEX, United Kingdom Received 11 January 1985 Revised 21 January 1986 Abstract: This paper studies the design of template masks for edge detection, and develops the underlying theory with particular reference to computational accuracy. The concept of circularity is shown to be important for the design of ‘general purpose’ template matching operators. A number of design constraints are enunciated: in particular it is found that different masks are required for the accurate estimation of edge magnitude and edge orientation; in either case they need to be tailored to the rele- vant edge profile. The Sobel coefficient is obtained in the closed form (13fi-4)/7=2.055. Key words: Edge detection, Sobel operator, template matching, operator design, industrial inspection, image processing. 1. Introduction 2. Edge detection Although image analysis has developed rapidly over the past decade, some parts of the subject have progressed at a rather slower rate. For exam- ple, there are often many ways of tackling in- dividual image interpretation tasks, but it is not always clear which of them will be the most effi- cient, or the most accurate, robust, or resistant to noise. Thus there is considerable scope for theory which will help one to choose between alternative approaches, or to optimise a given approach. In addition, there is a clear need for guidelines that can help one during the process of algorithm design. The present paper aims to provide a set of guidelines and constraints for one case of interest Traditionally image segmentation has been tackled in two main ways - by the extraction and linking of region edge points [I], and by ‘region growing’ techniques [2]. The fact that region grow- ing can proceed too far and miss edges that are subjectively significant [2] has meant that in in- dustrial and robotics applications, edge detection has become the normal means of initiating segmen- tation [3]. In addition, the needs of speed and economy tend to mean that sophisticated operators of the Hueckel [4-61 or ‘difference of Gaussian’ [7,8] type cannot readily be employed, since they are too computation-intensive. - that of the design of template masks for edge detection. Section 2 reviews the topic of edge detection, and Section 3 considers the differential gradient and template matching methods. Section 4 then studies the detailed design of template masks for edge detection. Finally, Section 5 lists a set of guidelines that have arisen out of this research. This paper is particularly concerned with ‘fast’ edge detection operators. Two approaches are par- ticularly relevant in this scenario: one is the dif- ferential gradient (DG) type of operator typified by the Sobel edge detector [9, lo]; the other is the template matching (TM) technique [l 11. Both ap- proaches are very widely used, and are quite old in concept [ 12,131. However, existing masks for these approaches appear rather ad hoc, and their theory 0167-8655/86/$3.50 0 1986, Elsevier Science Publishers B.V. (North-Holland) 111

Upload: er-davies

Post on 21-Jun-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Constraints on the design of template masks for edge detection

Pattern Recognition Letters 4 (1986) 11 I-120North-Holland

April 1986

Constraints on the design of template masks foredge detection

E.R. DAVIESPattern Recognition & Industrial Inspection Group, Department of Physics, Royal Holloway & Bedford New College,Egham Hil, Egham, Surrey TW20 OEX, United Kingdom

Received 11 January 1985

Revised 21 January 1986

Abstract: This paper studies the design of template masks for edge detection, and develops the underlying theory with particularreference to computational accuracy. The concept of circularity is shown to be important for the design of ‘general purpose’template matching operators. A number of design constraints are enunciated: in particular it is found that different masks arerequired for the accurate estimation of edge magnitude and edge orientation; in either case they need to be tailored to the rele-vant edge profile. The Sobel coefficient is obtained in the closed form (13fi-4)/7=2.055.

Key words: Edge detection, Sobel operator, template matching, operator design, industrial inspection, image processing.

1. Introduction 2. Edge detection

Although image analysis has developed rapidlyover the past decade, some parts of the subjecthave progressed at a rather slower rate. For exam-ple, there are often many ways of tackling in-dividual image interpretation tasks, but it is notalways clear which of them will be the most effi-cient, or the most accurate, robust, or resistant tonoise. Thus there is considerable scope for theorywhich will help one to choose between alternativeapproaches, or to optimise a given approach. Inaddition, there is a clear need for guidelines thatcan help one during the process of algorithmdesign. The present paper aims to provide a set ofguidelines and constraints for one case of interest

Traditionally image segmentation has beentackled in two main ways - by the extraction andlinking of region edge points [I], and by ‘regiongrowing’ techniques [2]. The fact that region grow-ing can proceed too far and miss edges that aresubjectively significant [2] has meant that in in-dustrial and robotics applications, edge detectionhas become the normal means of initiating segmen-tation [3]. In addition, the needs of speed andeconomy tend to mean that sophisticated operatorsof the Hueckel [4-61 or ‘difference of Gaussian’[7,8] type cannot readily be employed, since theyare too computation-intensive.

- that of the design of template masks for edgedetection.

Section 2 reviews the topic of edge detection,and Section 3 considers the differential gradientand template matching methods. Section 4 thenstudies the detailed design of template masks foredge detection. Finally, Section 5 lists a set ofguidelines that have arisen out of this research.

This paper is particularly concerned with ‘fast’edge detection operators. Two approaches are par-ticularly relevant in this scenario: one is the dif-ferential gradient (DG) type of operator typifiedby the Sobel edge detector [9, lo]; the other is thetemplate matching (TM) technique [l 11. Both ap-proaches are very widely used, and are quite old inconcept [ 12,131. However, existing masks for theseapproaches appear rather ad hoc, and their theory

0167-8655/86/$3.50 0 1986, Elsevier Science Publishers B.V. (North-Holland) 111

Page 2: Constraints on the design of template masks for edge detection

Volume 4, Number 2 PATTERN RECOGNITION LETTERS April 1986

is still being developed. Davies has proposed anunderlying rationale for the DG type of operator,which permits suitable masks to be designed syste-matically [14]: central to this work is the ‘circularoperator’ concept. The present paper makes asimilar study of the TM type of operator and in-vestigates the impact of the circular operator con-cept in this case. The emphasis is on finding prin-ciples that permit the accuracy of the TM approachto be optimised.

approach, it is estimated vectorially by the morecomplex equation

0 = arctan(g, /g,). (5)

Clearly the DG formulae (2) and (5) are con-siderably more computation-intensive than the TMformula (l), but they are also more accurate. Thusit is normal to employ the TM instead of the DGapproach except where high accuracy is involved.

3. Simple approaches to edge detection

Since both approaches essentially involve esti-mation of local intensity gradients, it is not surpris-ing that the TM masks are often identical to, orgeneralised from, DG masks - see Tables 1 and 2.

3. I. Basic theory 3.2. Differential gradient masks

Both DG and TM operators estimate local inten-sity gradients with the aid of suitable convolutionmasks. In the case of the DG type of operator, on-ly two such masks are required - for the x and ydirections. In the TM case, it is usual to employ upto twelve convolution masks, capable of estimatinglocal components of gradient in the different direc-tions [ll, 13,15,16].

In the TM approach, the local edge gradientmagnitude (or for short, the edge ‘magnitude’) isapproximated by taking the maximum of theresponses for the component masks:

g=max(gi: i= 1 to n) (1)

where n is usually 8 or 12.In the DG approach, the local edge magnitude

may be computed vectorially using the non-lineartransformation

g= [g;+g;]“? (2)

In order to save computational effort, it is com-mon practice [16] to approximate this formula byone of the simpler forms

g=lg,l+lg,l (3)

or

DG masks for 3 x 3 and larger neighbourhoodshave been analysed in [14] and will not be discuss-ed in detail here. However, it is pertinent that thePrewitt operator was derived by determining howbest a plane can be fitted to pixel intensity valueswithin a square 3 x 3 neighbourhood [13]. For along time this was regarded as the optimum DGoperator, the similar Sobel operator being regard-ed as effective [16] but ad hoc [14]. It has now beenshown that for a vectorial approach to be accurate,masks must be computed within a ‘circular’ neigh-bourhood (see below) by least squares’ fitting ofpixel intensity values to a local plane [14]: this con-sideration makes the Sobel operator theoreticallyalmost ideal, and explains its superior accuracy forthe estimation of edge orientation.

Table 1Masks of well-known 3 x 3 differential gradient edge operators

(a) Masks for the Prewitt 3x3 operator:

P,= [i ; ;] Py= [; p ;]

(b) Masks for the Sobel 3 x 3 operator:

g=max(lg,L lg& (4)

which are on average equally accurate [17].In the TM approach, edge orientation is esti-

mated simply as that of the mask giving rise to thelargest value of gradient in equation (1). In the DG

s,= [; i ;] Sy= r_e _p _;I

In this table masks are presented in an intuitive format (viz.coefficients increasing in the positive x and y directions) byrotating the normal convolution format through 180”. Thisconvention is employed throughout this paper.Mask weighting factors have been omitted for simplicity, asthey are throughout this paper.

112

Page 3: Constraints on the design of template masks for edge detection

Volume 4, Number 2 PATTERN RECOGNITION LETTERS April 1986

Table 2Masks of well-known 3 x 3 template matching edge operators

0” 45”

(a) Prewitt masks:

(b) Kirsch masks:

(c) Robinson ‘3-level’ masks:

(d) Robinson ‘S-level’ masks:

I -1 -1 1 -2 -1 1 1 1 1 1II -3 -3 -3 -3 0 5 -3 5 5 1

i -1 -1 0 -1 01 1 1 1 1

I -1 -2 0 -1 01 1 0 2 1

The table illustrates only two of the eight masks in each set: theremaining masks can in each case be generated by symmetryoperations. For the 3-level and Slevel operators, four of theeight available masks are inverted versions of the other four (seetext).

The significance of a circular neighbourhoodwill now be briefly summarised. In a discrete lat-tice the rules of vector algebra break down, andknowledge of the x and y components of intensitygradient results in inaccurate estimations of edgeorientation. Calculations relating to a continuousspace indicate that neighbourhoods are ideallystrictly circular in shape: in addition, adjustingmask coefficients using a radial weighting so thatthe discrete masks approximate to circularity verymuch improves the available accuracy. This situa-tion is optimised by a number of specific choices ofneighbourhood radius, the Sobel operator cor-responding to the smallest of the resulting ‘cir-cular’ operators [ 141.

3.3. Template matching masks

Table 2 shows four sets of well-known TMmasks for edge detection. These masks were origi-nally [ll, 13,151 introduced on an intuitive basis,starting in two cases from the DG masks shown inTable 1. In all cases the eight masks of each set are

obtained from a given one by permuting mask CO-

efficients cyclically. By symmetry, this is a goodstrategy for even permutations, but symmetryalone will not justify it for odd permutations. Inview of the recent work by Davies on circularoperators, this process of mask generation must beregarded as ad hoc and in need of further study.

Note first that four of the ‘3-level’ and four ofthe ‘Slevel masks can be generated from the otherfour of their set by sign inversion. This means thatin either case only four convolutions need be per-formed at each pixel neighbourhood, thereby sav-ing computational effort. This is an obvious pro-cedure if we regard the basic idea of the TM ap-proach as one of comparing intensity gradients inthe eight directions. The two operators which donot employ this strategy were developed muchearlier on some unknown intuitive basis.

Before proceeding, we recall the rationalebehind the Robinson ‘Slevel masks. These wereintended [ 1 I] to emphasise the weights of diagonaledges in order to compensate for the characteristicsof the human eye, which tends to enhance verticaland horizontal lines in images. Normally, imageanalysis is concerned with computer interpretationof images and an isotropic response is required.Thus the ‘Slevel operator is a special-purpose onethat need not be discussed further here.

These considerations show that the four templateoperators mentioned above have limited theore-tical justification: what is especially important isthat there seems to be nog general basis for re-designing these operators, or adapting them to dif-ferent circumstances, such as the detection ofedges of different profiles, or operation in largerneighbourhoods. This situation will be examinedin more detail below.

4. Detailed analysis and improvement of existingmasks

4. I. Responses of existing 3 x 3 template masks

Before analysing the performance of TM opera-tors, we note that they are likely to be used with avariety of types of edge, including in particular the‘sudden step’ edge, the ‘slanted step’ edge, the

113

Page 4: Constraints on the design of template masks for edge detection

Volume 4, Number 2 PATTERN RECOGNITION LETTERS April 1986

a br

--_/-

___

____-I ___-/

C d---- _/*

1 /___ .*’

f n

,I’ ‘\\ ___ii__-

Figure 1. Edge models. (a) ‘sudden step’ edge, (b) ‘slanted step’edge, (c) ‘smooth step’ edge, (d) ‘planar’ edge, (e) ‘roof’ edge,(f) ‘line’ edge. The effective profiles of edge models are non-zero ony within the stated neighbourhood. The slanted step andthe smooth step are approximations to realistic edge profiles:the sudden step and the planar edge are extreme forms that areuseful for comparisons (see text). The roof and line edge modelsare shown for completeness only, and are not considered fur-

ther in this paper.

‘planar’ edge, and various intermediate edge pro-files (see Figure 1). We will regard the sudden stepedge and the planar edge profiles as paradigmswhich form useful tests of the performance of edgetemplate masks: these two comparisons should besufficient since most relevant edge profiles will liebetween these extremes.

Table 3 lists computed angular variations for the

Table 3Angular variations for well-known 3 x 3 TM operators

(a) Prewitt operator

Sudden step edge response

edge 0” 45”angle mask mask

Planar edge response

edge 0” 45”angle mask mask

0 . 0 0 3.00 2.00 0.00 3.00 2.005.00 3.00 2.17 5.00 2.99 2.17

10.00 3.00 2.35 10.00 2.95 2.3215.00 3.00 2.54 15.00 2.90 2.4520.00 2.99 2.72 20.00 2.82 2.5625.00 2.91 2.85 25.00 2.72 2.6630.00 2.77 2.92 30.00 2.60 2.7335.00 2.57 2.97 35.00 2.46 2.7940.00 2.32 2.99 40.00 2.30 2.8245.00 2.00 3.00 45.00 2.12 2.83

change-over angle = 26.5” change-over angle = 26.5”

(b) Kirsch operator

Sudden step edge response

edge 0” 45”angle mask mask

0.00 12.00 8.005.00 12.00 8.70

10.00 12.00 9.4015.00 12.00 10.1420.00 11.98 10.8925.00 11.66 11.3830.00 11.08 11.6935.00 10.26 11.8840.00 9.26 11.9845.00 8.00 12.00

change-over angle = 26.5”

(c) Robinson 3-level operator

Planar edge response

edge 0” 45Oangle mask mask

0.00 12.00 8.005.00 11.95 8.67

10.00 11.82 9.2715.00 11.59 9.8020.00 11.28 10.2525.00 10.88 10.6330.00 10.39 10.9335.00 9.83 11.1440.00 9.19 11.2745.00 8.49 11.31

change-over angle = 26.5”

Sudden step edge response

edge 0” 45Oangle mask mask

0.00 3.00 2.005.00 3.00 2.17

10.00 3.00 2.3515.00 3.00 2.5420.00 2.99 2.7225.00 2.91 2.8530.00 2.77 2.9235.00 2.57 2.9740.00 2.32 2.9945.00 2.00 3.00

change-over angle = 26.5”

(d) Robinson 5-level operator

Planar edge response

edge 0” 45”angle mask mask

0.00 3.00 2.005.00 2.99 2.17

10.00 2.95 2.3215.00 2.90 2.4520.00 2.82 2.5625.00 2.72 2.6630.00 2.60 2.7335.00 2.46 2.7940.00 2.30 2.8245.00 2.12 2.83

change-over angle = 26.5”

Sudden step edge response

edge 0” 45”angle mask mask

0.00 4.00 3.005.00 4.00 3.17

10.00 4.00 3.3515.00 4.00 3.5420.00 3.99 3.7225.00 3.91 3.8530.00 3.77 3.9235.00 3.57 3.9740.00 3.32 3.9945.00 3.00 4.00

change-over angle = 26.5”

Planar edge response

edge 0” 45”angle mask mask

0.00 4.00 3.005.00 3.98 3.25

10.00 3.94 3.4815.00 3.86 3.6720.00 3.76 3.8525.00 3.63 3.9930.00 3.46 4.1035.00 3.28 4.1840.00 3.06 4.2345.00 2.83 4.24

change-over angle= 18.5”

four sets of 3 x 3 TM operators. These were ob-tained by simulations in which each pixel wasdivided into 31 x 31 sub-pixels, and the responsesfor a given edge profile averaged: similar simula-tions were performed in [14]. A rather unexpected

114

Page 5: Constraints on the design of template masks for edge detection

Volume 4. Number 2 PATTERN RECOGNITION LETTERS April 1986

outcome of these computations is the fact that thefour sets of masks have very similar angular pro-perties for step-edges, the change-over from a 0” toa 45” estimate of angle occurring at 26.5”. It is per-tinent (a) that the angle is the same in each case,and (b) that it is not the ideal value of 22.5” in anyinstance. It will be shown below that this reflectsan underlying theoretical constraint.

The angular variations of these operators for aplanar edge seem very similar to those for a stepedge, with the sole exception of the ‘5-level’ opera-tor. In view of the remarks made in Section 3, thisis not too surprising. As far as magnitude estima-tions are concerned, all four operators are equallygood for a step edge (having equal responses at 0”and 45”) and for a planar edge (where the responsesat 0” and 45” are in the ratio of 3 : 2\/2, or the in-verse of this).

Finally, angular sensitivity seems closely similarin all cases, except for the Prewitt operator. Thislack of sensitivity can be attributed to the coeffi-cients - 1,2, - 1 along the axis corresponding to theoptimal edge line for each mask, since these coeffi-cients are absent in the otherwise identical ‘3-level’operator masks.

At this stage it does not appear that any of theexisting operators offers any particular advan-tages, and it is not obvious how they can be im-proved. Detailed analysis of the situation is there-fore necessary.

4.2. Theory of 3 x 3 template operators

In this analysis of 3 x 3 template operators, itwill be assumed that eight masks are to be used, forangles differing by 45”. In addition, four of themasks will differ from the others only in sign, sincethis seems unlikely (see Sections 3 and 4.1) to resultin any loss of performance. Symmetry require-ments then lead to the following masks for 0” and45” respectively:

[:a ; ;], [_“c _zc ;j.

These masks are as general as possible, within theconstraints already stated: they are more generalthan the masks used by Kittler [18], which were

t

Figure 2. Geometry for the computation of step edge responsesin a 3 x 3 neighbourhood. a shows the angle of the step edge,and r, U, V, W, X, Y represent the areas of various triangles andother shapes, the area S of a single pixel being taken as unity.

restricted to the case A = C, B = D. For simplicity,calculations will follow the case of a step edge on-ly, but this will be adequate to reveal a number ofimportant points.

For a step edge, the computation devolves intoa determination of the areas of various trianglesand other shapes shown in Figure 2. As a result thestep edge responses are computed for the 0” maskare:

0” response =2A+B,

45” response =A+B,

o-axis response = (1 +X+ Y- W)A + B

=2(1- W)A+B,

and for the 45” mask as:

0” response =C+D,

45” response =2C+D,

a-axis response-(1 + T+ U- V)C+D

=2(1- V)C+ D.

(6)

(7)

(8)

(9)

(IO)

(II)

(The a-axis response expressions given above areonly correct for o in the range arctan(l/3) I (Y I

11s

Page 6: Constraints on the design of template masks for edge detection

Volume 4, Number 2

arctan 1.) Values for the areas Vin terms of (Y by the expressions

V= (1 - tan c~)~/8 tan a

and

W= (3 tan a - 1)2/8 tan ~1.

PATTERN RECOGNITION LETTERS April 1986

and W are given now proceed with the first of these strategies.If the primary constraint on the masks is that

they are to be circular in shape, then the coeffi-cients should be weighted according to their radialdistances, and they must obey the relations B = Cand A =D. Equations (6) and (9) now show thatfor the operator to give equal magnitude responsesat 0” and 45”, all coefficients A, B, C,D must beequal. This shows that the Robinson 3-level opera-tor is in fact ‘circular’ in this sense. However, aswe have seen in Section 3, this operator leads to aninaccuracy in the estimation of edge orientation. Ifinstead we equate the responses of the two masksat 22.5”, the angular variations should be optimis-ed. This leads to the formula

Applying these formulae to the 3-level and 5level operators (see Table 2) immediately leads tothe additional conditions A = C, B =D. Thus theoperator responses for 0” and 45” step edges areexactly equal. (It is easy to see that this is also truefor the Prewitt and Kirsch operators.) This wasclearly one of the original design ideas in each case.It is also possible to determine the angle (Y at whichthe 0” and 45” masks give equal responses. Thisoccurs for

2(1- W)A +B=2(1- I’)C+D

which leads (for operators with A = C and B = D)to

w= v.

Clearly, this means that a= arctan(l/2) or 26.5”,exactly as found experimentally (see Section 4.1).However, we have shown here that 26.5” is thechange-over angle for any operator of the abovetype in which 45” masks are generated from 0”masks merely by permuting coefficients cyclically.A more complex calculation has shown that 26.5”is the change-over angle for any set of masks inwhich the 0” mask has reflection symmetry in thex-axis, and the 45” mask is obtained by permutingthe coefficients cyclically. This explains the factthat all four masks in Table 2 have a change-overangle of 26.5”.

A possible method for improving on the perfor-mance of the existing operators might be to assumea ‘circular’ operator of the type suggested byDavies [14]. There are two ways in which thismight be approached. One is to assume very simplythat the mask coefficients are those correspondingto the circular shape, and then to apply other rele-vant conditions to fully determine the mask coeffi-cients. The other is to enter the spirit of the calcu-lation in [14], by noting that we are really attempt-ing to estimate local intensity gradients, and thento find how this affects the mask coefficients. We

116

B/z4=(9t2-10t+l)/(t2-6t+l)

where t=tan22.5”, so that

B/A =(17-6t/z)/7= 1.216= l/0.822.

The resulting masks are shown in Table 4 togetherwith their angular variations. Clearly, this operatorgives an improved angular accuracy for both a stepedge and a planar edge, though for a step edge itis able to estimate edge magnitude along the maskaxis directions somewhat less accurately than theother operators.

Table 4Angular variations for the ‘circular shape’ operator

0” mask

I -0.822 -1.000 -0.822 0.000 0.000 0.000 0.822 0.822 1.000 I

Sudden step edge response

edge 0” 45Oangle mask mask

45” mask

I - -0.822 0.000 1.000 -1.000 0.000 1.000 0.822 0.000 1.000 1

Planar edge response

edge 0” 45Oangle mask mask

0.00 2.64 1.82 0.00 2.64 1.825.00 2.64 2.00 5.00 2.63 1.91

10.00 2.64 2.17 10.00 2.60 2.1115.00 2.64 2.36 15.00 2.55 2.2320.00 2.64 2.55 20.00 2.48 2.3425.00 2.57 2.67 25.00 2.40 2.4230.00 2.45 2.75 30.00 2.29 2.4935.00 2.29 2.19 35.00 2.17 2.5440.00 2.08 2.82 40.00 2.03 2.5145.00 1.00 2.82 45.00 I .87 2.58

change-over angle = 22.5” change-over angle = 24.5”

Page 7: Constraints on the design of template masks for edge detection

Volume 4, Number 2 PATTERN RECOGNITION LETTERS April 1986

If instead we interpret the need for operator cir-cularity as reflecting an underlying need to makeaccurate estimates of intensity gradient [14], thenwe arrive at a rather different situation. In particu-lar we note that intensity gradients should followthe rules of vector addition. If the pixel intensityvalues within a 3 x 3 neighbourhood are

a b cqd e fg h i

then estimation of the 0”, 90” and 45” componentsof gradient by our general masks gives

g,=A(c+i-a-g)+B(_-d),

g,=A(a+c-g-i)+B(b-h),

g,, = C(b +f- d - h) + D(c - g).

If vector addition is to be valid, then

g45 = (go + &o)/fi.

Equating coefficients of a, b, c, d, e, f, g, h, i leads tothe self-consistent pair of conditions

C = B/\lZ, D=A.\IZ.

These conditions form a basic requirement for a‘circular’ operator. A further requirement is forthe masks to give equal responses at 22.5”. Thisleads to the formula

B/A=\jZ[9t2-(14-4fi)+1]/[t2-(lo-4fi)t+l]

where t = tan 22.5”) so that

B/A = (13v9- 4)/7 = 2.055.

This is encouraging, since it gives a value for B/Ain line with that deduced in [14] for an optimisedSobel operator. In fact the value of B/A obtainedin [14] is 0.959/0.464=2.067 kO.015, and it mustbe remembered that the computation in [14] was anumerical one. What is more important is that thevalue for the idealised Sobel coefficient (B/A)deduced here is exact, and appears in closed form.This seems to be the first time that the Sobel coeffi-cient has been obtained in closed form by anymethod, though the present approach provides arather indirect method of calculation. It is interest-ing that as recently as 1983 it was stated [18]

Table 5Angular variations for the ‘vector addition’ operator

0” mask

i -2.055 -1.000 - 1.000 0.000 0.000 0.000 2.055 1.000 1.000 1

Sudden step edge response

edge 0” 45”angle mask mask

0.00 4.06 2.875.00 4.06 3.12

10.00 4.06 3.3815.00 4.06 3.6520.00 4.05 3.9225.00 3.97 4.1030.00 3.82 4.2135.00 3.62 4.2740.00 3.37 4.3145.00 3.06 4.32

change-over angle = 22.5”

45” mask

I - -1.414 0.000 1.453 -1.453 0.000 1.453 0.000 1.453 1.414 1

Planar edge response

edge 0” 45”angle mask mask

0.00 4.06 2.875.00 4.04 3.11

10.00 3.99 3.3215.00 3.92 3.5120.00 3.81 3.6725 .oo 3.68 3.8130.00 3.51 3.9235.00 3.32 3.9940.00 3.11 4.0445.00 2.87 4.06

change-over angle = 22.5”

“In practice the [Sobel] coefficient K is normallyset to 2 but this particular value has an intuitivebasis only.”

The angular variations obtained with thesemasks are shown in Table 5. They are peculiar ingiving optimal estimates of edge orientation forboth step and planar edges, and in giving relativelyaccurate estimates of edge magnitude for planaredges. However, their magnitude response for stepedges is not particularly accurate.

Thus three operators have now been obtained bythe two main strategies for generating a ‘circular’operator. These operators have different charac-teristics, one (identical to the ‘3-level’ operator) be-ing optimal for estimating edge magnitude for astep edge profile, another being optimal for esti-mating orientation for a step edge, and anotherthat is optimal for a planar edge.

It is worth asking whether an operator can bedesigned that is optimal in estimating both magni-tude and orientation with a step edge. We may pro-ceed by equating the operator responses at 0” and45”, and also the two mask responses arising at22.5”. This leads to the formulae

2A+B=2C+D,

2(1- W)A+B=2(1- V)C+D.

117

Page 8: Constraints on the design of template masks for edge detection

Volume 4, Number 2 PATTERN RECOGNITION LETTERS April 1986

Subtracting to eliminate B and D leads to the for-mula

A/C=(1-t)2/(3f- 1)2

where t= tan 22.5”, so that

A/C= 3 + 2fi= 5.83.

Setting C= 1 and solving for D, leaving B as theonly undetermined parameter, gives the 0” and 45”masks:

L-1 ; XI].

i

0 1 (9.66+ B)-1 0 1 .

-(9.66+B) -1 0 1

Note that B must not be less than zero or thetemplate matching procedure of determining themask of maximum response will give misleadingresults. An interesting set of masks arises for B = 0;their angular variations are shown in Table 6(a).Clearly these are more consistent in their step edgeresponse than any of the other masks so far con-sidered. In addition they can be optimised by vary-

Table 6Angular variations for some theoretically derived operators

(a) Case of B=O (see Section 4.2)

0” mask 45’ mask

-5.830 0.000

il

5.830 0.000 1.000 9.6600.000 0.000 0.000 -1.000 0.000 1.000

-5.830 0.000 I: I-5.830 -9.660 I-1.000 0.000

Sudden step edge response Planar edge response

edge 0” 45” edge 0” 45”

angle mask mask angle mask mask

0.00 11.66 10.66 0.00 11.66 10.665.00 11.66 10.83 5.00 11.62 11.55

10.00 11.66 11.01 10.00 11.48 12.3515.00 11.66 11.20 15.00 11.26 12.0620.00 11.62 11.38 20.00 10.96 13.6625.00 11.16 11.51 25.00 10.57 14.1730.00 10.31 11.58 30.00 10.10 14.5635.00 9.12 11.63 35.00 9.55 14.8540.00 1.67 11.65 40.00 8.93 15.0245 .oo 5.83 11.66 45.00 8.24 15.08

change-over angle = 22.5” change-over angle = 6”

118

(b) Case of B adjusted for optimal planar response

0” mask 45” mask

I -5.830 -5.830 8.240 0.000 0.000 0.000 -8.240 5.830 5.830 i I -1.000 -1.414 0.000 -1.000 0.000 1.000 0.000 1.414 1.000 1

Sudden step edge response Planar edge response

edge 0” 45” edge 0” 45”angle mask mask angle mask mask

0.00 3.42 2.41 0.00 3.42 2.415.00 3.42 2.59 5.00 3.41 2.62

10.00 3.42 2.76 10.00 3.37 2.8015.00 3.42 2.95 15.00 3.30 2.9620.00 3.38 3.14 20.00 3.21 3.0925.00 2.92 3.26 25.00 3.10 3.2130.00 2.07 3.34 30.00 2.96 3.3035.00 0.88 3.38 35.00 2.80 3.3640.00 -0.57 3.41 40.00 2.62 3.4045.00 -2.41 3.41 45.00 2.42 3.41

change-over angle = 22.5” change-over angle = 22.5”

(c) Case of isotropic step edge response

0” mask

i -1 0 0 0 0 0 0 0 1 11

Sudden step edge response

edge 0” 45”angle mask mask

0.00 1.00 1.005.00 1.00 1.00

10.00 1.00 1.0015.00 1.00 1.0020.00 1.00 1.0025.00 1.00 1.0030.00 1.00 1.0035.00 1.00 1.0040.00 1.00 1.0045.00 1.00 1.00

change-over angle = 22.5”

45” mask

iI -I 0 0 0 0 0 0 0 I I

Planar edge response

edge 0” 45”angle mask mask

0.00 1.00 1.005.00 1.00 1.08

10.00 0.98 1.1615.00 0.97 1.2220.00 0.94 1.2825.00 0.91 1.3330.00 0.87 1.3735.00 0.82 1.3940.00 0.77 1.4145.00 0.71 1.41

change-over angle = 0”

ing B so that the planar variations also give an op-timal response (see Table 6(b)).

Finally, a careful look at equations (6) to (11)shows that coefficients B and D produce an iso-tropic contribution to the step-edge response forthe 0” and 45” masks. This suggests that forgreatest angular sensitivity these coefficientsshould be kept small, though the situation will in-evitably be more complicated for a planar edge.On the other hand, for least angular sensitivity,

Page 9: Constraints on the design of template masks for edge detection

Volume 4. Number 2 PATTERN RECOGNITION LETTERS April 1986

and hence greater constancy and accuracy in theestimation of edge magnitude, we may set B=Dand A = C=O. As shown in Table 6(c), thisstrategy works well for step edges, but is not goodfor planar edges.

4.3. Comparison of the new operators

Two approaches stand out in Section 4.2 as giv-ing estimates of edge orientation and magnitudethat are close to optimal. One is the second im-plementation of a ‘circular’ TM operator (Table5), based on the strategy of making rigorous, con-sistent estimates of intensity gradient. The other isthe operator (Table 6(b)) based on the strategy ofoptimising both the magnitude and the orientationresponses for step edges, with the one remainingparameter adjusted to make the operator also res-pond accurately with planar edges.

Although the operator of Table 6(b) gives slight-ly greater accuracy than the circular operator ofTable 5, it is significant that it achieves this accur-acy by partial cancellation between the responsesof relatively large mask coefficients of oppositesign. This means that it will perform poorly in thepresence of noise. (If noise is Gaussian, then noiseresponse is essentially proportional to the r.m.s.value of the mask coefficients [17].) This meansthat, overall, the second type of circular operatorreflects a design strategy that is the simplest andyet the most systematic and general, and at thesame time more resistant to noise than the otherstrategies considered here.

5. Summary - Design constraints and conclusions

This paper has studied existing template masksfor edge detecting and examined the underlyingtheory. Detailed calculations have led to the designof new TM operators having a variety of character-istics. During this work a number of design aimshave become evident:- the need to optimise accuracy in the estimation

of edge magnitude;- the need to optimise accuracy in the estimation

of edge orientation;

- the need to optimise sensitivity in the estimationof edge orientation;

- the need to suppress noise during edge detection;- the need to optimise operators for different edge

profiles;- the requirement that operators optimised for

one edge profile must not act anomalously fordifferent profiles that might arise in practicalsituations.Not only have these design aims been made ex-

plicit, but also they have constantly been found toconflict with each other. This has meant that trade-offs between them exist, and compromises have tobe made. The following specific conclusions havebeen arrived at:- Different masks are needed for the accurate esti-

mation of edge magnitude and orientation.- Optimisation of sensitivity and optimisation of

accuracy in the estimation of edge orientationimpose different conditions on TM masks.

- Obtaining sets of masks by permuting coeffi-cients ‘cyclically’ in a square neighbourhood isunsound (though it might well be provide a goodgeneral strategy in a large circular neighbour-hood).

- Use of ‘circular’ operators provides a good stra-tegy for ensuring the accuracy of TM operatorsin estimation of edge magnitude and orientation.

- The vector addition approach to the design ofcircular masks is optimal for planar edge pro-files, but also gives acceptable results for stepedges.

- There is a danger in tailoring masks specificallyfor step edge profiles, since they may then havepoor responses for planar and other edge pro-files.Perhaps oddly, this appears to be the first time

it has been pointed out that different templates arerequired for the optimal estimation of edge magni-tude and edge orientation, and that they need to betailored to a representative set of edge profiles. Ata procedural level, the concept of circular opera-tors has been shown to form the basis of a soundmethod for constructing accurate sets of TMmasks. Finally, the idealised Sobel coefficient of[14] has for the first time been obtained in closedform, as a byproduct of this work.

119

Page 10: Constraints on the design of template masks for edge detection

Volume 4, Number 2 PATTERN RECOGNITION LETTERS April 1986

Acknowledgement

This work was carried out with the support of agrant from the UK Science and Engineering Re-search Council.

References

[1] Pratt, W.K. (1978). Digital Image Processing. Wiley, NewYork.

[2] Hall, E.L. (1979). Computer Image Processing and Re-cognition. Academic Press, New York-London.

[3] Gonzalez, R.C. and R. Safabakhsh (1982). Computer vi-sion techniques for industrial applications and robot con-trol. Computer 15(12), 17-32.

[4] Levialdi, S. (1981). Finding the edge. In: J.C. Simon andR.M. Haralick, Eds., Digital Image Processing, ReidelDordrecht, pp. 105-148.

[5] Hueckel, M.F. (1971). An operator which locates edges indigitised pictures. J. ACM 18(l), 113-125.

[6] Hueckel, M.F. (1973). A local visual operator whichrecognises edges and lines. J. ACM 20(4) 634-647.

(71 Marr, D. and E. Hildreth (1980). Theory of edge detection.Proc. Royal Sot. London B207, 187-217.

[8] Brady, M. (1982). Computational approaches to imageunderstanding. Computing Surveys 14(l), 3-71.

[9] Duda, R.O. and P.E. Hart, (1973). Pattern Classificationand Scene Analysis. Wiley, New York, p. 271.

[lo] Pringle, K.K. (1969). Visual perception by a computer. Ch.13 in: A. Grasselli, Ed., Automatic Interpretation andClassification of Images. Academic Press, New York, pp.277-284.

[11] Robinson, G.S. (1977). Edge detection by compass gra-dient masks. Computer Graphics and Image Processing 6,492-501.

[12] Roberts, L.C. (1965). Machine perception of three-dimensional solids. Ch. 9 in: J. Tippett et al., Eds., Opticaland Electra-optical Information Processing, MIT Press,Cambridge, MA, pp. 159-197.

[13] Prewitt, J.M.S. (1970). Object enhancement and extrac-tion. In: B.S. Lipkin and A. Rosenfeld, Eds., Picture Pro-cessing and Psychopictorics, Academic Press, New York,pp. 75-149.

[14] Davies, E.R. (1984). Circularity - A new principle underly-ing the design of accurate edge orientation operators. Im-age and Vision Computing 2(3), 134-142.

[15] Kirsch, R.A. (1971). Computer determination of the con-stituent structure of biological images. Computers andBiomedical Research 4, 315-328.

[16] Abdou, I.E. and W.K. Pratt (1979). Quantitative designand evaluation of enhancement/thresholding edge detec-tors. Proc. IEEE 67(5), 753-763.

[17] Foglein, J. (1983). On edge gradient approximations. Pat-tern Recognition Letters 1, 429-434.

[18] Kittler, J. (1983). The template edge detector and its per-formance. In C.H. Chen, Ed., Issues in Acoustic Signal/Image Processing and Recognition. NATO AS1 series, Vol.Fl, Springer, Berlin-Heidelberg, pp; 296-307.

120