Ellipse fitting by accumulating five-point fits

Ellipse fitting by accumulating five-point fits

Pattern Recognition Letters 14 (1993) 661-669 North-Holland August 1993 PATREC 1081 Ellipse fitting by accumulating five-point fits Paul L . Ros...

480KB Sizes 13 Downloads 76 Views



Pattern Recognition Letters 14 (1993) 661-669 North-Holland

August 1993

PATREC 1081

Ellipse fitting by accumulating five-point fits Paul L . Rosin Cognirire Systems Group, School of Computing Science . Curtin University of Teritnolo,gt% Perth, 6001 . Ithstera

Ausnruha

Received 30 March 1992

Ahstroct Rosin, P.L . Ellipse fitting by accumulating five-point fits . Pattern Recognition Letters 14 (1993) 661 669 . Standard techniques for ellipse fitting such as the least squares method and the Hough Transform either make certain assumptions about the type of noise distribution, or require input parameters . This often prevents the techniques working robustly over a large range of data . A technique for ellipse fitting is described in this paper that does not have these disadvantages . It is based on accumulating many five-point ellipse fits to subsets of the data, sorting the parameters of these ellipses . and selecting the medians of each parameter .

Kerworr(s Ellipse fitting, median, least squares, Hough transform .

1 . Introduction

Fitting models of image feature primitives to image data is a common task in computer vision . For example, edge data is commonly approximated by straight lines and arcs to provide a more compact and convenient representation . This paper described a technique for fitting ellipses to sets of linked edge points . Ellipses are a powerful feature, and are useful in computer vision . If ellipses detected in the image are assumed to be the 2D projection of circular features in the 3D scene than various inferences can be made about their 3D structure . These restrict the number of interpretations of the data, and can be used for matching (W u and Caelli (1988)), grouping (Rosin and West (1992)), and cueing (Rosin (1991)) . Various methods exist for model fitting and can

C'orrespondenrr to : Dr . Paul Rosin, School of Computing Science . Curtin Lnivershy of Technology . Perth, 6001, Western Australia .

be assessed by the following criteria : robustness to noise and incomplete data, accuracy, and computational efficiency . Two of the most common fitting techniques used in computer vision are the least squares method (e .g . Agin (1981)) and the Hough Transform (e .g . Tsuji and Matsumoto (1978)) . However, both are unsatisfactory concerning the above criteria . Although the least squares method performs well in the presence of Gaussian noise it becomes unreliable for nonGaussian noise . In particular, it is sensitive to outliers (i .e ., samples with values far from the local trend) which have an unduly adverse influence on the fit . Although more complex techniques are available to combat this problem such as the iterative reweighted least squares method (Sampson (1982)), they are inefficient and unreliable . In contrast, the Hough Transform is insensitive to outliers but requires arbitrary quantisation of the feature's parameters . Model evidence is accumulated by binning the parameters-incorrect bin sizes may result in a coarse (i .e ., inaccurate) fit, or a failure to find the feature in accumulator space . In addi-

0167-8655/93/$06 .0(1 G 1993 - Elsevier Science Publishers B .V. All rights reserved

66 1



Volume 14, Number 8

PATTERN RECOGNITION LETTERS

tion, some formulations of the Hough Transform require a large portion of the data to be present . The ellipse fitting method described in this paper is based on accumulating five-point ellipse fits to subsets of the data and then using medians to determine the fit . The technique's advantages are : (1) it makes no assumptions about the type of noise, making it insensitive to outlying points, and (2) it does not require any parameters . Both these facts ensure that the technique can work robustly over a large range of data .

Median approach to ellipse fitting Recently, robust fitting techniques using medians have become popular (Hampel et al . (1986), Meer et al . (1991), Rousseeuw (1984)) . Their advantage is that they can tolerate many large outliers (i .e ., they have a high breakdown point) without requiring any arbitrary parameters and are reliable (e .g ., there are no problems with convergence as in the iterative reweighted least squares method) . Many median based approaches have a 50% breakdown point in contrast to the 0% breakdown point of the simple mean . This paper extends a method described by Kamgar-Parsi et al . (1989) for fitting a straight line to a set of points called the median of intercepts (MI) . The MI method works in two stages . First the line passing through each pairwise combination of points is determined and each of its parameters stored in a list . Lines are parameterised by their slope and intercept along the Y-axis . Next, the two lists of parameter are sorted . The median value from each list provides the pair of parameter values that define the fitted line . This paper describes an extension of this technique to ellipse fitting . An ellipse is specified by five parameters, and a natural representation is its centre co-ordinates, lengths of major and minor axes, and orientation of the major axis . An alternative representation is the general equation for a conic :

A 2 +Bxy+Cy 2 +Dx+Ey+F=0 with the scaling factor normalised, e .g . by setting F=1, A 2 +B 2 +C 2 +D 2 +E 2 +F2 =1, etc. (Carne (1990)) . 662

August 1993

The MI method was based on accumulating the parameters of all perfect line fits . Likewise we fit an ellipse by accumulating the five parameters of all perfect ellipse fits . Whereas two points are required to uniquely define a straight line, ellipses are uniquely defined by a minimum of five points . Therefore the ellipses through all combinations of five points are determined . The coefficients of the conic through five points can be determined by substituting the points into the conic equation and solving the five simultaneous equations . An alternative quick method is given by Smith (1921, §207) . Four lines L a , L b , L,, and Ld can be defined through pairs of four of the five points, where L ;=1;x+m ;y+n ; . The equation of the conic through the five points is LQLb

-

1.LcLd=0

which can be solved for 1, and then evaluated for the fifth point . However, whereas two points were always sufficient to specify a unique line, an ellipse may not exist through certain arrangements of five points . For some sets of five points the conic may not be an ellipse, but a parabola or hyperbola instead . When accumulating ellipse fits, non-elliptic five-point fits will be rejected . This has the advantage over least-square fitting in that fits to nonelliptic sections of data will be ignored rather than contributing incorrectly to the final ellipse fit . From the n data points, each fit through a 5-tuple of points (PI,PJ,Pk,PI,Pm),

i*j*k*I*m, I c I,],k,1,mCn

provides an estimate (a,,krm, bt klm, c,,kfm, dr klm , eijkim ) of the final ellipse's parameters . The parameters of the final ellipse fit (a, 6, e, d, e) are taken as the medians of each set of parameters a=median{a;,k,,,, },

b = median { b,uk,m } , c=median{cyk,,,,}, d = median { d;,kr,,, } , e = median{e,Jkf,,, IFigure la shows the ellipse fitted by the median

Volume 14, Number 8

PATTERN RECOGNITION LETTERS

August 1993

X

x

x

Figure la . Ellipse fitted by median method .

Figure lc . Ellipse fitted by median method-only regularly spaced samples considered .

method compared with the least squares fit in Figure lb . It can be seen that despite the outliers the median method produces a good fit in contrast to the least squares fit which has been distorted and pulled towards the outliers . These results were obtained by accumulating the natural parameters of the ellipse (centre, axes, and orientation) . It is noteworthy that when the coefficients of the conic equation were accumulated instead, the fitted ellipse was extremely inaccurate . In a series of tests, accumulating the conic coefficients resulted

in one or several of the estimated parameters of the ellipse such as centre location or scale being incorrect . This can probably be accounted for by two factors . First, each of the natural parameters is not determined by a single coefficient, but is distributed over several coefficients, leading to problems when the lists of coefficients are sorted independently . Second, even for similar ellipses the coefficients have a much larger range of values than the natural parameters, affecting the sorting of the coefficients . The line method considered all pairwise combinations, resulting in an algorithmic complexity of O(n 2 ) . However, taking all combinations of five points results in 0(n) . This is undesirable as it produces a large number of ellipses for even a few points . To avoid this, a speedup is obtained by only considering a subset of the data . One approach is to take a random sample of the data points . This technique has been recently used for the least median of squares (Meer et al . (1991)) and the Hough Transform (Xu et al . (1990)) . Here we take a different approach based on the assumption that the data is ordered . This is the case when dealing with edge data this is generally linked and extracted as connected, ordered lists of pixels . Rather than considering all combinations of five points only the fits from all regularly spaced 5-tuples of points are accumulated . That is, for a set of n points (P 1 , P2 , . . ., P,) the 5-tuples (p,, pi+s, P!+2s' Pi -3s'

x Figure lb . Ellipse fitted by least square method .

663



Volume 14, Number 8

are selected, where s=1, 2, 3, . . . is the separation between points, and i=1, 2, 3, . . . resulting in no more than

p;1 4s)

(n-4s)

s-I

5-tuples which is O(n 2 ) . This method ensures that each point is included in a number of 5-tuple fits . Unfortunately the data is not regularly sampled points at the ends of the pixel list are included in less five-point ellipse fits than more central points . One solution is to consider the list as circular and wrap points around the end of the list . This still produces O(n 2 ) 5-tuples . However, in our examples this was not necessary to achieve good results . Figure Ic shows the previous example of noisy elliptical data again . This time only the regularly spaced 5-tuples are accumulated . Again a good fit is obtained by the median method although not as accurate as when all 5-tuples are considered as in Figure Ia . However, whereas 33649 fits were considered (of which 19831 were ellipses and accumulated) for the fit in Figure Ia only 95 fits (of which 34 fits were ellipses) were required to fit Figure lc . Although Kamgar-Parsi et al . (1989) and Meer et al. (1991) only consider the problem of extreme noise (i .e ., outliers) on the data, even minor variations can lead to discrepancies of the fits . For the noise-free data shown in Figure 2a the regularly spaced 5-tuple ellipse fits are shown in Figure 2b . Just the relatively small effects of quantisation result in several ellipses significantly different from the trend . These inaccurate fits are more likely to occur with closely spaced points than well spread out points since the inaccuracies of the data are relatively larger . Therefore it may be advantageous to ignore closely spaced ellipse fits if an estimate of the noise is known . Figure 3a gives an example of an ellipse with large amounts of added structured noise . Most ellipses fitted to points covering a smaller extent than that of the structured noise will be inaccurate estimates of the global trend . This is demonstrated in Figure 3b which shows all regularly spaced points separated by less than 4 points . In actual fact, the median technique is robust to large numbers of incorrect estimates . When the ellipse fit to all regularly spaced points is compared to the ellipse fit to regularly spaced points separated 664

x

x

x x

X

X

x

x x

x

n-1)/4

E

August 1993

PATTERN RECOGNITION LETTERS

X X

x

X

Figure 2a . Noise-free elliptical data .

Figure 2b . Regularly spaced five-point ellipse fits to data .

by four or more points there is little difference (Figure 3c) . When fitting ellipses to linked edge data the outliers are likely to arise not from noise but from imperfect segmentation . A standard technique for segmenting curves into straight lines and circular arcs is to analyse its curvature . However, the curvature of an ellipse is complex, making this approach difficult . Thus detection of the endpoints of an ellipse-particularly for the case of smooth joins-is often inaccurate . An example of poorly segmented data is shown in Figure 4a which contains an ellipse with one smooth join to a straight line and one sharp join to an arc with low curvature . The median method provides a good ellipse fit which is mostly unbiased by the adjacent features



Volume 14, Number 8

PATTERN RECOGNITION LETTERS

August 1993

X

xx xx

X X

x xx

X X X

x x

x

X X X X X X

x

X X

x

X X

X

Figure 3a . Ellipse data with added structured noise .

Figure 3c . Ellipse fits to all regularly spaced points and to distant regularly spaced points .

Figure 3b . Ellipse fits to close regularly spaced points .

in contrast to the least squares method as shown in Figure 4b . An example of applying the median method to linked edge data is shown in Figure 5 . The edges extracted from an image of a petrol pump are shown in Figure 5a . The linked list of pixels corresponding to part of the outline is isolated in Figure 5b . Rather than fit an ellipse to all points it is more efficient to follow the process in which the

curve is first approximated by straight lines to reduce the amount of data (Figure 5c) (Rosin and West (1992)) . The ellipse produced by the median method to the data points (Figure 5d) is a good fit to the top of the pump . It is unaffected by the outliers arising from the side and other non-elliptical details of the pump in contrast to the least squares method . 66 5



PATTERN RECOGNITION LETTERS

Volume 14, Number 8

August 1993

X X X X X XX X

X X X

X

X X X

Figure 4a . Ellipse joined to a line and an arc .

Figure 4b . Ellipses fitted by median and ]east squares methods .

