0031 - 3203/87 $3.00+ .00 Pergamon Journals Lid. Pattern Recognition Society
Pattern Recognition. VoL 20, No. 3, pp. 291-296, 1987. Primed in Grea! Brilain.
AN I M P R O V E D CORNER DETECTION ALGORITHM BASED ON C H A I N - C O D E D PLANE CURVES H. LYNN BEUS TMCB 232, Computer Science Dept., Brigham Young University, Provo, UT 84602, U.S.A. and STEVENS. H. Ttu Box 7021 University Station, Provo, UT 84602, U.S.A. (Received 29 April 1986; in revised form I 1 September 1986)
Abstract-- One possible measure of corners on chain-coded plane curves is the product of the length of the uniform chain sections to either side (the forward and backward arms) of a point, times the angle of discontinuity of that particular point. This paper describes a corner detection algorithm which performs close to humans expectations. The improved algorithm is based on previous work done by Freeman and Davis. The algorithm uses an approach of averaging multiple s values to avoid the selection of spurious corners. The algorithm also uses a maximum cut off value (a certain fraction of the entire chain) to determine the length of the forward and backward arms of each point, and hence eliminates the detection of spurious corners. The improved algorithm was tested with results close to humans expectations. The results of the improved algorithm are shown by way of examples. Chain-coded curves Image segmentation
Cornerity Image analysis
Human corner detection
I. INTRODUCTION One of the difficulties of corner detection in image processing is the difficulty of detecting corners where humans would recognize them (human corner detection). In the past, many approaches to corner detection have been studied by different researchers,"-3~ none of these approaches could uniquely identify all the corners in the given image. These approaches either detect corners, both wanted and unwanted, at the same time, or fail to detect obvious corners in some situations. Image analysis could be a difficult task when corner detection is used as part of the image segmentation process (division of images into meaningful regions). This paper describes an improved corner detection algorithm based on the previous work done by Freeman and DavisJ' It is expected that the reader has already read the corner detection algorithm as described by them. The modified corner detection algorithm has been tested with resulting corner detection performance closer to human expectation. The algorithm is illustrated by way of examples. !1. S U M M A R Y O F F R E E M A N A N D D A V I S ' A L G O R I T H M
In their corner detection algorithm, Freeman and Davis define a corner as an isolated discontinuity
Incremental curvature
(local curvature) in the mean slope, and its significance (prominence) is proportional to the length of the discontinuity-free regions to either side as well as the severity of the discontinuity. Freeman and Davis define a chain {a)j,n where a,6 {0. . . . . 7}, as the outline of a given object. They use straight line segments (vectors) L~ that connect the J initium, a _ , + ~, to the terminus, a, of a contiguous set of points (chain codes). The length, D~, of L~ will always J J lie between sx/2 to and 1; however, for a well-quantizeff ~ curve, it should never be less than sx/2. This length is given by
= E(xy + ( O T
(1)
where J I
i-j-s+l )
v=
E
a
(3)
i=j--s+l
and where the a~ and a~. are, respectively the x and y components of the chain links, a~, a,ye{ - 1,0, 1}. The angle between the x axis and the forward direction of 291
292
H. LYNNBEUSand STEVENS.H. TIu
the line segments is defined as the local curvature and is given as
Ix;I >1 r;I if Ix;I
0; -- t a n - ' (Y;/X'~) if
(4)
~} ffi c o t - ' (X;/Y'j)
(5)
and can vary from 0 to 360°. This local curvature is supposed to provide some smoothing to the curve. For further smoothing, Freeman and Davis define dj' : +; +1 - ~ ' j - I
(6)
as the incremental curvature of the chain; it is equal to twice the mean over two successive angular differences. The larger the s used, the heavier the smoothing to the curve will be. The best value of s will normally range from a minimum of 5 to a maximum of 11. This appears to be the optimum range for removing the effect of chain quantization noise and yet preserving significant fine detail. An illustration of this linesegment scanning is given in Fig. 1. A possible measure for a corner or "the cornerity", according to Freeman and Davis' definition of corner, is the product of the lengths of the uniform chain sections to either side (the forward and backward arms) era point, times the angle of discontinuity of that particular point. With this definition to measure a corner, Freeman and Davis denote the cornerity at point j by K~ as follows j+s Kj = ln(tl)* ~ d * ln(t2)
(7)
i=j
where tl ~- max {t:d r ¢ ( - A, A), For all v, wherel < v < t} (8) t2 = max {t:d . . . . ¢ ( - A , A), For all o, where 1 _< v < t} (9) and A ffi tan- i (l/(s - 1))
37 I 36["T"~ 2 3 Iq6
31 ~ 30 29 28 27 26
7
8 9 10 11 12 13 14 23122[1111117 21 20 19 18
Fig. 1. Illustration of line-segment scan, chain being scanned with s ffi 5.
IlL PROBLEMS WITH THE ALGORITHM
Figure 2 has two examples that we have chosen to illustrate the problems with Freeman and Davis' algorithm. As humans would see it, the outer boundary of the given images should have the distinct corners as numbered in Fig. 2a. Applying their algorithm (using s equal to 5, and a threshold of 3000) to these images, corners are detected and highlighted as shown in Fig. 2b. Clearly, the algorithm has failed to detect one obvious corner (corner number 2); in addition, it has detected an unwanted corner. Theoretically, their algorithm should be able to detect the correct corners in each example in Fig. 2, since they have obvious forward and backward arms, and large incremental curvatures. However, digitizing errors affect the detailed structure of real corners as well as the structure of apparently smooth curves. Our research has shown that this situation usually happens when a point has detailed structure (due to digitization) like that shown in Fig. 3. As shown in Fig. 3, point A should be considered to have high degree of incremental curvature, both long forward and backward arms. Freeman and Davis' algorithm, however, will detect the forward arm (t 1) as having a small value because it does not even get past the first point tested using s equal to 5 or less. Ifa larger value ofs were used, the problem could be eliminated since it would get past the first point tested. Therefore, with s equal to 5 in the examples shown in Fig. 2, the undetected corner should have relatively smaller K value in comparison with other corners; it did not get detected because its K value did not exceed the threshold. This problem is also pointed out by West in his application of Freeman and Davis' corner detection algorithm to develop a system for automatic visual inspection of bare-printed circuit boards/51 The second problem is that the algorithm detects unwanted corners in some situations. This happens when a point has extremely large values both in forward and backward arms. In this situation, even though the incremental curvature of that point has a smaller value in comparison with other points, the product of forward arm, backward arm, and the incremental curvature still exceeds the set threshold, and the point will be erroneously detected by the algorithm as a corner. A human would see only one corner in Fig. 3, while the enlarged portion shows that the computer "sees" two corners possibly due to digitizing errors. In order to avoid having the algorithm detect both these points as corners, we pick the point with the largest cornerity value as the true corner, and ignore the nearby points up to distance s. For multiple s values, the distance to skip should not exceed the average of the sum of s values used. With these changes, the modified algorithm correctly detects one corner in Fig. 3. IV. THE MODIFIED CORNER DETECTION ALGORITHM
Two modifications are made in order to obtain performance closer to human expectations. First, the
An improved corner detection algorithm
293
Example 1:
C) 2
(a)
(b)
(c)
Example 2:
(a)
(b)
(c)
Fig. 2. Two examples of corner detection problems (a) as humans would see it, (b) using Freeman and Davis' algorithm, and (c) using the modified algorithm. In both examples, a "true" corner is missed and a spurious corner is found by Freeman and Davis' algorithm. These errors are generally due to sensitivity of the algorithm to digitization errors.
III111
o k_l
Point A
The magnifiedportionof the square Fig. 3. The relationship of the incremental curvature, the forward arm (tl), and the backward arm (t2) of a point. The cornerity (K) at a point tends to have a smaller value when tl or t2 is smaller than the s being used. Freeman and Davis' algorithm will treat the example shown here by detecting a spurious forward arm when s = 5, which leads to a comparatively smaller cornerity value. Humans would see only one corner (in the un-enlarged image) as having both long forward and backward arms.
modified algorithm uses the approach of averaging the K values obtained at a particular point for multiple s values. The advantage of this approach is to eliminate the situation as shown in Fig. 3. Secondly, the modified algorithm sets a maximum to the lengths of the forward and backward arms. When determining these lengths, the modified algorithm will limit the t values to some fraction of the number of nodes in the given image (a cutoff point). Our research has shown that one tenth the length of the object outlines seems to produce a reasonable result. The purpose of this modification is to reduce the cornerity (or the K values) of spurious nodes with long forward and backward arms. Setting such a limit to arm length is more in accord with human perception of corners, which depends on object size. The following are the modifications to Freeman and
294
H. LYNNBEUSand STEVE~S. H. TIu
Davis' algorithm. A new variable N is introduced, which determines the maximum cutoff value of t I and t2 as a fraction of the entire chain length. A few modifications are made to (7) to yield (11) in calculating the Kj value at point j : We apply the modified Freeman and Davis algorithm s2 - sl times for each point and then average the values Kj. N = C* F, where C is chain length and F is some fraction (0 < F < 1) (10) [ l n ( t l ) * ~ d , * In(t2)] / ( s 2 - s l )
Kj= \s=sl
(11)
t=j
where tl = max {t:dj_~ ¢ ( - A , A), For allv, wherel _~ v _ ~ t , a n d t ~ N}
(12)
t2 = max {t:dj +, +~ e ( - A, A), For allv, w h e r e l < v < t, a n d t _ < N}
(13)
and A = tan -J (1/(s - 1)). The algorithm accepts six input parameters, they are C (point count), F (the fractional cutoff for arm lengths), M (the maximum number of corners to be detected), sl and s2 (the smallest and largest values of s), and a list of chain-coded values that forms the chain. The output of the algorithm is a list of the M most corner-like nodes ordered from highest to lowest cornerity. It is important to note that this modified algorithm does not make multiple passes over the points of the curve for each value ofs. The algorithm uses a queue to process chain nodes by appending new nodes at the end, and deleting old nodes from the front. The size of the queue must be at least twice N to allow room for the algorithm to calculate the forward and backward arms. Therefore, the algorithm cannot begin calculation of cornerity values until the queue is full. Another list is used to store the M nodes of highest cornerity. This list of nodes is first initialized to all zeros. Before a point is added to this list, it is compared with this list ofcornerities in absolute value. If the current point has a higher value than one of the nodes in the list, it is added to the list and the point with the least cornerity value is deleted from the list. In choosing to use the approach of averaging cornerities for multiple s values, the algorithm requires more computation; however, it still traverses the entire chain only once, instead of requiring multiple passes. This is one advantage of the modified algorithm. Another advantage is that the algorithm allows the user to specify the number of highest cornerity nodes to be found, rather than setting a fixed threshold to decide if a certain point is a corner. The user rarely knows what threshold to set to obtain optimal results. Consequently, unwanted corners are detected if the threshold is set too low, or true corners may be missed when the threshold is set too high. When this modified corner detection algorithm is used on the image given in Fig. 2. The result is exactly the same as the
2
4
6
Fig. 4. A more complicated objeci used to test the modified corner detection algorithm. See Table 1 for the results. expectation of humans, and is shown in Fig. 2c. In most cases, the modified algorithm tends to produce the same result as that from human corner detection. The only disadvantage is that the algorithm runs comparatively slower than Freeman and Davis' algorithm due to the use of multiple s values. V. M O R E EXPERIMENTAL RESULTS
Besides the two examples shown in Fig. 2, a more complicated object, as shown in Fig. 4, is used to test the performance of the modified algorithm. The outline of the object used here has approximately 350 nodes. According to humans, the outline of the object would be seen to have nine true corners; they are highlighted and numbered. To test the modified algorithm, we not only use the range of s values (3 -11), but also use different ranges and scattering ofs values. The results are shown in Table 1. Speed comparison results of using both Freeman and Davis' algorithm and the modified algorithm are also included in Table 1. The results shown in Table 1 indicate that in most cases, using only a single s value, the modified algorithm performs a better job than Freeman and Davis'. This indicates that the use of a cut off value (a certain fraction of the entire chains) in the algorithm helps prevent the detection of spurious corners. Furthermore, the modified algorithm does not need to u s e a full range of s values (3-11) to detect all true corners. When using a single s value or double s values, some true corners could be missed; however, the results have shown that as the number of s values are increased, the algorithm tends to perform corner detection as humans would expect. It seems that if we choose to average four or more multiple s values in the algorithm, we shall most likely obtain a reasonable result. Table 1 also shows an important point about how to pick the correct s values for best results. As the size of the object boundaries increase, larger s values should be used. The boundary used in Fig. 4 consisted of approximately 350 points (a relatively small number); therefore, smaller s values should be used. Thus, Table 1 shows that when the value ofs is greater than 8, or the average of multiple s values is greater than 8, the algorithm tends to detect spurious corners. This information could be incorporated in the algorithm, so that it automatically chooses reasonable values for s, based on boundary size. This too
295
An improved corner detection algorithm Table 1. A comparison of the modified algorithm with Freeman and Davis' algorithm Freeman and Davis' algorithm *
The modified algorithm s values used are between 3-11
approximate time used (s)
3 4 5 6 7 8 9 10 II all possible pairs "~ of s except (8,11), f (9,10), (9,1 I), and (lOAD (8,11), (9,10), } (9.1 I) or (10,11) all possible three "~ s values except ~ (8,9,10), (8,9,1 l) and (9,10,1 I) (8,9,10), (8,10,11) } or (9,10,1 I1 all possible four s "1 values except .j~ (8,9,10,II) (8,9,10,II) all possible five s values all possible six s values all possible seven s values all possible eight s values all possible nine s values
number of true number of corners deteted spurious corners detected 9 9 8 9 8 9 7 8 8
0 0 1 0 1 0 2 1 1
2
9
0
2
8
1
3
9
0
3
8
1
4
9
0
4 5
8 9
1 0
6
9
0
7
9
0
8
9
0
9
9
0
approximate time used (s) 1 1 1 1 1 1 I 1 1
number of true number of corners spurious corners detected detected 7 6' 4 9 9 5 7 5 5
0 4 1 0 0 3 2 5 4
Does not apply
* The results of using Freeman and Davis's algorithm are obtained using a threshold which determines maximum number of true corners but minimum number of spurious corners.
The modified corner detection algorithm on a chain-coded plane curve has been described. The algorithm is implemented on the Lilith computer in Modula-2, and has been proven reasonably accurate in detecting corners. The only disadvantage is its speed; it takes longer to detect the corners of an image due to the use of the multiple s values. Future enhancements to the speed of the algorithm will certainly be very useful. One possible enhancement of
based on chain-coded plane curves has been described. The improved algorithm is based on Freeman and Davis' corner detection algorithm. Two modifications were made to make their algorithm perform corner detections closer to human performance. These two modifications are (1) the use of multiple s values to avoid the detection of spurious corners due to digitizing errors, and (2) the use of a maximum cut off value (a certain fraction of the entire chain) to determine the forward and backward arms of each point. The use of this maximum cut off value corresponds to what humans would "see" as corners in small versus large objects. The results of the improved corner detection
the algorithm is by applying the arm cut off values obtained for one point (when cut off by change in curvature) to other nodes as well, thus saving the time of traversing out to the cut off point each time.
algorithm are demonstrated by way of examples and have been proved with reasonable results. In most cases, the algorithm tends to perform corner detection close to human performance.
SUMMARY
REFERENCES
corresponds to what a human "sees" as corners in small, vs large objects. VI. POSSIBLE FURTHER REFINEMENTS
In this paper, an improved corner detection algorithm
I . H . Freeman and L.S. Davis, A corner finding algorithm
296
H. LYNN BEUSand STEVENS.H. TIu
for chain-coded curves, IEEE Trans. Comput. C-26, 297-303 (1977). 2. D.J. Langridge, Curve encoding and the detection of discontinuities, Computer Graphics Image Process. 20, 58-71 (1983). 3. K. Paler, J. Foglein, J. Illingworth and J. Kittler, Local ordered grey levels as an aid to corner detection, Pattern
Recognition 17, 535-543 (1984). 4. H. Freeman and J. Glass. On the quantization of line drawing data, IEEE Trans. Syst. Sci. Cybern. 5, 70-79 (1969). 5. G.A.W. West, A system for the automatic visual inspection of bare printed circuit boards, IEEE Trans. Syst. Man Cybernet. SMC-14, 767-773 (1984).
About the Author-- H. LYNNBEUSreceived his bachelor degr~ ~.(1961) from Brigham Young University, his masters degree (1964) and Ph.D. degree (1967) from Case-We.,tern Reserve University, all in Mathematics (with computer emphasis). He was employed with the General Electric Company from 1967 to 1971, where he was chairman of the company's Database Workshop. Hejoinea ~he faculty of Brigham Young University, Computer Science Department in 1971. His current research ;-" .ots are artificial intelligence, with special interest in pattern recognition. About the Author -- STEVENS.H. TIu was born in Hong Kong. He received the B.S. degree in Computer Science from Brigham Young University, Provo, Utah in 1983. He is working on his M.S. degree in Computer Science at Brigham Young University, and his thesis is on edge interpolation and extrapolation techniques for object recognition in image processing.