PRO stabilw,from,to,shfts,offs,mov ; ;CORRECTION OF GLOBAL SHIFTS of WL frames of 23 or 25 June 1997. ;INPUTS: from = seq. of the first image in the subseries. ; to = seq. of the last image in the subseries. ; shfts = array of big image shifts measured manually ; by IBIGSHIFT. ; Derotated files XXjun/wdXX.seq, where XX is the date. ;OUTPUTS: offs = 2-column (x,y) array of cumulative shifts with ; respect to the 1st frame of the subseries, which, ; applied to frames, move them to the reference position ; of the 1st frame - only for check. ; Stabilized files XXjun/wsXX.seq, where XX is the date. ;METHOD: Cross correlation (ALIGN_C2 or COR_IMAG/COR_ANAL) - ; - derived from GSSTAB. If necessary, correction for ; "big shifts" is applied before the correlation. ; Procedures called: ALIGN_C2, FIVEPOIN, MAXLOC, MEAN, NINT, ; COR_IMAG, COR_ANAL. siz=size(shfts) nima=siz(2) offs=shfts*0.0 ;float ;............PARAMETERS.................................... if nima eq 321 then begin dat='23' x1=464 ;coords of correlation box for 23 June x2=751 ; 288x288 y1=152 y2=439 wx=238 ;this allows the shifts up to +/- 24 pixels wy=238 endif else begin dat='25' x1=784 ;coords of correlation box for 25 June x2=1071 ; 288x288 y1=136 y2=423 wx=238 ;this allows the shifts up to +/- 24 pixels wy=238 endelse im=intarr(1528,1024) ;image array nami=dat+'jun/wd'+dat+'.' ;I/O filenames namo=dat+'jun/ws'+dat+'.' mov=intarr(288,288,to-from+1) window,2,xsiz=144,ysiz=72 ;.......................................................... ;1st frame - nothing to be done openr,1,nami+strtrim(from,2) readu,1,im close,1 ref=float(im(x1:x2,y1:y2)) openw,1,namo+strtrim(from,2) writeu,1,im close,1 mov(0,0,0)=im(x1:x2,y1:y2) ;loop over frames ........................................ for i=from+1,to do begin openr,1,nami+strtrim(i,2) readu,1,im close,1 im1=shift(im,total(shfts(0,from:i)),total(shfts(1,from:i))) ;putting the field into the right position if necessary, ; using cumulative big shifts ima=float(im1(x1:x2,y1:y2)) tvscl,rebin(ref,72,72,/sample),0 tvscl,rebin(ima,72,72,/sample),1 offset=align_c2(ref,ima,flg,wx,wy) ;float ; when align_c2 fails (flg=1) we call cor_imag, cor_anal... if (flg eq 1) then begin print,i,' ...cor_imag called...' corrmat=cor_imag(ref,ima) ; correl_images cor_anal,corrmat,xof,yof ; corrmat_analyze offset=[xof,yof] endif offset=offset+shfts(*,i) ref=ima ;reference for the next frame offs(*,i)=offs(*,i-1)+offset ;cumulative shifts (float) print,format='(i4," shift:",2f8.2," cumul.:",2f8.2)', $ i,offset(0),offset(1),offs(0,i),offs(1,i) im=shift(im,nint(offs(0,i)),nint(offs(1,i))) ;correction for shifts openw,1,namo+strtrim(i,2) writeu,1,im close,1 mov(0,0,i-from)=im(x1:x2,y1:y2) endfor END