Applying the Hough Transform to five-point fits It was earlier stated that the Hough Transform, in addition to the limitation caused by quantising the parameters, may be restricted by its particular

formulation for a model . Many Hough Transform applications for ellipse fitting require large portions of the data to be present (e .g ., so that points with parallel tangents can be accumulated) and require the orientation of the data points (e .g . Tsuji

Figure 5a . Extracted edges from an image .

Figure 5b . A single linked list of edges .

666

Volume 14, Number 8

PATTERN RECOGNITION LETTERS

August 1993

Figure Sc . Approximation by straight lines .

X & Matsumoto (1978)) . The concept of accumulating five-point ellipses used in the median based method can be also be applied to the Hough Transform . The advantages of this formulation is that it does not require large portions of the data or the orientation of the points . Rather than independently accumulating and sorting the five parameters of the five-point ellipse fits the Hough Transform approach accumulates the parameters in a five-dimensional accumulator space . The best ellipse fits to the data are found by searching for peaks in accumulator space . An alternative to explicitly generating a five-dimensional accumulator space is to compare all pairwise combinations of five-point ellipse fits and increment their counters if they are similar . Peaks are located by identifying the five-point ellipses with the largest number of votes . The parameters associated with each peak are taken as the average of the param-

Figure 5d . Ellipses fitted to endpoints by median and least squares methods .

