|
djordjep@gmail.com wrote in message <984e419b-b5fd-4acb-bf80-bcb09dffcce6@v15g2000yqn.googlegroups.com>...
> Hello all, i have a problem with ellipse fitting experiment i'm trying
> to do for my class:
> ........
Here's one approach you might consider. Assuming you are in two dimensional space, any ellipse can be described by the equation
A*x^2 + B*x*y + C*y^2 + D*x + E*y + F = 0
with appropriate values of A, B, C, D, E, and F. If x, y, and z are column vectors of the three corresponding coordinate of your data points, form the matrix M:
M = [x.^2,x.*y,y.^2,x,y,ones(size(x))];
Then use the singular value decomposition function:
[U,S,V] = svd(M,0);
The sixth (last) column of V will contain the least squares values of [A;B;C;D;E;F] subject to the restriction that the sum of their squares is one. (This latter is necessary because the ellipse's equation is homogeneous in the six coefficients.)
For many (but not all) point sets this can be considered a "best" fit to an ellipse. One drawback it possesses is that this solution does not remain strictly invariant with respect to translations of the coordinate system.
Roger Stafford
|