x=[2 3 1; 1 4 2;3 3 1];% Image h=[1 1 1; 2 0 1;0 1 2];% Filter m=size(x);% Save the size of image matrix (3x3) n=size(h);% save size of filter matrix (3x3) M1=m(1)%save value of the row of the image matrix M2=n(1)%save value of the row of the filter matrix N1=m(2)%save value of the column of the image matrix N2=n(2)%save value of the column of the filter matrix X=[x,zeros(M1,N1)];% expantion the image matrix (3 x 6 ) X=[X;zeros(M1,N1*2)];% expantion the image matrix (6 x 6 ) H=[h,zeros(M2,N2)];% expantion the image matrix (3 x 6 ) H=[H;zeros(M2,N2*2)];% expantion the image matrix (6 x 6 )

for i=1:M1+M2-1 for k=1:N1+N2-1 y(i,k)=0; for j=1:M1 for s=1:N1 if(i-j+1>0&&k-s+1>0) y(i,k)=y(i,k)+X(j,s)*H(i-j+1,k-s+1); end end end end end y