eters of all the ellipses that contributed to the peak ellipse's votes . Considering all pairwise combinations of regularly sampled five-point ellipse fits results in a complexity of 0(n 4) . The advantage of the Hough Transform is that several instances of the model may be fitted to different portions of the data . For instance Figure 6a shows a curve made up of three elliptical sections . All the regularly spaced five-point ellipse fits are shown in Figure 6b . As expected there are three main clusters of ellipses corresponding to the three sections . The median technique is limited to data containing only one dominant feature . Since that is not the case in this example the ellipse fitted by the 667

Volume 14, Number 8

PATTERN RECOGNITION LETTERS

xxXx Figure 6a . Connected curve containing three elliptical sections .

Figure 6b . All regularly spaced five-point ellipse fits .

median technique is incorrect (Figure 6c) . However, each cluster can be located using the Hough Transform to accumulate five-point ellipses, resulting in three good ellipse fits (Figure 6d) . The disadvantages of the five-point Hough Transform technique are (1) it is sensitive to the parameters which determine whether two ellipses are considered similar (a problem also common to other Hough Transform approaches), and (2) the peak searching stage makes it computationally more expensive than the median selection method .

668

August 1993

xXXX Figure 6c . Ellipse fitted by median method .

Figure 6d . Ellipses fitted by five-point Hough Transform .

