;******************************************************************** ;NAME : rshift (procedure) ;FUNCTION : shift an image with flaction distance ; K.I. '92/04/26 ; "92/09/02 ; "92/11/07 ; "93/01/23 ;==================================================================== function rshift,img,dx,dy,missing=missing ; missing : replace the pixel near the edge with this value s=size(img) nx=s(1) & ny=s(2) case s(0) of 2: begin if dx eq 0.0 and dy eq 0.0 then return,img idx=fix(dx) & if dx lt 0 then idx=idx-1 idy=fix(dy) & if dy lt 0 then idy=idy-1 rimg=shift(img,idx,idy) ddx=dx-idx ddy=dy-idy if (ddx ne 0) or (ddy ne 0) then $ rimg = ( (1.-ddy)*( (1.-ddx)*rimg + ddx*shift(rimg,1,0) ) + $ ddy *( (1.-ddx)*shift(rimg,0,1) + ddx*shift(rimg,1,1) ) ) if n_elements(missing) gt 0 then begin if dx ge 0 then rimg(0:idx,*)=missing $ else rimg(nx+idx:nx-1,*)=missing if dy ge 0 then rimg(*,0:idy)=missing $ else rimg(*,ny+idy:ny-1)=missing endif end 1: begin if dx eq 0.0 then return,img idx=fix(dx) & if dx lt 0 then idx=idx-1 rimg=shift(img,idx) ddx=dx-idx if (ddx ne 0) then $ rimg = ( (1.-ddx)*rimg + ddx*shift(rimg,1) ) if n_elements(missing) gt 0 then begin if dx ge 0 then rimg(0:idx)=missing $ else rimg(nx+idx:nx-1)=missing endif end endcase type=s(n_elements(s)-2) if type eq 2 then rimg=fix(rimg) if type eq 3 then rimg=long(rimg) if type eq 4 then rimg=float(rimg) if type eq 7 then rimg=byte(rimg) return,rimg end