pro deform2,oima,oref,war ; DESTRETCHING ; Image and reference image are divided into subimages and those of ima ; are shifted to correlate with those in ref. ; Calculation of grid-points before and after shifts of subimages of ima ; with respect to subimages of ref, then applying WARP_TRI. ; INPUTS: ima - image to be destretched (warped) ; ref - reference image ; OUTPUTS: war - resulting warped image ; ; Procedures called: align_cr, fivepoin, maxloc, mean, nint, warp_tri, ; cor_imag, cor_anal, smoothe (Oslo). sima=size(oima) sref=size(oref) if sima(0) lt 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 ; --------------------- PARAMETERS TO BE CHANGED ---------------------- ; smoothing parameter (in pixels) for unsharp masking smo=15 ; (about 1") or 23 (about 1.5") ; numbers of grid-points xpoints= 9 ; or 17 ypoints= 9 ; half-sizes of subimages around grid-points (pixels) xenvi=32 ; or 16 yenvi=32 ; maximum allowed shift of grid-points (pixels) msh=8 ; ______________________________________________________________________ ; Equalized image and reference (unsharp masking and log scaling)... ima=smoothe(oima,smo) ref=smoothe(oref,smo) ima=oima-ima ref=oref-ref ; Cutting negative values ima=ima>0 ref=ref>0 ; Scaling to be edible for ALOG ima=100.*float(ima)/mean(ima)>1. ; here is implied a selection that ref=100.*float(ref)/mean(ref)>1. ; BF must be brighter than 1% of mean ima=alog(ima) ref=alog(ref) ; .................................................................... ; xi,yi arrays of coordinates of initial grid points ; xo,yo arrays of coordinates of shifted grid points xi=intarr(xpoints * ypoints) xo=xi yi=xi yo=xi xmesh=fix(sima(1)/(xpoints-1)) ymesh=fix(sima(2)/(ypoints-1)) xgr=(indgen(xpoints))*xmesh ; x-axis grid ygr=(indgen(ypoints))*ymesh ; y-axis grid n=0 ; counter of grid-points for i=0,xpoints-1 do begin for j=0,ypoints-1 do begin ; definition of subimages in ima and ref lx=(xgr(i)-xenvi)>0 ux=(xgr(i)+xenvi-1)<(sima(1)-1) ly=(ygr(j)-yenvi)>0 uy=(ygr(j)+yenvi-1)<(sima(2)-1) im=ima(lx:ux,ly:uy) re=ref(lx:ux,ly:uy) ; determination of shifts using align_cr (by R.Molowny) offset=align_cr(re,im) ; align_cross... ; when align_cr fails (offset=[0,0]) we call cor_imag, cor_anal... if (offset(0) eq 0) and (offset(1) eq 0) then begin print,xgr(i),ygr(j),' cor_imag called...' corrmat=cor_imag(re,im) ; correl_images... cor_anal,corrmat,xof,yof ; corrmat_analyze... offset=[xof,yof] endif ; limitation ; if (abs(offset(0)) gt msh) or (abs(offset(1)) gt msh) then begin ; offset=[0,0] ; print,xgr(i),ygr(j),' shifts set to zero' ; endif if (abs(offset(0)) gt msh) or (abs(offset(1)) gt msh) then $ print,'***',xgr(i),ygr(j),' shift set to maximum' offset=offset>(-msh) offset=offset