8
COMPUTER GRAPHICS AND IMAGE PROCESSING (1975)4, 55-62 A New Algorithm for Edge Detection* M. W. SMITHt ANO W. A. DAVIS Department of Computing Science, University of Alberta, Edmonton, Alberta, Canada Communicated by A. Rosenfeld Received June 10, 1974 This paper presents a new algorithm for the detection of edges in grey level pictures. This algorithm is based on the amount of clustering of the grey levels in a square neighborhood. The algorithm is first developed for binary regions and then extended to include grey level regions. For the multilevel case two procedures are given, one of which is then implemented and tested on a reference picture. The test results are included. 1. INTRODUCTION This paper presents a new algorithm for the detection of edges in multilevel pictures. Edge detection is an important aspect of picture processing since the major portion of the information content of a picture is contained in the edges. A picture is defined as a rectangular matrix of integers, where the matrix ele- ments represent the average brightness level of the corresponding region in the original image. This brightness value is commonly referred to as the grey level. The matrix elements are referred to as picture elements (pixels or pels). An edge element (edgel) is a pixel on the boundary, or border, between two neighboring picture regions which differ in some measurable characteristic by a threshold T. Edge detection is the process Of assignment to each element p of a picture ma- trix an indication of the likelihood that p is an edgel. The immediate concern, in this paper, is to identify edges which can be characterized by a brightness transi- tion between regions. Therefore textured edges are excluded from consideration, since these will involve a somewhat different approach. Edge detection schemes may be classified into two categories: sequential and parallel. Parallel detection schemes access and process all pixels simultaneously and output the obtained edges in parallel. On the other hand, sequential methods access the pixels serially, and on the basis of a neighborhood of pixels, assign a likelihood to the pixel in question. Although edge operators have been compared elsewhere r1 ], it is important to the ensuing discussion that their characteristics be briefly mentioned. While the following list may not be complete, the characteristics listed are clearly relevant. a. Speed. The length of time needed for an operator to determine the edges in a picture matrix. b. lsotropy. The insensitivity to edge orientation. * This research was supported in part by NRC grant A-7634. ? Current address: Department of National Defence, Ottawa, Ontario, Canada, 55 Copyright © 1975by AcademicPress, Inc. All rights of reproduction in any form reserved.

A New Algorithm for Edge Detection

Embed Size (px)

Citation preview

Page 1: A New Algorithm for Edge Detection

COMPUTER GRAPHICS AND IMAGE PROCESSING (1975)4, 55-62

A New Algorithm for Edge Detection*

M. W. SMITHt ANO W. A. DAVIS

Department of Computing Science, University of Alberta,

Edmonton, Alberta, Canada

Communicated by A. Rosenfeld Received June 10, 1974

This paper presents a new algorithm for the detection of edges in grey level pictures. This algorithm is based on the amount of clustering of the grey levels in a square neighborhood. T h e algorithm is first developed for binary regions and then extended to include grey level regions. For the multilevel case two procedures are given, one of which is then implemented and tested on a reference picture. T h e test results are included.

1. INTRODUCTION This paper presents a new algorithm for the detection of edges in multilevel

pictures. Edge detection is an important aspect of picture processing since the major portion of the information content of a picture is contained in the edges.

A picture is defined as a rectangular matrix of integers, where the matrix ele- ments represent the average brightness level of the corresponding region in the original image. This brightness value is commonly referred to as the grey level. The matrix elements are referred to as picture elements (pixels or pels).

An edge element (edgel) is a pixel on the boundary, or border, between two neighboring picture regions which differ in some measurable characteristic by a threshold T.

Edge detection is the process Of assignment to each element p of a picture ma- trix an indication of the likelihood that p is an edgel. The immediate concern, in this paper, is to identify edges which can be characterized by a brightness transi- tion between regions. Therefore textured edges are excluded from consideration, since these will involve a somewhat different approach.

Edge detection schemes may be classified into two categories: sequential and parallel. Parallel detection schemes access and process all pixels simultaneously and output the obtained edges in parallel. On the other hand, sequential methods access the pixels serially, and on the basis of a neighborhood of pixels, assign a likelihood to the pixel in question.

