pro findmax,image,xpos,ypos,maximum,ap = ap,nodisp = nodisp if n_params() lt 1 then begin print,'Usage: pro findmax,imgs,[/ap],[nodisp]' return end ; find the peak pixel within some radius of the location ; defined by the cursor if keyword_set(ap) eq 0 then ap = 6 print print,' left or middle button to center apertures' print,' right button to finish' print sz = size(image) ;print,format='(a4," ",a4)','xpeak ',' ypeak ' repeat begin cursor,x,y,/device,/wait if (!err eq 1) or (!err eq 2) then begin x0 = floor(x-ap) x1 = ceil(x+ap) y0 = floor(y-ap) y1 = ceil(y+ap) if (x0 lt 0.0) or (x1 gt (sz(1)-1)) $ or (y0 lt 0.0) or (y0 gt (sz(2)-1)) then begin print,'** WARNING: aperture is off the image! **' endif x0 = x0 > 0.0 x1 = x1 < (sz(1)-1) y0 = y0 > 0.0 y1 = y1 < (sz(2)-1) img = image(x0:x1,y0:y1) maximum = max(img) w = where( image eq maximum) ; Find the corresponding x & y whereis,image,w,xpos,ypos print,format='(i5,i5,g9.3)', xpos,ypos,maximum if keyword_set(nodisp) eq 0 then tvh,image,/silent tvcircle,ap,xpos,ypos wait,0.2 endif endrep until (!err eq 4) end