Conclusions A technique has been described for fitting ellipses to point data . It is based on accumulating many five-point ellipse fits to subsets of the data, sorting the parameters of these ellipses, and selecting the medians of each parameter . When all combinations of five points are considered the complexity of the technique is 0(n 5 ) . This can be reduced to 0(n 2 ) by only conisdering regularly spaced 5-tuples . Examples show that even with this reduction of data good results are still obtained . The advantages of this technique are that no



Volume 14, Number 8

PATTERN RECOGNITION LETTERS

assumptions are made about the type of noise distribution, and no parameters are required . This ensures that the technique can be applied to a large range of data without requiring any modifications . The median has a breakdown point of 50°16, making it robust even in the presence of a large number of outliers . This is in contrast to standard fitting techniques such the least squares (Agin (1981)), Hough transform (Tsuji and Matsumoto (1978)), and RANSAC (Bolles and Fischler (1981)) . The least squares method assumes that the noise distribution is Gaussian, causing it to be very sensitive to outliers . The results of the Hough Transform are sensitive to the bin sizes used to accumulate the evidence . The RANSAC method is dependent on parameters which are necessary to eliminate outliers . An alternative to selecting the medians of the parameters of the accumulated five-point fits is to search for clusters in parameter space, i .e ., the Hough Transform . This has the advantage over the median method that it can cope with data containing several features rather than just a single dominant feature . Its disadvantages are its sensitivity to the binning parameters and a greater time complexity than the median method .

References Agin, G .J . (1981) . Fitting ellipses and general second-order curves . Tech . Report CMU-RI-TR-81-5, Robotics Institute, Carnegie-Mellon University .

August 1993

proach to model fitting and its applications to finding cylinders in range data . Proc. 7th . IJCAI, 637-643 . Carnie, S.L . (1990) . A survey of least square ellipse-fitting algorithms . Computing Project 594 Report, Grad . Dip . Computing, School of Computing Science, Curtin University of Technology . Hampel, F .R ., E .M . Ronchetti, P .J . Rousseeuw and W .A . Stahel (1986) . Rohust Statistics . Wiley, New York . Kamgar-Parsi, B ., B . Kamgar-Parsi and N .S . Netanyahn (1989) . A nonparametric method for fitting a straight line to a noisy image . IEEE Trans . Pattern Anal. Machine Intell . 11, 998-1001 . Meet, P ., M . Mintz, A . Rosenfeld and D .Y . Kim (1991) . Robust regression methods for computer vision : a review . Internal . J. Computer Vision 6, 59-70 . Rosin, P .L . (1991) . Acquiring information from cues . Pattern Recognition Len . 14, 599-609 . Rosin, P .L . and .W .A West (1990) . Segmenting curves into G . elliptic arcs and straight lines . IEEE Internal. Conf on Computer Vision, Osaka, Japan, 75-78 . Rosin, P .L . and G .A .W . West (1992) . Detection and verification of surfaces of revolution by perceptual grouping. Pattern Recognition Lett. 13, 453-461 . Rousseeuw, P .J . (1984) . Least median of squares regression . J . Amer . Slat . Assoc . 79, 871-880 . Sampson, P . (1982) . Fitting conic sections to `very scattered' data : an iterative refinement of the Bookstein algorithm . Comp. Vision Graphics Image Process . 18, 97-108 . Smith, C . (1921) . An Elementary Treatise on Conic Sections. Macmillan, London . Tsuji, S . and F . Matsumoto (1978) . Detection of ellipses by a modified Hough transform . IEEE Trans. Compul . 27, 777-781 . Wu, J . and T . Caelli (1988) . Model-based 3D object localization and recognition from a single intensity image . Vision Interface Conference, Edmonton, Alberta, Canada, 21-67 . Xu, L ., E . Oja and P . Kultanen (1990) . A new curve detection method : randomized Hough transform . Pattern Recognition Lett . 11, 331-338 .

Bolles, R .C . and M .A . Fischler (1981) . A RANSAC-based ap-

669