;------------------------------------------------------------- ;+ ; NAME: ; SHIFT_IM_CBC ; PURPOSE: ; This function given an image and two floating point ; scalars that describe a shift to be applied to that ; image in x and y, will then apply that shift to the ; image using a cubic convolution interpolation. ; CATEGORY: ; IMAGE PROCESSING ; CALLING SEQUENCE: ; ssfxy = shift_im_cbc(qf,odelx,odely) ; INPUTS: ; qf = An image that will be shifted. ; type: array,any type,arr(nx,ny) ; odelx = The value of the decimal shift in the x-direction. ; type: scalar,floating point ; odely = The value of the decimal shift in the y-direction. ; type: scalar,floating point ; KEYWORD PARAMETERS: ; OUTPUTS: ; ssfxy = The shifted 2d array. ; type: array,floating point,fltarr(nx,ny) ; COMMON BLOCKS: ; NOTES: ; MODIFICATION HISTORY: ; H. Cohl, 27 Mar, 1991 --- Initial implementation. ;- ;------------------------------------------------------------- function shift_im_cbc,qf,odelx,odely,help=help ;Display idl header if help is required. if keyword_set(help) or n_params() lt 3 then begin get_idlhdr,'shift_im_cbc.pro' ssfxy=-1 goto,finishup endif ;Convert values to floating point. f=qf*1. delx=odelx*1. dely=odely*1. ;Determine size of array. ssz=size(f) nx=ssz(1) ny=ssz(2) ;Determine integer part of shift in x and y. fdx=fix(delx) fdy=fix(dely) ;Shift image by fdx and fdy. sf=shift(f,fdx,fdy) ssfx=sf ;Determine remaining shift and other shift values. dx=delx-fdx dy=dely-fdy x=findgen(nx) y=findgen(ny) nnx=x-dx nny=y-dy h=1 ;Apply shift in x. ; print, x xw=x(3-2:3+2) s=f_cbc(nnx(3),xw,h) for i=0,nx-1 do begin if (nnx(i) lt x(2)) then begin ; ssfx(i,*)=sf(i+abs(fdx),*) ssfx(i,*)=sf(i,*) ;sf is already integer shifted endif else if (nnx(i) gt x(nx-3)) then begin ; ssfx(i,*)=sf(i-abs(fdx),*) ssfx(i,*)=sf(i,*) endif else begin ;print,s,total(s) ssfx(i,*)=s(0)*sf(i-2,*)+\$ s(1)*sf(i-1,*)+\$ s(2)*sf(i, *)+\$ s(3)*sf(i+1,*)+\$ s(4)*sf(i+2,*) endelse endfor ;Apply shift in y. ssfxy=ssfx yw=y(3-2:3+2) s=f_cbc(nny(3),yw,h) for i=0,ny-1 do begin if (nny(i) lt y(2)) then begin ; ssfxy(*,i)=ssfx(*,i+abs(fdy)) ssfxy(*,i)=ssfx(*,i) endif else if (nny(i) gt y(ny-3)) then begin ; ssfxy(*,i)=ssfx(*,i-abs(fdy)) ssfxy(*,i)=ssfx(*,i) endif else begin ssfxy(*,i)=s(0)*ssfx(*,i-2)+\$ s(1)*ssfx(*,i-1)+\$ s(2)*ssfx(*,i) +\$ s(3)*ssfx(*,i+1)+\$ s(4)*ssfx(*,i+2) endelse endfor finishup: return,ssfxy end