how to find the right distance evaluation function of an ellipse

조회 수: 4 (최근 30일)
Johannes Tischer
Johannes Tischer 2020년 9월 25일
댓글: Matt J 2020년 9월 29일
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