;------------------------------------------------------------- ;+ ; NAME: ; SHIFTG ; PURPOSE: ; Procedure to find shift between a BBSO magnetogram and a grid ; produced by the HGRID function to estimate the limb position. ; ; This procedure, given two images a1 and a2, ; displays a1 overlaid with a scaled version of a2 (we assume ; a2 is a coordinate grid). ; The relative shift of a2 over a1 ; is controlled by moving the mouse and clicking. ; When done, the relative shift is printed on the screen. ; CATEGORY: ; IMAGE PROCESSING ; CALLING SEQUENCE: ; shiftg,a1,a2,... ; INPUTS: ; a1 = The first image. ; type: array, any type. ; a2 = The second image. ; type: array, any type. ; KEYWORD PARAMETERS: ; NOBYTE = If present, then NOBYTE specifies that a bytscl ; isn't to be performed. It assumes that the input is ; already in byte format. We assume a2 is always in short ; integer format (the output of HGRID). ; OUTPUTS: ; Prints relative shift of one image over the other. ; COMMON BLOCKS: ; NOTES: ; MODIFICATION HISTORY: ; J. Varsik, 09 Nov, 1995 --- Adapted from IMAGSCL program. ;- ;------------------------------------------------------------- pro shiftg,a1,a2,nbit=nbit,nobyte=nobyte,help=help ;Display idl header if help is required. if keyword_set(help) or n_params() lt 2 then begin get_idlhdr,'shiftg.pro' goto,finishup endif ;Print introduction. print,' -------------------' print,' Shiftg is running.' print," Type 'q' to exit. ' print,' Press a mouse button' print,' to shift the image.' print,' You may have to press' print,' the mouse button again' print," after typing 'q' to exit.' print,' -------------------' ;Byte scale images if (n_elements(nobyte) eq 0) then begin if (n_elements(nbit) ne 0) then begin if nbit eq 8 then div = 1 if nbit eq 9 then div = 2 if nbit eq 10 then div = 4 if nbit eq 11 then div = 8 if nbit eq 12 then div = 16 na1 = BYTSCL(FIX(a1 / div)+128,MIN=0,MAX=255) endif else begin maxa1 = max(a1) mina1 = min(a1) if (abs(mina1) gt maxa1) then begin big = abs(mina1) endif else begin big = maxa1 endelse na1 = BYTSCL(FIX((128./ big) * a1) + 128,MIN=0,MAX=255) endelse endif else begin na1=a1 endelse na2 = bytscl(a2,MIN=0,MAX=25000) dev=getenv('IDL_DEVICE') dnc=!d.n_colors if (dev(0) eq 'SUN') then begin ;Scale Images na1=235*na1/255. na2=235*na2/255. endif na2siz = size(na2) centerx = na2siz(1) / 2 centery = na2siz(2) / 2 nai = FIX(na1) + na2 nas = BYTSCL(nai,MAX=255,MIN=0) tv,nas while get_kbrd(0) ne 'q' do begin ; read mouse position cursor,mx,my,/device ; calculate image shift shiftx = centerx - mx shifty = centery - my nai = FIX(na1) + shift(na2,shiftx,shifty) nas = BYTSCL(nai,MAX=255,MIN=0) tv,nas print,'shiftx = ',shiftx,' shifty = ',shifty endwhile finishup: return end