function CompareImg(A1 , A2)
if size(A1) ~= size(A2)
disp('两幅图像的大小不一致');
else
F1 = figure;
set(F1,'units','normalized','position',[0 0 1 1])
subplot(1,2,1);
imshow(A1);
a1 = get(F1,'currentaxes');
set(a1,'position',[0 0 0.5 1])
subplot(1,2,2);
imshow(A2);
a2 = get(F1,'currentaxes');
set(a2,'position',[0.5 0 0.5 1])
dcm = datacursormode;
datacursormode on;
set(dcm,'DisplayStyle','Datatip','UpdateFcn',{@Compare_Callback,A1,A2});
h = zoom;
set(h,'ActionPostCallback',@zoomcallback);
set(h,'enable','off');
end
function zoomcallback(~,~)
YLim = get(gca,'ylim');
XLim = get(gca,'xlim');
if gca == a2
set(a1,'xlim',XLim,'YLim',YLim);
else
set(a2,'xlim',XLim,'YLim',YLim);
end
end
function output_txt = Compare_Callback(obj, event_obj, orig,targ)
pos = get(event_obj,'Position');
i = round(pos(1));
j = round(pos(2));
G = orig(j,i);
if nargin == 4
G1 = targ(j,i);
output_txt = {['COL: ',num2str(i,4),' ROW: ',num2str(j,4), char(10),...
'左侧G: ',num2str(round(G)), ' 右侧G: ',num2str(round(G1))]};
end
end
end
第一篇记录,Matlab比较两幅图像的像素值
最新推荐文章于 2023-10-21 14:07:12 发布