How should we evaluate the similarity of two graphs?
49 views (last 30 days)
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.
m = ellipse_original(:,1);
n = ellipse_original(:,2);
x = ellipse_estimation(:,1);
y = ellipse_estimation(:,2);
pbaspect([1 1 1])
grid on; grid minor
[th r] = cart2pol(m,n);
[xth yr] = cart2pol(x,y);
Matt J on 21 Sep 2022
I don't know why you think the MSE is "large", but perhaps the percent area difference would be more suitable to you:
ellipse0=polyshape( ellipse_original );
ellipse1=polyshape( ellipse_estimation );
percentError = abs( area(intersect(ellipse0,ellipse1))/area(ellipse0)*100-100)
Chunru on 21 Sep 2022
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(:))
function im = shp2im(x)
% Convert shape into binary image
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