function [Warp0,Warp1,Warp,Mu,Nu] = BeierNeely(I0,I1,J0,J1,s); 
[m,n] = size(I0); 
//encadrement prealable des tableaux 
D=sqrt(m^2+n^2)/2; 
MM = ceil(D-m/2); 
NN = ceil(D-n/2); 
Iinit0= [zeros(MM,n);I0;zeros(MM,n)]; 
Iinit0 = [zeros(m+2*MM,NN) Iinit0 zeros(m+2*MM,NN)];
Iinit1= [zeros(MM,n);I1;zeros(MM,n)]; 
Iinit1 = [zeros(m+2*MM,NN) Iinit1 zeros(m+2*MM,NN)];
[N1,N2] = size(Iinit0); 
//repostionnement des segments 
J0init = J0 + [MM,NN,MM,NN]; 
J1init = J1 + [MM,NN,MM,NN]; 
//calcul des positions de reassignement 
[WarpPos0,WarpPos1,Mu,Nu] = BeierNeelyaux(Iinit0,Iinit1,J0init,J1init,s);
//operation de reassignement 
Warp0=zeros(N1,N2);
Warp1=zeros(N1,N2); 
for j=1: N1
  for k=1:N2  
     j0reass = WarpPos0(j,k,1); 
     k0reass = WarpPos0(j,k,2); 
     j1reass = WarpPos1(j,k,1); 
     k1reass = WarpPos1(j,k,2); 
     //remplissage de Warp0   
     if j0reass*(j0reass-(N1-1))>0 
        Warp0(j,k)=0; 
     elseif k0reass*(k0reass-(N2-1))>0 
        Warp0(j,k)=0; 
     else
        tt=j0reass-floor(j0reass); 
        ss=k0reass-floor(k0reass); 
        idXinf = floor(j0reass)+1; 
        idXsup = ceil(j0reass)+1; 
        idYinf = floor(k0reass)+1; 
        idYsup = ceil(k0reass) +1; 
        Iaux1 = (1-tt)*Iinit0(idXinf,idYinf) + tt*Iinit0(idXinf,idYsup); 
        Iaux2 = (1-tt)*Iinit0(idXsup,idYinf) + tt*Iinit0(idXsup,idYsup); 
        Warp0(j,k) = (1-ss)*Iaux1 + ss*Iaux2;
     end 
     //remplissage de Warp1  
     if j1reass*(j1reass-(N1-1))>0 
        Warp1(j,k)=0; 
     elseif k1reass*(k1reass-(N2-1))>0 
        Warp1(j,k)=0; 
     else
        tt=j1reass-floor(j1reass); 
        ss=k1reass-floor(k1reass); 
        idXinf = floor(j1reass)+1; 
        idXsup = ceil(j1reass)+1; 
        idYinf = floor(k1reass)+1; 
        idYsup = ceil(k1reass) +1; 
        Iaux1 = (1-tt)*Iinit1(idXinf,idYinf) + tt*Iinit1(idXsup,idYinf); 
        Iaux2 = (1-tt)*Iinit1(idXsup,idYinf) + tt*Iinit1(idXsup,idYsup); 
        Warp1(j,k) = (1-ss)*Iaux1 + ss*Iaux2;
     end           
  end
end 
Warp = (1-s)*Warp0 + s*Warp1; 
endfunction 
