how to find the right distance evaluation function of an ellipse
Mostra commenti meno recenti
I want to fit a 2D data set to an ellipse using the ransac algorithm . Therefore I use the an equation in polar coordinates, with the origin at the center of the ellipse and with the angular coordinate theta.

ft = fittype( @(a,b,theta,r) (a*b)./sqrt((b*cos(theta)).^2+(a*sin(theta)).^2), 'independent', 'theta', 'dependent','r', 'coefficients', {'a','b'});
fitLineFcn = @(points) fit(points(:,1),points(:,2),ft ) % type function handle
evalLineFcn = ... % distance evaluation function
[modelRANSAC, inlierIdx] = ransac(points,fitLineFcn,evalLineFcn, sampleSize,maxDistance);
How can I compute distances from an ellipse to the data. The example doesnt help me at all.
Risposte (1)
Matt J
il 25 Set 2020
0 voti
6 Commenti
Johannes Tischer
il 26 Set 2020
Modificato: Johannes Tischer
il 28 Set 2020
My problem is, I cant compare my data set to my fit, because I cant compute distances from my ellipse to the data set. Do you have any idea how I can fix this?
The link I gave you showed how to calculate the distance of an arbitrary point y (in Cartesian coordinates) to the ellipse, using trustregprob() from the File Exchange.
Aroot=chol(A);
L=Aroot\eye(2);
z=Aroot\trustregprob(L.'*L, L.'*y,1); %closest point on ellipse
distance=norm(z-y)
but my data set i given in polar coordinates.
You can use pol2cart() to convert them to Cartesian coordinates.
Johannes Tischer
il 28 Set 2020
Image Analyst
il 28 Set 2020
Incomplete code does us no good. For example it hits an error when it needs magnitude and angle. You keep forgetting to attach your data. Why???
Johannes Tischer
il 28 Set 2020
Matt J
il 29 Set 2020
How can I get your matrix ellipse equation in my fit() ?
Once you have fitted the ellipse, you have the major and minor axes lengths a and b. Assuming you convert your data to a cartesian coordinate system in which the major axis is the x-axis, the A matrix will be given by
A=[1./a.^2, 0;0 1./b.^2];
Categorie
Scopri di più su Process Point Clouds in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!