I am trying to plot a series of ellipses on Matlab. Basically I have a microscopic picture and I process it with ImageJ to obtain a series of data (area, center, major and minor axes) for each ellipse. I am trying to replot those ellipses on matlab in order to after add a gradient color to map the picture so I can tell from the ellipse in which direction the fibre is. This is my code
clearvars -except data colheaders %Clear everything but the original data
data(:,9)=data(:,9)*pi/180; %Transform my 9th colomn (rotation angle) in rad
data(:,6)=1196-data(:,6); %Recalibrate the y axis (different coordinate system)
for i=1:29 %29 ellipses to plot
theta = 0 : 0.01 : 2*pi;
x = data(i,7)/2 * cos(theta) * cos(data(i,9)) - data(i,8)/2 * sin(theta) * sin(data(i,9)) + data(i,5);
y = data(i,7)/2 * sin(theta) * cos(data(i,9)) + data(i,8)/2 * cos(theta) * sin(data(i,9)) + data(i,6);
plot(x, y, 'LineWidth', 1);
hold on
end
% Columns (5,6) are the centre (x,y) of the ellipse
% Columns (7,8) are the major and minor axes (a,b)
% Column 9 is the rotation angle with the x axis
axis equal; % Keep axis same size as sample picture
xlim([0 1592]);
ylim([0 1196]);
grid on;
I can send a picture on private, seems they don't let me upload one. But i obtain circles at the right location instead of ellipses. Are my equations right ? Best Dorian