File:Regression elliptique distance algebrique donnees gander.svg

页面内容不支持其他语言。
這個文件來自維基共享資源
维基百科,自由的百科全书

原始文件(SVG文件,尺寸为452 × 364像素,文件大小:21 KB)


 
W3C-validity not checked.

摘要

描述
English: Ellipse fitting, using the method of the algebraic distance. Fitzgibbon algorithm (Halíř and Flusser 1998), with test data from Gander et al. 1994.
Français : Régression elliptique, méthode de la distance algébrique. Algorithme de Fitzgibbon, avec les données test de Gander et coll. 1994.
日期
来源

自己的作品

  • Halíř, R. and Fluser, J, Numerically Stable Direct Least Squares Fitting of Ellipses, in Winter School of Computer Graphics, vol. 6 (1998), [1]
  • Gander, W., Golub, G. H., Strebel, R., Least-Squares Fitting of Circles and Ellipses, in BIT Numerical Mathematics, Springer, vol. 34 No. 4 (1994), pp. 558-578 [2]
作者 Cdang

Parameters of the ellipse:

  • center: (4.64 ; 4.80);
  • major semi-axis: a = 3.91;
  • minor semi-axis: b = 2.96;
  • tilt angle: φ = -9.21°.

Scilab source

// **********
// Initialisation
// **********

clear;

// **********
// Données
// **********

X0 = [1, 2, 5, 7, 9, 6, 3, 8];
Y0 = [7, 6, 8, 7, 5, 7, 2, 4];

// **********
// Fonctions
// **********

function [a] = regression_elliptique(X, Y) // Fitzgibbon
    // méthode de la distance algébrique
    // X, Y : points expérimentaux, matrices colonnes réelles
    // a : coefficients de la formule quadratique (matrice colonne réelle)
    D = [X.*X, X.*Y, Y.*Y, X, Y, ones(X)]; // matrice de conception (design m.)
    S = D'*D; // matrice de dispersion (scatter m.)
    C = zeros(6,6);
    C(1,3) = 2; C(2,2) = -1; C(3,1) = 2; // matrice de contrainte
    [vecpropres, valpropres] = spec(inv(S)*C); // détermination du
    // système propre
    if imag(vecpropres) <> 0 then
        error('Les vecteurs propres contiennent des valeurs complexes')
    end
    if imag(valpropres) <> 0 then
        error('Les valeurs propres contiennent des valeurs complexes')
    end
    vecpropres = real(vecpropres); // complexes -> réels
    valpropres = real(valpropres);
    [PosLigne, PosColonne] = find((valpropres > 0 & ~isinf(valpropres)));
    // recherche les indices des valeurs propres positives
    a = vecpropres(:, PosLigne); // vecteur propre correspondant
endfunction

function [phi]=trouve_rotation(A)
    // A : coefficients de la formule quadratique (matrice colonne réelle)
    // phi : angle que fait un axe de l'ellipse avec x (radians)
    delta = 1 - 1/(1 + (A(3) - A(1))^2/A(2)^2);
    absphi = acos(sqrt((1 + sqrt(delta))/2));
    signephi = sign(A(2)*(cos(absphi)^2 - sin(absphi)^2)/(A(1) - A(3)));
    phi = signephi*absphi;
endfunction

function [x,y]=trouve_centre(A)
    // A : coefficients de la formule quadratique (matrice colonne réelle)
    // x, y : coordonées du centre de l'ellipse (réels)
    delta = A(2)^2 - 4*A(1)*A(3);
    x = (2*A(3)*A(4) - A(2)*A(5))/delta;
    y = (2*A(1)*A(5) - A(2)*A(4))/delta;
endfunction

function [rx, ry]=trouve_rayons(a, phi, xc, yc)
    // a : coefficients de la formule quadratique (matrice colonne réelle)
    // phi : angle que fait un axe de l'ellipse avec x
    // xc, yc : coordonnées du centre de l'ellipse
    // rx, ry : rayons (grand et petit demi-grands axes) de l'ellipse
    A = [a(1), a(2)/2 ; a(2)/2, a(3)];
    Q = rotate([1,0;0,1], phi); // matrice de rotation
    t = [xc;yc]; // matrice de translation
    Abar = Q'*A*Q;
    b = [a(4);a(5)];
    bbar = (2*t'*A + b')*Q;
    c = a(6);
    cbar = t'*A*t + b'*t + c;
    rx = sqrt(-cbar/Abar(1,1));
    ry = sqrt(-cbar/Abar(2,2));
endfunction

