how to find the right distance evaluation function of an ellipse

6 次查看(过去 30 天)
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.

回答(1 个)

Matt J
Matt J 2020-9-25
  6 个评论
Johannes Tischer
Johannes Tischer 2020-9-28
You keep forgetting to attach your data. Why???
Why do you need my data ?? My problem is to combine an explicit function and the ellipse equation matrix. There is no data needed.
Matt J
Matt J 2020-9-29
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];

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

产品


版本

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by