pro deformo,oima,oref,war,smo,umq,wid,reb,INTERP=interp ; DESTRETCHING ; Image is deformed (interpolated) to match the Reference. ; The displacement maps vx,vy are computed by November's method ; (procedure DISTORTION_MAP or DISTORTI by R. Molowny, Oslo Lib) ; from Image and Reference equalized by unsharp masking. ; ; INPUTS: oima - image to be destretched ; oref - reference image ; ; smo - smoothing parameter (in pixels) for unsharp masking ; good values are 17[9] (~1") or 25[13] (~1.5") ; umq - coefficient of unsharp masking (um=ima-umq*smoothima) ; for smoo ~ 1.5" is good umq=0.5 ; wid - FWHM of November's smoothing gaussian window ; reb - down-rebinning factor to increase the effective size of ; pixels (good value is reb=2[1], i.e. get to 0.125"/pix) ; OUTPUTS: war - resulting destretched image ; ; KEYWORD: INTERP - If set, bicubic interpolation is chosen. Otherwise, ; bilinear interpolation is performed. ; ; CALLING SEQUENCE: deformo,ima,ref,war,smo,umq,wid,reb [,/interp] ; ; PROCEDURES CALLED: smoothe,mean,distorti ("distortion_map"); ; Distorti calls: sconvol,odd,(kconvol). ; Version 28.3.95 ; ON_ERROR,2 sima=size(oima) sref=size(oref) if sima(0) ne 2 then goto,wrong if sima(0) ne sref(0) then goto,wrong if sima(1) ne sref(1) then goto,wrong if sima(2) ne sref(2) then goto,wrong reb=fix(reb) ; assure that reb is integer ; --------------------- PARAMETERS TO BE CHANGED ---------------------- limit=5 ;4 maximum allowed shift (pixels) - about 0.5" ; ______________________________________________________________________ ; Equalized image and reference (unsharp masking and log scaling)... ima=SMOOTHE(oima,smo) ref=SMOOTHE(oref,smo) ima=oima-umq*ima ref=oref-umq*ref ; Cut negative values and make the logarithm, to enhance ; small and faint features ; ;ima=ima>1 ; careful with the values - here we have ;ref=ref>1 ; the normalization at 10000 ! ;ima=alog(ima) ;ref=alog(ref) ; Rebining ----------------------------------------------------------- wid1=wid if reb gt 1 then begin wid1=wid/reb ref=congrid(ref,sima(1)/reb,sima(2)/reb,/interp) ima=congrid(ima,sima(1)/reb,sima(2)/reb,/interp) endif ;print,' min/max ref:',min(ref),max(ref) ;print,' min/max ima:',min(ima),max(ima) ; Calling DISTORTION_MAP --------------------------------------------- DISTORTI,ref,ima,vx,vy,fwhm=wid1 ; Computation of original size and values of displacement maps ------- if reb gt 1 then begin vx=congrid(vx,sima(1),sima(2),/interp)*float(sima(1))/(sima(1)/reb) vy=congrid(vy,sima(1),sima(2),/interp)*float(sima(2))/(sima(2)/reb) endif ; Limitation --------------------------------------------------------- print,' displ. extrema',min(vx),max(vx),min(vy),max(vy) print,' displ. stdev ',stdev(vx),stdev(vy) vx=vx > (-1.*limit) vx=vx < limit vy=vy > (-1.*limit) vy=vy < limit ; Interpolation ------------------------------------------------------ x = LINDGEN(sima(1),sima(2)) ;Grids. y = x / sima(1) x = x MOD sima(1) IF NOT KEYWORD_SET(interp) THEN interp = 0 war=INTERPOLATE(oima,x+vx,y+vy,cubic=interp) goto,fin wrong: print,'DEFORMO: Input parameters must be images of equal size!' war=oima fin: end