http://www.mathworks.com/matlabcentral/newsreader/view_thread/243156
MATLAB Central Newsreader  fitting irregularly spaced points to ellipses
Feed for thread: fitting irregularly spaced points to ellipses
enus
©19942015 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Mon, 26 Jan 2009 21:02:02 +0000
fitting irregularly spaced points to ellipses
http://www.mathworks.com/matlabcentral/newsreader/view_thread/243156#624109
Peter Schreiber
Hi guys,<br>
Does anybody have some experience with fitting points to ellipses? Any hints or comments would be highly appreciated. Would you recommend a least square solution?<br>
<br>
Best Regads,<br>
Peter

Mon, 26 Jan 2009 22:26:02 +0000
Re: fitting irregularly spaced points to ellipses
http://www.mathworks.com/matlabcentral/newsreader/view_thread/243156#624143
Roger Stafford
"Peter Schreiber" <schreiber.peter15@gmail.com> wrote in message <gll8ca$3tv$1@fred.mathworks.com>...<br>
> Hi guys,<br>
> Does anybody have some experience with fitting points to ellipses? Any hints or comments would be highly appreciated. Would you recommend a least square solution?<br>
> <br>
> Best Regads,<br>
> Peter<br>
<br>
It is necessary to know how many degrees of freedom your ellipse is allowed. If it is totally unconstrained and you have five degrees of freedom, your general ellipse can be expressed as<br>
<br>
A*x^2+B*x*y+C*y^2+D*x+E*y+F = 0<br>
<br>
and this can be expressed as a linear problem in least squares of the six coefficients in a homogeneous equation, which can be solved with the singular decomposition function, 'svd'. If the x and y coordinates of the given points are given as two column vectors X and Y, do this:<br>
<br>
M = [X.^2,X.*Y,Y.^2,X,Y,ones(size(X,1),1)];<br>
[U,S,V] = svd(M);<br>
<br>
Then V(:,6) will consist of the desired six coefficients [A;B;C;D;E;F].<br>
<br>
There is no guarantee this conic will turn out to be an ellipse. If a hyperbola or parabola fits better, that is what you will get. You can tell by the sign of the discriminant, B^24*A*C. For an ellipse it should be negative.<br>
<br>
Also note that if the points are bunched say near one end of the ellipse, the fit will tend to be somewhat inaccurate, as one would expect. In least squares each point is given an equal weight, so in these circumstances the weighting would be heavily skewed toward that end.<br>
<br>
Roger Stafford