Borrar filtros
Borrar filtros

The explanation of each step in ellipse fitting code

4 visualizaciones (últimos 30 días)
Walaa
Walaa el 6 de Abr. de 2023
Comentada: Matt J el 6 de Abr. de 2023
I need help understanding each line of this code.
% Calculate centroid, orientation and major/minor axis length of the ellipse
s = regionprops(BW,{'Centroid','Orientation','MajorAxisLength','MinorAxisLength'});
% Calculate the ellipse line
theta = linspace(0,2*pi);
col = (s.MajorAxisLength/2)*cos(theta);
row = (s.MinorAxisLength/2)*sin(theta);
M = makehgtform('translate',[s.Centroid, 0],'zrotate',deg2rad(-1*s.Orientation));
D = M*[col;row;zeros(1,numel(row));ones(1,numel(row))];

Respuesta aceptada

Matt J
Matt J el 6 de Abr. de 2023
Editada: Matt J el 6 de Abr. de 2023
I've added some comments.
% Calculate centroid, orientation and major/minor axis length of the ellipse
s = regionprops(BW,{'Centroid','Orientation','MajorAxisLength','MinorAxisLength'});
theta = linspace(0,2*pi);
col = (s.MajorAxisLength/2)*cos(theta);
row = (s.MinorAxisLength/2)*sin(theta); %coordinates of points (col,row) on unrotated ellipse
M = makehgtform('translate',[s.Centroid, 0],'zrotate',deg2rad(-1*s.Orientation)); %rotation matrix
D = M*[col;row;zeros(1,numel(row));ones(1,numel(row))];%points on rotated ellipse
  2 comentarios
Walaa
Walaa el 6 de Abr. de 2023
Movida: Matt J el 6 de Abr. de 2023
thanks you
Matt J
Matt J el 6 de Abr. de 2023
You are quite welcome.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Animation en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by