Although edge operators have been compared elsewhere r1 ], it is important to the ensuing discussion that their characteristics be briefly mentioned. While the following list may not be complete, the characteristics listed are clearly relevant.

a. Speed. The length of time needed for an operator to determine the edges in a picture matrix.

b. lsotropy. The insensitivity to edge orientation.

* This research was supported in part b y N R C grant A-7634.

? Current address: Depar tment of National Defence, Ottawa, Ontario, Canada,

55

Copyright © 1975 by Academic Press, Inc. All rights of reproduction in any form reserved.

Page 2: A New Algorithm for Edge Detection

5 6 SMITH AND DAVIS

c. Type response. Response to different types of edges. d. Dynamic range. The effectiveness over varying brightness ranges. e. Noise. The ability to detect edges in varying noise conditions. f. S torage costs. The storage required during computation. g. Universality. The degree of machine system independence of the operator. h. Adaptabili ty. The ability to change, expand, or otherwise adapt the para-

meters to varying picture conditions during computation.

2. ANOTHER EDGE DETECTOR

Edge detection is defined in terms of the probability that some element p (i , j) is on the border between two regions. Then, given two and only two contiguous regions in one's field of view it seems mandatory to assume the presence of one edge, and thus at least one edgel. In other words, identifying two and only two regions in a field of view is equivalent to identifying one edge in that field.

In a one-demensional binary matrix, such as 00001111000110, note by the above statements that the five binary regions produce four edges. On a more local examination, to wit, 011, two regions are noted, and thus one edge. Since this is a one-dimensional picture only one edgel per edge is possible. It is normal to assign the central pixel of the examined area as the edgel.

In the above examples there is no doubt involved in our identification of a region; however, there is also no doubt that the converse is the norm. One is usually uncertain, to some extent, in the categorization of some area as a "region." This uncertainty must therefore extend to the identification and la- beling of the associated edge. Thus one can say that the degree of certainty with which two and only two regions in the field of view are identified corresponds to the degree of certainty that one edge is present.

Further sections will develop this degree of certainty into an algorithm for edge detection, both in the binary and the grey level matrix cases. This measure will take the form of a difference sum, DS; whereby the sum of absolute dif- ferences of pixel values across a picture segment will be suggested as being in- versely related to the probability of the presence of an edge oriented orthogon- ally to the scan.

For the purposes of this paper those subsets of picture matrices whose grey levels satisfy some spatial statistical distribution criteria, and whose elements are edgewise contiguous, will be distinguished as "regions."

Binary Regions

A binary region is characterized by the presence of a subset of ones and zeros, whose quantity ratio is prescribed by the statistical constraints for that region. For example, one might insist that the regions contain exclusively ones or zeros, thus forcing a unimodal distribution over the region. On the other hand, the defi- nition of an even mixture of ones and zeros as characterizing a region would give rise to a balanced biomodel distribution.

Using a unimodal distribution to detect edges would require the satisfaction of that criterion over two adjacent areas each with a different binary value. For ex- ample, it is an easy matter to:

Page 3: A New Algorithm for Edge Detection

N E W EDGE D E T E C T I O N A L G O R I T H M 5 7

I 1 0 1 1 1 0 0

o i o 1 i l o o

0 0 0 0 1 1 0 0

1 1 0 1 1 1 0 0

a b

Ft{]. 1. Balanced bimodality. (a) Many edges. (b) One edge.

a. examine one area and determine its distribution as unimodal in ones, then declare it to be a "1" region;

b. examine an adjacent area and determine it as unimodal in zeros, and declare it a "0" region;

c. conclude that there is an edge between these two regions; d. assign an edge indication to some element(s) on the border between them.

