N=512;%一副512的图
tu1=imread('f.jpg');
tu2=imread('r.jpg');
tu1=double(rgb2gray(tu1));
tu2=double(rgb2gray(tu2));
% 把输入图像置于同一平面;
[hang1,lie1]=size(tu1);
[hang2,lie2]=size(tu2);
m1=floor(hang1/2);
m2=floor(hang2/2);
n1=floor(lie1/2);
n2=floor(lie2/2);
input=zeros(N);
input(N/2-m1+1:N/2+hang1-m1,N/4-n1+50:N/4+lie1-n1+49)=tu1;%这里用的是矩阵拆分
input(N/2-m2+1:N/2+hang2-m2,3*N/4-n2-40:3*N/4+lie2-n2-41)=tu2;
figure,imshow(input,[]);