mos2.m
上传用户:jiangyu148
上传日期:2014-10-19
资源大小:2124k
文件大小:3k
源码类别:

图形图象

开发平台:

Matlab

  1. function I=mos2(image1,image2,row,col); 
  2. L=double(image1);
  3. R=double(image2);
  4. h1=size(L,1);
  5. w1=size(L,2);
  6. h2=size(R,1);
  7. w2=size(R,2);
  8. col=w1-(610-col);%w_2 must have stable value, not alter as program goes 
  9. LL=w1-col+1;
  10. TT=h1-row+1;
  11. dd=1/LL;
  12. if TT<h2    
  13.     new=zeros(h2+row-1,w1+w2-LL,3);
  14.     %%%%%%%%%%%%
  15.     new(1:h1,1:w1-LL,1)=L(1:h1,1:w1-LL,1)/255;
  16.     new(1:row-1,col:w1,1)=L(1:row-1,col:w1,1)/255;
  17.     new(row:h2+h1-TT,w1+1:w1+w2-LL,1)=R(1:h2,LL+1:w2,1)/255; 
  18.     new(h1+1:h1+h2-TT,col:w1,1)=R(TT+1:h2,1:LL,1)/255;
  19.     for i=1:h1-row+1
  20.         for j = 1:LL
  21.             new(row+i-1,j+w1-LL,1) = (L(row+i-1,j+w1-LL, 1) * (1 - (0.5* sin (pi*j * dd - pi/2) + 0.5)) ...
  22.                                  +  R(i,j,1) * (0.5* sin (pi*j * dd - pi/2) + 0.5))/255; 
  23.         end
  24.     end
  25.     %%%%%%%%%%%%%
  26.     new(1:h1,1:w1-LL,2)=L(1:h1,1:w1-LL,2)/255;
  27.     new(1:row-1,col:w1,2)=L(1:row-1,col:w1,2)/255;
  28.     new(row:h2+h1-TT,w1+1:w1+w2-LL,2)=R(1:h2,LL+1:w2,2)/255; 
  29.     new(h1+1:h1+h2-TT,col:w1,2)=R(TT+1:h2,1:LL,2)/255;
  30.     for i=1:h1-row+1
  31.         for j = 1:LL
  32.             new(row+i-1,j+w1-LL,2) = (L(row+i-1,j+w1-LL, 2) * (1 - (0.5* sin (pi*j * dd - pi/2) + 0.5)) ...
  33.                                  +  R(i,j,2) * (0.5* sin (pi*j * dd - pi/2) + 0.5))/255; 
  34.         end
  35.     end
  36.     %%%%%%%%%%%%%
  37.     new(1:h1,1:w1-LL,3)=L(1:h1,1:w1-LL,3)/255;
  38.     new(1:row-1,col:w1,3)=L(1:row-1,col:w1,3)/255;
  39.     new(row:h2+h1-TT,w1+1:w1+w2-LL,3)=R(1:h2,LL+1:w2,3)/255; 
  40.     new(h1+1:h1+h2-TT,col:w1,3)=R(TT+1:h2,1:LL,3)/255;
  41.     for i=1:h1-row+1
  42.         for j = 1:LL
  43.                    new(row+i-1,j+w1-LL,3) = (L(row+i-1,j+w1-LL, 3) * (1 - (0.5* sin (pi*j * dd - pi/2) + 0.5)) ...
  44.                                  +  R(i,j,3) * (0.5* sin (pi*j * dd - pi/2) + 0.5))/255; 
  45.         end
  46.     end
  47. else
  48.    new=zeros(h1,w1+w2-LL,3);
  49.    %%
  50.    new(1:h1,1:w1-LL,1)=L(1:h1,1:w1-LL,1)/255;
  51.    new(1:row-1,col:w1,1)=L(1:row-1,col:w1,1)/255;
  52.    new(row:h2+h1-TT,w1+1:w1+w2-LL,1)=R(1:h2,LL+1:w2,1)/255; 
  53.    new(h1+1:h1+h2-TT,col:w1,1)=R(TT+1:h2,1:LL,1)/255;
  54.    for i=1:h2
  55.         for j = 1:LL
  56.             new(row+i-1,j+w1-LL,1) = (L(row+i-1,j+w1-LL, 1) * (1 - (0.5* sin (pi*j * dd - pi/2) + 0.5)) ...
  57.                                  +  R(i,j,1) * (0.5* sin (pi*j * dd - pi/2) + 0.5))/255; 
  58.         end
  59.    end
  60.    %%%%%%%%%%%%%
  61.    new(1:h1,1:w1-LL,2)=L(1:h1,1:w1-LL,2)/255;
  62.    new(1:row-1,col:w1,2)=L(1:row-1,col:w1,2)/255;
  63.    new(row:h2+h1-TT,w1+1:w1+w2-LL,2)=R(1:h2,LL+1:w2,2)/255; 
  64.    new(h1+1:h1+h2-TT,col:w1,2)=R(TT+1:h2,1:LL,2)/255;
  65.    for i=1:h2
  66.         for j = 1:LL
  67.             new(row+i-1,j+w1-LL,2) = (L(row+i-1,j+w1-LL, 2) * (1 - (0.5* sin (pi*j * dd - pi/2) + 0.5)) ...
  68.                                  +  R(i,j,2) * (0.5* sin (pi*j * dd - pi/2) + 0.5))/255; 
  69.         end
  70.    end
  71.    %%%%%%%%%%%%%
  72.    new(1:h1,1:w1-LL,3)=L(1:h1,1:w1-LL,3)/255;
  73.    new(1:row-1,col:w1,3)=L(1:row-1,col:w1,3)/255;
  74.    new(row:h2+h1-TT,w1+1:w1+w2-LL,3)=R(1:h2,LL+1:w2,3)/255; 
  75.    new(h1+1:h1+h2-TT,col:w1,3)=R(TT+1:h2,1:LL,3)/255;
  76.    for i=1:h2
  77.         for j = 1:LL
  78.             new(row+i-1,j+w1-LL,3) = (L(row+i-1,j+w1-LL, 3) * (1 - (0.5* sin (pi*j * dd - pi/2) + 0.5)) ...
  79.                                  +  R(i,j,3) * (0.5* sin (pi*j * dd - pi/2) + 0.5))/255; 
  80.         end
  81.    end 
  82. end
  83. I=new;