N o t e that one might observe both of the above areas at once under bimodal distribution criteria. The confirmation of bimodality would again seem to in- dicate the presence of an edge. The obvious danger of this more efficient method is illustrated in Fig. 1. Note that both regions are balanced bimodal, but that only Fig. lb contains one edge. Therefore , confirming that a balanced bimodal dis- tr ibution is present is not enough. One must ascertain that each binary level is positionally grouped or clustered (to some arbitrary extent) in order for an edge to be indicated. Chow and Kaneko [2] measure the variance of the neigh- bo rhood surrounding a point to determine bimodality, but do not check the order of clustering of this neighborhood.

D a e e y and Tung [3, pp. 84-85] list three methods for identifying randomness in point patterns. To detect the degree of clustering they prefer their "Orde r Method , " which amounts to measuring the distance to a point 's nearest k neighbors, for all points in the examined area. The variability of this distance measure is shown to be proportional to the randomness of the distribution. T h e r e are computational and efficiency problems with this method. One must select k properly, define "distance," and compute this distance kn times. Finally, a variance calculation is done and compared against some criterion of ran- domness. The C P U time taken for this operation is a function o f the density of the neighbors in the pattern, and is thus unpredictable from pattern to pattern.

These problems lead to the proposal of a suboptimal procedure to indicate the degree of " randomness" in a point pattern distribution. This disorder is then related to the number of edges in the pattern. The procedure is suboptimal in that texture shows a high degree of disorder, and will tend to cause edges to be missed.

The Difference Sum Measure of "Disorder"

The difference sum (DS) over an m × m binary submatrix b is computed as

DS = H D S + VDS = bi~ - + b~ - . i=l i~2

(1)

Page 4: A New Algorithm for Edge Detection

58 SMITH AND DAVIS

In words, DS, in (1), is computed by summing the absolute differences between all pairs of horizontally and vertically adjacent pixels.

Considering the extent of clustering or grouping of identical values in a binary matrix as a reflection of the degree of "order" in the matrix, it can be seen that DS is inversely proportional to that order. For example, consider the one-dimen- sional matrix 00001111. Here maximum clustering occurs, reflected by a DS of 1. On the other hand, 01010101 shows minimum cluster size with D S = 7. There is an identity relationship, implied by the definition, between DS and the n , m b e r of microedges (not edgels) in the matrix.

Given a balanced bimodal distribution over an m-by-m binary matrix, it is clear that DS cannot be less than m. Consider Fig. 2a. No other configuration exists that will reduce the number of 1-0 pairs to less than 4 = m. Note that the number of microedges formed is identical to DS, and is also a minimum. Fig. 2b shows another balanced bimodal distribution with DS = 6. In this pattern the grouping of l 's is slightly less pronounced. Therefore, 1/DS reflects the com- pactness of clustering by measuring the length of the border between the two binary values. Given balanced bimodality, 1/DS will be considered proportional to the probability of the existence of two distinct adjacent regions within the pat- tern. From a previous paragraph, two distinct adjacent regions give rise to one edge.

At this point it is noted that straight diagonally oriented edges, although intui- tively as "sharp" as vertical or horizontal edges, are not as positively indicated by the DS measure. In fact, the DS computation indicates a diagonal edge to be one-third weaker than the same step edge oriented vertically (horizontally). This anisotropy is highly undesirable, and will be largely countered by "unbalancing" the modality measure when a diagonal edge is suspected (i.e., when VDS = HDS). This unbalancing reflects the difference in the size of two regions separated by a diagonal edge, when the area examined is square.

To measure the balance of a bimodal distribution one could define some simple linear measure. For example, compute the frequency of occurrence of one binary value within a pattern of n elements denoted by f ; then the function (n/2) - - I (n/2) - f l is linear, and peaks at n/2. However, to provide a sharper cutoff (and consequently narrower edges), and to accommodate the need for a slight imbalance by diagonal edges, the following nonlinear general function is proposed.

f(Zs - f ) ,

1 1 1 1 1 1 1 1

1 1 1 1 1 1 1 0

0 0 0 0 1 0 0 0

0 0 0 0 0 0 0 0

a b Fie. 2, Degree of clustering. (a) Maximum clustering. (b) Nonmax clustering.

Page 5: A New Algorithm for Edge Detection

