Corner detection based on an adaptively filtered curvature function
C. Urdiales, C. Trazegnies, A. Bandera and F. Sandoval Dpto. Tecnología Electrónica, E.T.S.I. Telecomunicación, Universidad de Málaga, Campus de Teatinos - 29071, Málaga (Spain) Corresponding author e-mail:
[email protected]
Abstract This paper presents a fast new algorithm to detect corners defined at different scales. It relies on calculating the shape curvature function using an adaptive filtering factor to remove as much noise as possible without losing corners. Corners are the peaks of the function and they can be detected by thresholding. Experimental results show that detected corners are very stable against noise, scale and rotation.
1
1. Introduction Most contour based relevant point detection methods rely on detecting corners on the contour of a shape. A common approach is to calculate the curvature function (CF) of the contour because corners are the peaks of the funtion and, hence, they can be easily detected by thresholding [1,3]. The main problem of this approach is that CFs are typically noisy. Thus, most CF calculation methods implicitly or explicitly filter the function at a fixed cut frequency [3]. Since corners appear at different scales, some of them may be lost after filtering the CF. In order to detect a correct and stable sequence of corners over a contour, Bandera et al. [1] proposed an adaptively estimated curvature function (AECF). The main advantage of the AECF is that corners defined at low scales were preserved. However, noise is better removed in segments presenting a constant curvature than in segments related to corners in the AECF. Hence,
noisy peaks in the
AECF can provoke false detections when using a fixed threshold.
In this paper, we propose a new algorithm for corner detection that represents every contour point i by its local curvature value. This value is locally approximated by the angle of a secant joining points i+k and i-k of the contour where k is obtained so that the portion of the curve between both points does not present sharp curvature changes. The peaks of the function are the corners of the shape. However, unlike in the AECF, the corner subtended angle is not equal to the height of the peak but to the integral of the curve between the two closest zero-crossing points on the left and the right of the corner respectively. This new CF presents two
2
advantages with respect to the AECF: i) the original shape can be recovered; and ii) peaks are not as affected by noise as in the AECF. 2. Corner detection algorithm The proposed detection algorithm consists of the following steps: 1) Contour encoding by means of an incremental chain code. The incremental chain code associated to a given pixel i is a vector (∆x(i), ∆y(i)) which presents the difference in x and y between point i and i +1 of the contour. 2) For every point i, calculation of the maximum contour length k(i) free of discontinuities around i. The value of k(i) is calculated by comparing the Euclidean distance from pixel i-k(i) to pixel i+k(i)th, ||i-k(i), i+k(i)||2, to the length of contour between both pixels, lmax(k(i)). Both distances tend to be equal in absence of corners, even for noisy contours. Otherwise, ||i-k(i), i+k(i)||2 is significantly shorter than lmax(k(i)). Thus, k(i) is the largest value that satisfies: || i − k (i ), i + k (i ) || 2 ≥ l max (k (i )) − U k
(1)
Uk being a constant value that depends on the noise level tolerated by the detector. If Uk is large, k(i) tends to be large and some contour spikes might be softened, but if it is low, the resulting curvature function is very noisy. Fortunately, it is very easy to choose a suitable Uk. In most cases Uk equal to 0.4 works correctly [1]. ∆x (i ) k = ∆y (i ) k =
i + k (i )
∑ ∆x( j )
j = i − k (i ) i + k (i )
(2)
∑ ∆y( j )
j = i − k (i )
3
3) Calculation of the curvature at every point i (Ri ). If ang(i) is the angle formed by segment
i − k ( i ), i + k ( i )
and the horizontal axis, the
curvature Ri at every point i can be calculated as: 1 ang (i) − ang(i − n ) = Ri n
(3)
In our case, we use n=1 to simplify calculations because: i) n tends to 1 in segments presenting a high curvature; and ii) the curvature value does not depend much on n in segments presenting a low curvature. 4) Corner detection. The peaks of the curvature function are the corners of the object. In this function the subtended angle of a corner is equal to the integral of the function between the closest zero-crossing points on the right and left of the corner. Thus, residual noise tends to make peaks wider rather than to fork them. Consequently, detection is more resistant to noise using this function than using the AECF. Fig. 1.a presents a contour including flat and curve segments and corners. Its proposed curvature function is presented in Fig. 1.b. It can be observed that flat segments are related to flat areas in the function. Curve segments are related to soft peaks. Corners are clearly defined as sharp peaks and they can be easily detected by thresholding. 3. Results Previous works [1,3] have studied the behavior of several corner detectors and concluded that the circular histograms method (CHM) [3] and adaptive method (AECF) [1] were the best choices regarding stability of detected corners. Therefore, the proposed method is compared to these methods to test its performance. Figs. 1a-d present the contour of an
4
object at two different scales and orientations. Corners detected by the AECF, the CHM and the proposed method are superimposed on the contours. All methods detect the same set of corners at practically the same positions over the contour in Fig. 2a. However, it can be appreciated in Figs. 2b-c that the CHM (Fig. 2b) and AECF (Fig. 2c) lose stability when the contour shape is significantly affected by scale and noise. Table I shows the performance of the different methods for the object in Figs. 2b-d according to the Merit value proposed by Rosin [2]. This Merit value combines a measure of efficiency E and a measure of fidelity F: Merit = E ⋅ F =
ISEopt ⋅ M opt ISE approx ⋅ M approx
⋅ 100
(4)
ISEopt and ISEapprox being the error of the polygonal approximation built with the detected corners when compared to the real contour on an optimal corner detector method and on the method under evaluation respectively. M opt and M approx are the number of lines of the approximated polygon for an optimal corner detector method and for the method under evaluation respectively. In our tests, we use the optimal corner detector proposed by Pérez and Vidal [4]. It must be noted that the proposed method has a high Merit and that it is very resistant to scale and noise. 4. Conclusions This paper proposes a new algorithm to estimate the curvature of a contour in a local adaptive way so that corners can be detected even if they appear at different natural scales. Detection is very fast and stable against rotation, scale and noise distortions.
5
Acknowledgments: This work has been partially granted by the Spanish Ministerio de Ciencia y Tecnología (MCYT), under Project No. TIC20011758.
6
References 1
BANDERA, A., URDIALES, C., ARREBOLA, F., and SANDOVAL, F.: “Corner detection by means of adaptively estimated curvature function”, Electronics Letters, 2000, 36 (2), pp. 124-126
2
ROSIN, P.L.: “Representing curves at their natural scales”, Pattern Recognition, 1993, 25 (11), pp. 1315-1325
3
ARREBOLA, F., CAMACHO, P., BANDERA, A. and SANDOVAL, F.: “Corner detection and curve representation by circular histograms of contour chain code”, Electronics Letters, 1999, 35 (13), pp. 1065-1067
4
PÉREZ, J.C., and VIDAL, E.: “Optimum polygonal approximation of digitized curves”, Pattern Recognition Letters, 1994, 15, pp. 743-750
7
Figure captions and subcaptions
Fig. 1. a) Object contour; and b) local curvature function obtained by the proposed method
Fig. 2. a) Contour #1 and corners detected by the CHM, AECF and the proposed method (the positions of the corners are practically the same in all cases); b) contour #2 and corners detected by CHM (k=6); c) contour #2 and corners detected by AECF; and d) contour #2 and corners detected by the proposed method.
Table I. Performance of the CHM, AECF and the proposed method for Figs. 2.a-d.
8
Fig. 1
9
Fig. 2
10
Table I
Contour #1
Contour #2
ISE
Merit
ISE
Merit
CHM (Figs. 2a/2b)
194.84
98.9
1008.7
30.1
Adaptive Method (Figs. 2a/2c)
200.39
97.5
234.84
65.9
Proposed method (Figs. 2a/2d)
193.63
99.2
231.73
70.4
11