matlab 两幅图像配准

来源:互联网 发布:rewear it aac 编辑:程序博客网 时间:2024/06/10 19:54
两幅图像配准。修改图像路径之后,由于uiwait(msgbox('Click OK after closing the CPSELECT window.','Waiting...'));会有弹窗,先无视别关掉。接着再两幅图像选定
成对对称点,保存工作空间再退出就可以了。
% use matlab tools to register images
%图像配准,一幅图像时另外一副图像的一部分
clear all;clc;I1=imread('C:\Users\山猪\Desktop\12345.jpg');I2=imread('C:\Users\山猪\Desktop\12345.jpg');unregistered =I2;%%未配准图像rect=I1;%%参考图像cpselect(unregistered,rect);%%%选择点对,选完后记得保存uiwait(msgbox('Click OK after closing the CPSELECT window.','Waiting...'));%创建一个按钮,等待用户反映fixedPoints=round(fixedPoints);movingPoints=round(movingPoints);input_points_corr= cpcorr(movingPoints,fixedPoints,unregistered,rect);%调整控制点位置tform = cp2tform(input_points_corr,movingPoints,'linear conformal');%%控制点的空间变换registered = imtransform(unregistered,tform,'XData',[1 300], 'YData',[1 300]);%%对图像进行重采样H.Position=[232 258 600 402];figure(H)subplot(2,2,1)imagesc(rect)title('Original image 1')subplot(2,2,3)imagesc(unregistered)title('Unmatched image 2')subplot(2,2,2)imagesc(rect)title('Original image 1')subplot(2,2,4)imagesc(registered)title('Matched image 2')colormap (gray)



原创粉丝点击