N E W EDGE DETECTION ALGORITHM 59

where s is the desired region size containing elements of frequencyf. Since the derivative of the above function with respect to f i s 2s -- 2f, it is a maximum at f = s. If one desires an exact balance, then the general formula transforms to f ( n - - f ) . Using a 4-by-4 subarray size, f ( 1 6 - f ) results. For diagonal edges in this same array, a reasonable choice for s is 10. Our slightly unbalanced modal measure then becomes f(20 - f ) .

From the foregoing one can consolidate the formula for the edge merit (EM) of an arbitrary (but usually central) pixel of an m-by-m submatrix B as

EM = f ( 2 s --f) /DS, (2)

where s is the desired number of elements within the region, f is the actual frequency derived, and DS is the difference sum measure. Note that the constant 1 in the function 1/DS (mentioned earlier in this section) has been replaced by

f(2s -- f ) to account for DS near zero over a highly unbalanced bimodal region.

Grey Level Regions

A grey level region is characterized by integer pixel values whose range over all regions is commonly 0-63, and over one region is defined by the prescribed statistical constraints for that region. For example, one might insist that a grey level region comprise grey levels whose values are identical, with a resulting sharp unimodal distribution. On the other hand, one might weaken the criteria for region definition to the extent that the distribution would be mesokurtic- shaped or even flatter.

Arguments similar to those used in the section on binary regions again lead to the proposal of a suboptimal procedure to indicate the "degree of randomness' in the statistical distribution of a grey level pattern. This disorder is then as- sociated with the likelihood of the existence of an edge therein. Again, it is tex- tured regions that result in the suboptimality.

Two versions of the procedure are presented here. The first is measurably faster, and less complicated; however, it lacks flexibility, and is weak with diag- onal edges. The second, since it is a direct outgrowth of the binary algorithm; must treat each of the grey level values as one of the two binary values, with resulting complications in making that decision. However, ease in selecting the balance of the bimodality desired, and in emphasizing diagonal edges, along with more freedom from noise effects, seem to make this second method worthwhile. For convenience, refer to the first method as the Grey Level Deviation Method, and the second as the Grey Level Modality Method. It is emphasized here that both methods use the difference sum postulate explained earlier.

No computer algorithm will be given for the two methods since the mechani- zation is straightforward and simple.

Grey Level Deviation Method

This algorithm uses two measures: a. Mean deviation (MD). The average difference of a set of n numbers from

their arithmetic mean. This measure emphasizes the degree of separation of the elements on one side of the average from those on the other. Given a range of n

Page 6: A New Algorithm for Edge Detection

60 SMITH A ND DAVIS

elements from a through b, MD maximizes with n/2 a-values and n/2 b-values. Thus, it peaks on a balanced bimodat distribution with widely separated modes, and with a given range. This last qualification means that two different ranges could have the same MD but markedly different modality characteristics. Addi- tionally, there is no easy way to "tune" this measure to peak on diagonal edge distributions. These liabilities, however, are to a degree counteracted by the next measure.

b. Difference sum (DS). As mentioned previously, the sum of the positive dif- ferences across a pattern in the horizontal direction (HDS), and in the vertical direction (VDS). The measure 1/DS-- I / (HDS + VDS) maximizes when the grey level values are identical. Given an exactly balanced bimodal distribution, this measure is large when the elements are, in a positional sense, tightly clus- tered.

Combining these two measures into equation form we have

Edge Merit (EM) = MD/ (HDS + VDS).

Given an n-by-n grey level matrix G, the following procedure will transform it into an edge matrix B by determining the existence of an edgel centered on all m-by-m submatrices (with origin (i,j)) over G. The type of edgel will be in- dicated as vertical (1), or horizontal (2), according to the relative weights of H D S and VDS. Equality between them will require an arbitrary decision. The edgels will be marked as follows.

B(i, j) = (1 o r2)

if EM(i + int (rn/2), j + int (m/2)) ----- MD/DS > T, or equivalently, if Total Deviation > T*DS*me;