function [] = trace_ellipse(xc, yc, a, b, phi)
    // trace l'ellipse de centre (xc, yc)
    // de rayons a et b et tournée de phi
    pas = 0.1;
    t = 0:pas:%pi/2;
    X = a*cos(t);
    Y = b*sin(t);
    n = 4*size(X,'*');
    XY1 = [X, -flipdim(X,2), -X, flipdim(X,2);...
        Y, flipdim(Y,2), -Y, -flipdim(Y,2)];
    XY = rotate(XY1, phi) + [xc*ones(1,n);yc*ones(1,n)];
    xpoly(XY(1,:), XY(2,:));
endfunction

// **********
// Programme principal
// **********

// lecture des données

Xdef = X0';
Ydef = Y0';

// Régression
aopt = regression_elliptique(Xdef, Ydef);

// affichage des paramètres
disp(aopt)

phi = trouve_rotation(aopt);
phideg = phi*180/%pi;
[xc, yc] = trouve_centre(aopt);
[a, b] = trouve_rayons(aopt, phi, xc, yc);
disp('phi = '+string(phi)+' rad = '+string(phideg)+'°.');
disp('C('+string(xc)+' ; '+string(yc)+').');
disp('a = '+string(a)+' ; b = '+string(b)+'.');

// tracé
clf;

plot(Xdef, Ydef, 'b+')
isoview(0, 10, 1, 9);
plot(xc, yc, 'r+')
trace_ellipse(xc, yc, a, b, phi);
ell = gce();
ell.foreground = 5;

It is also possible to use the Halíř algorithm (split matrices). The algorithm is more stable, and the result is the same.

function [a] = regression_elliptique(X, Y) // Halir
    // méthode de la distance algébrique
    // X, Y : points expérimentaux, matrices colonnes réelles
    // a : coefficients de la formule quadratique (matrice colonne réelle)
    D1 = [X.*X, X.*Y, Y.*Y];
    D2 = [X, Y, ones(X)];
    // matrices de conception (design m.)
    S1 = D1'*D1; 
    S2 = D1'*D2;
    S3 = D2'*D2;
    // matrices de dispersion (scatter m.)
    T = -inv(S3)*S2';
    N = S1+ S2*T;
    M = [0.5*N(3, :) ; -N(2,:) ; 0.5*N(1, :)]; // mult par inv(C1) à gauche
    // matrice de dispersion réduite
    [vecpropres, valpropres] = spec(M);
    vep = real(vecpropres);
    // détermination du système propre
    condition = 4*vep(1, :).*vep(3, :) - vep(2, :).^2;
    // évaluation de a'Ca
    a1 = vep(:, find(condition > 0));
    a = [a1 ; T*a1]; // vecteur propre correspondant à la solution
endfunction

许可协议

我,本作品著作权人,特此采用以下许可协议发表本作品:
GNU head 已授权您依据自由软件基金会发行的无固定段落及封面封底文字(Invariant Sections, Front-Cover Texts, and Back-Cover Texts)的GNU自由文件许可协议1.2版或任意后续版本的条款,复制、传播和/或修改本文件。该协议的副本请见“GNU Free Documentation License”。
w:zh:知识共享
署名 相同方式共享
本文件采用知识共享署名-相同方式共享3.0 未本地化版本2.5 通用2.0 通用1.0 通用许可协议授权。
您可以自由地:
  • 共享 – 复制、发行并传播本作品
  • 修改 – 改编作品
惟须遵守下列条件:
  • 署名 – 您必须对作品进行署名,提供授权条款的链接,并说明是否对原始内容进行了更改。您可以用任何合理的方式来署名,但不得以任何方式表明许可人认可您或您的使用。
  • 相同方式共享 – 如果您再混合、转换或者基于本作品进行创作,您必须以与原先许可协议相同或相兼容的许可协议分发您贡献的作品。
您可以选择您需要的许可协议。

说明

添加一行文字以描述该文件所表现的内容

此文件中描述的项目

描繪內容

文件历史

点击某个日期/时间查看对应时刻的文件。

日期/时间缩⁠略⁠图大小用户备注
当前2012年12月21日 (五) 10:022012年12月21日 (五) 10:02版本的缩略图452 × 364(21 KB)Cdang{{Information |Description ={{en|1=sign error in algorithm}} |Source ={{own}} |Author =Cdang |Date = |Permission = |other_versions = }}
2012年12月19日 (三) 13:302012年12月19日 (三) 13:30版本的缩略图452 × 364(21 KB)Cdang{{Information |Description ={{en|1=Ellipse fitting, using the method of the algebraic distance. Fitzgibbon algorithm, with test data from Gander et al.}} {{fr|1=Régression elliptique, méthode de la distance algébrique. Algorithme de Fitzgibbon, a...

没有页面链接到本图像。

全域文件用途

以下其他wiki使用此文件:

元数据