pro slices, image, xx, yy
on_error,2
s = size(image)
nx = s[1]
ny = s[2]
maxv = max(image, min=minv)
orig_w = !d.window
orig_xs = !x.s
orig_ys = !y.s
orig_zs = !z.s
xtype = !X.TYPE
ytype = !Y.TYPE
ztype = !Z.TYPE
xsize = 0.5*!D.X_VSIZE
ysize = 0.5*!D.Y_VSIZE
xstart = !D.X_SIZE + 0.5 * !D.X_SIZE
ystart = !D.Y_SIZE - 0.15 * !D.Y_SIZE
tvcrs, 1
print, 'Left mouse button to toggle between rows and columns.'
print, 'Right mouse button to Exit.'
window, /FREE, xs=xsize, ys=ysize, xpos=xstart, ypos=ystart, title='Profiles'
new_w = !d.window
old_mode = -1
old_font = !p.font
!p.font = 0
mode = 0
!mouse.button = 0
while (!mouse.button ne 4) do begin
wset, orig_w
!x.s = orig_xs
!y.s = orig_ys
!z.s = orig_zs
!X.TYPE = xtype
!Y.TYPE = ytype
!Z.TYPE = ztype
cursor, a, b, 2, /DATA
x = where((abs(xx-a)) eq min(abs(xx-a)))
y = where((abs(yy-b)) eq min(abs(yy-b)))
if !mouse.button eq 1 then begin
mode = 1-mode
repeat begin
cursor, a, b, 0, /DATA
x = where((abs(xx-a)) eq min(abs(xx-a)))
y = where((abs(yy-b)) eq min(abs(yy-b)))
endrep until !mouse.button eq 0
endif
device, window_state = ws
wins = where(ws ne 0)
if ((where(wins eq new_w))[0] ge 0) then begin
wset, new_w
endif else $
return
if mode ne old_mode then begin
old_mode = mode
first = 1
if mode then begin
plot,[minv,maxv],minmax(yy),/nodata,title='Column Profile'
vecy = yy
end else begin
plot,minmax(xx),[minv,maxv],/nodata,title='Row Profile'
vecx = xx
endelse
endif
if (x lt nx) and (y lt ny) and $
(x ge 0) and (y ge 0) then begin
if first eq 0 then begin
erase
endif else first = 0
value = string(xx[x],FORMAT='(i8)')+string(yy[y], Format='(+f8.2)')
if mode then begin
vecx = image[x,*]
crossx = image[x,y]
crossy = yy[y]
title='Column Profile'
endif else begin
vecy = image[*,y]
crossx = xx[x]
crossy = image[x,y]
title = 'Row Profile'
endelse
plot, vecx, vecy, TITLE=title
xyouts, .1, 0, /NORM, value
oplot, [crossx], [crossy], PSYM=1, SYMSIZE=3
endif
endwhile
wset,orig_w
!x.s = orig_xs
!y.s = orig_ys
!z.s = orig_zs
tvcrs, 0
wdelete, new_w
!p.font = old_font
end
Part of