B (i,j') = 0 otherwise.

This GL deviation method is characterized by: a. partiality to steplike edges; b. edge-width detection as a function of the size of the submatrix used in the

scanning process; c. weaker responses from diagonal edges than from vertical or horizontal,

which thus cannot be absolutely identified; d. uniquely marked vertical and horizontal edges; e. a threshold T that needs no dynamic modification; f. salt-and-pepper noise, which tends to drive the EM below threshold, with

the loss thereby of possible edges (this effect could be partially countered by ex- ponentiating the MD prior to the threshold check);

g. the normally used scan's being regular and exhaustive, although it could readily be made context sensitive (i.e., the direction of motion of the scan could be a weighted function of the types of the n previous edgels).

Grey Level Modality Method

This method uses two measures. a. Modal measure, f (2s -J ' ) , the same measure used for binary matrices, but

operable on a transformed subset of a grey level matrix.

Page 7: A New Algorithm for Edge Detection

NEW EDGE DETECTION ALGORITHM 6]

b. Difference sum. Again the same measure used for binary matrices, and also operable on a transformation of the GL matrix.

in essence, this method is identical to the binary algorithm @er: a. the elements of the m-by-m submatrix have been examined (i.e., the arith-

metic mean and/or the median and/or the range has been computed); b. the elements of the submatrix have been transformed into one of the binary

values according to some criteria determined in step (a) immediately above, and in perhaps the n immediately preceding examinations.

Thus, one operates on the resulting simulated binary matrix to produce an edge matrix, as explained in the binary algorithm case.

It is obvious that the crucial phase of this procedure is subparagraph (b) imme- diately above. Perhaps the easiest choice is to compute the arithmetic mean of the elements, then assign l's to those above it, and 0's to those below. The best transformation, however, is not easily proven. The grey level modality method (using the arithmetic mean as a threshold for the binary decision) has the same characteristics as the GL deviation method above, except that:

a. diagonal edges can be detected with about the same strength as vertical and horizontal edges;

b. salt-and-pepper noise effects are not as serious; c. exhaustive scanning can be transformed into an eight-directional contextual

scan. That is, diagonal edges can also be traced. However, this can only be done if a separate structure is available to maintain the grey level matrix in its original form throughout the complete operation.

/1 Reasonable Test

Analytically, it is difficult to decide which of the above two methods is more worthwhile. One must balance the value of diagonal edge detection, and opera- tion in the presence of noise against the worth of higher-speed operation and rel- ative ease of implementation. However, in order to make a reasonable compari- son among other local methods of edge detection [5], one of the above methods

FIG. 3. Reference picture. FIG. 4, Edges detected from the reference picture.

Page 8: A New Algorithm for Edge Detection

62 SMITH AND DAVIS

Fro. 5. Distribution of grey level values.

was chosen. Arbitrarily, a variant of the Grey Level Modality Method was implemented as a local, exhaustive edge detector with a 4-by-4 submatrix size. It had a secondary threshold input parameter included.

The results of applying the operator to real pictures [4] is given in Figs. 3-5.

3. CONCLUSIONS

In conclusion, a new algorithm for edge detection has been presented. While the algorithm requires considerable computation, the edges produced are crisp and sharp. A proper comparative analysis has not been presented, but has been comple ted [1] and is the subject of an additional paper currently in process [5].

REFERENCES

l. M. W. Smith, On the detection of edges in pictures, M.Sc. Thesis, University of Alberta, 1973. 2. C. K. Chow and T. Kaneko, Boundary detection of radiographic images by a threshold method,

I F I P Congr. 71, North Holland, Amsterdam, August 1971, Booklet TA-7, pp. 130-134. 3. M. F. Dacey and T. H. Tung, The identification of randomness in point patterns, J. Req. Sci. 4,

1962, 83-96. 4. W. A. Davis, R. N. McPherson, M. W. Smith, and N. Tsang, A system for processing digital pic-

tures, Proc. 3rd Man-Computer Communications Seminar, NRC, Ottawa, May 1973. 51 W. A. Davis and M. W. Smith, An evaluation of edge detection algorithms, in preparation.