pro gsstab,movin,movout,optio ; CORRECTION OF GLOBAL SHIFTS of a movie in a 3-D array MOVIN, ; result is a 3-D array MOVOUT. ; Procedures called: ALIGN_C2, FIVEPOIN, MAXLOC, MEAN, NINT ; Reference image: either the average of movie frames or individual frame. ; This is selected by "optio": optio=0, average frame, optio=n, frame no. n. ; The routine is faster when the image size is xsiz = ysiz = 2^n. ; version of 14.3.95, Michal. smov=size(movin) if smov(0) ne 3 then begin print,'GSSTAB: Input must be a 3-D array!' stop endif nima=smov(3) print,'number of frames:',nima ;............PARAMETERS.................................... wx=smov(1)-34 ;this allows the shifts up to +/- 16 pixels wy=smov(2)-34 ; (see comments in ALIGN_C2) ;.......................................................... movout=movin*0 if optio gt 0 then goto,indiv ; average reference ref=total(movin,3)/nima ; total returns float if smov(4) eq 1 then ref=bytscl(ref) ; conversion to bytes if smov(4) eq 2 then ref=fix(ref) ; conversion to integer goto,exec ; individual frame reference indiv: ref=movin(*,*,optio) exec: for i=0,nima-1 do begin offset=nint(align_c2(ref,movin(*,*,i),flg,wx,wy)) ; 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,movin(*,*,i)) ; correl_images cor_anal,corrmat,xof,yof ; corrmat_analyze offset=nint([xof,yof]) endif print,'frame no.',i,' shift:',offset movout(0,0,i)=shift(movin(*,*,i),offset(0),offset(1)) endfor end