How should we evaluate the similarity of two graphs?

22 visualizaciones (últimos 30 días)
장훈 정
장훈 정 el 21 de Sept. de 2022
Respondida: Chunru el 21 de Sept. de 2022
I estimated the ellipse, and thought about it in my own way for comparison with the actual ellipse.
If you plot the graph in the Cartesian coordinate system through the attached file, you can see that the difference is not large.
In the figure below, the blue line is the estimated ellipse, and the red line is the actual ellipse.
To check the difference between the two graphs, I changed the polar coordinates, and calculated the difference in the lengths of the two graphs assuming that thetha is the same in polar coordinates. Likewise, blue is the estimated ellipse, and red is the polar coordinates of the actual ellipse.
I simply calculated the difference between the two data's r value and then plotted it, but the difference is too large than I thought, which is confusing.
The MSE is also much larger than I thought, but in fact, it is unlikely that the MSE of the two data will be too large.
It seems to be a data sorting problem, but I would like to ask how to solve it.
Also, the difference between each angle is up to 3mm, so please help me to see that.
load ellipse_original.mat
load ellipse_estimation.mat
m = ellipse_original(:,1);
n = ellipse_original(:,2);
x = ellipse_estimation(:,1);
y = ellipse_estimation(:,2);
plot(x,y,'.b')
xlim([-150 150])
ylim([-150 150])
pbaspect([1 1 1])
grid on; grid minor
hold on
plot(m,n,'.r')
hold off
%%
[th r] = cart2pol(m,n);
[xth yr] = cart2pol(x,y);
plot(th,r,'.b')
hold on
plot(xth,yr,'.r')
hold off
%%
plot(th,(r-yr),'.')

Respuestas (2)

Matt J
Matt J el 21 de Sept. de 2022
I don't know why you think the MSE is "large", but perhaps the percent area difference would be more suitable to you:
load ellipse_original.mat
load ellipse_estimation.mat
ellipse0=polyshape( ellipse_original );
Warning: Polyshape has duplicate vertices, intersections, or other inconsistencies that may produce inaccurate or unexpected results. Input data has been modified to create a well-defined polyshape.
ellipse1=polyshape( ellipse_estimation );
Warning: Polyshape has duplicate vertices, intersections, or other inconsistencies that may produce inaccurate or unexpected results. Input data has been modified to create a well-defined polyshape.
plot([ellipse0,ellipse1])
percentError = abs( area(intersect(ellipse0,ellipse1))/area(ellipse0)*100-100)
percentError = 0.9974

Chunru
Chunru el 21 de Sept. de 2022
load ellipse_original
load ellipse_estimation
whos
Name Size Bytes Class Attributes ans 1x47 94 char cmdout 1x33 66 char ellipse_estimation 1000x2 16000 double ellipse_original 1000x2 16000 double
plot(ellipse_original(:,1), ellipse_original(:,2), 'r', ellipse_estimation(:, 1), ellipse_estimation(:,2), 'b');
% conver the geometric shape into image
im1 = shp2im(ellipse_original);
im2 = shp2im(ellipse_estimation);
% Now compare two images
black1 = im1 == 0;
black2 = im2 == 0;
common = black1 & black2;
similarity = sum(common(:))/sum(black1(:))
similarity = 0.9976
function im = shp2im(x)
% Convert shape into binary image
figure
fill(x(:,1), x(:,2), 'k'); axis equal
F = getframe(gcf);
F = im2gray(F.cdata);
im = F>0; % binary: 0 for black & 1 for white
imagesc(im); colormap([0 0 0; 1 1 1]); axis equal
end

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by