How should we evaluate the similarity of two graphs?
25 次查看(过去 30 天)
显示 更早的评论
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),'.')
0 个评论
回答(2 个)
Matt J
2022-9-21
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 );
ellipse1=polyshape( ellipse_estimation );
plot([ellipse0,ellipse1])
percentError = abs( area(intersect(ellipse0,ellipse1))/area(ellipse0)*100-100)
0 个评论
Chunru
2022-9-21
load ellipse_original
load ellipse_estimation
whos
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
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Polar Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!