Verfasst am: 28.06.2010, 21:02
Titel: Ellipse in einem Bild fitten
Hallo Leute,
ich habe Bilder einer mehr oder weniger ellipsoiden Form. Ich will ein Fit mit einer Ellipse machen. Wie das mit einem Kreis geht weiss ich bereits, aber das mit der Ellipse funktioniert leider nicht. Ich will ausserdem die geometrischen Daten der Ellipse (Breite und Hoehe wissen) Kann mir da jemand bitte helfen?
% solve for parameters a, b, and c in the least-squares sense by % using the backslash operator
abc = [x y ones(length(x),1)] \ -(x.^2+y.^2);
a = abc(1); b = abc(2); c = abc(3);
% calculate the location of the center and the radius
xc = -a/2;
yc = -b/2;
radius = sqrt((xc^2+yc^2)-c)
% display the calculated center plot(xc,yc,'rx','LineWidth',2);
% use parametric representation of the circle to obtain coordinates % of points on the circle
Xfit = radius*cos(theta) + xc;
Yfit = radius*sin(theta) + yc;
Was verstehst du unter Bildern mit elliptischer Form?
Als ich das gestern nacht gelesen habe, musste ich spontan an den Heydemann-Algorithmus denken. Wird in der Interferometrie verwendet und fittet ziemlich gut in Daten (x,y) die entsprechende Funktion (z.B. Ellipse).
_________________
also ich meine Bilder von einem ellipsoiden Objekt. Eine Funktion zum Fitten habe ich nun. Aber ich habe das Problem, dass mein Programm nur die obere Haelfte meiner Ellipse findet, untere Haelfte leider nicht, daher funktioniert das Fitten auch nicht. Momentan sieht der Code folgendermassen aus
% remove bias of the ellipse - to make matrix inversion more accurate. (will be added later on).
mean_x = mean(x);
mean_y = mean(y);
x = x-mean_x;
y = y-mean_y;
% the estimation for the conic equation of the ellipse
X = [x.^2, x.*y, y.^2, x, y ];
a = sum(X)/(X'*X);
% check if conic equation represents an ellipse
test = a*c;
switch(1) case(test>0), status = '';
case(test==0), status = 'Parabola found'; warning( 'fit_ellipse: Did not locate an ellipse' );
case(test<0), status = 'Hyperbola found'; warning( 'fit_ellipse: Did not locate an ellipse' );
end
% if we found an ellipse return it's data if(test>0)
% make sure coefficients are positive as required if(a<0), [a,c,d,e] = deal( -a,-c,-d,-e ); end
% rotate the axes backwards to find the center point of the original TILTED ellipse
R = [ cos_phi sin_phi; -sin_phi cos_phi ];
P_in = R * [X0;Y0];
X0_in = P_in(1);
Y0_in = P_in(2);
das Problem mit der unteren Ellipsenhaelfe ist geloest, aber ich schaffe es grade nicht die Ellipse zu fitten. Bekomme immer ein "out of memory" als Fehler. Was kann ich da machen?
%% Ellipse
x = [contour(:,2) ;contour2(:,2);contour3(:,2);contour4(:,2);contour5(:,2)];
y = [contour(:,1) ;contour2(:,1);contour3(:,1);contour4(:,1);contour5(:,1)];
x = transpose(x);
y = transpose(y);
Du kannst Beiträge in dieses Forum schreiben. Du kannst auf Beiträge in diesem Forum antworten. Du kannst deine Beiträge in diesem Forum nicht bearbeiten. Du kannst deine Beiträge in diesem Forum nicht löschen. Du kannst an Umfragen in diesem Forum nicht mitmachen. Du kannst Dateien in diesem Forum posten Du kannst Dateien in diesem Forum herunterladen
MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, and Embedded MATLAB are trademarks of The MathWorks, Inc.