;------------------------------------------------------------- ;+ ; NAME: ; XHISTPICK ; PURPOSE: ; Widget routine to select image scaling based on a histogram. ; CATEGORY: ; CALLING SEQUENCE: ; xhistpick, xx, hh ; INPUTS: ; xx = Histogram bin positions. in ; hh = Histogram counts. in ; KEYWORD PARAMETERS: ; Keywords: ; MIN=mn Returned selected lower image value cutoff. ; MAX=mx Returned selected upper image value cutoff. ; If defined these values will also be used as initial ; values of the cutoffs. ; TITLE=txt Title text string or array. ; ERROR=err Error flag: 0=OK, 1=CANCEL ; CLIP=n Clip max histogram count to the n'th below the ; highest count. Good for ignoring spikes in histogram. ; /clip may work well, or try clip=2 or 3. ; IMAGE=img Image to display (def=none). If given, this ; image will be displayed in the specified window with ; the currently selected scaling limits. ; WINDOW=win Window for image display (def=0). Only ; needed if an image is given. ; /ON_FREEZE redisplay image every time a limit is frozen ; in a new position. Else a Redisplay button appears. ; /WAIT means wait for returned result. ; GROUP_LEADER=grp specified group leader. When the ; group leader widget is destroyed this widget is also. ; Any valid PLOT keywords will be passed on to PLOT. ; OUTPUTS: ; COMMON BLOCKS: ; NOTES: ; Notes: Histogram and bin position array may be made using ; hist. Ex: hh=hist(img,xx) ; xhistpick,xx,hh,image=img ; Try xx(2:0),hh(2:*) to drop a large count of image zeros ; and the bottom added bin. See h=hist(/help)). ; Image may be floating. ; MODIFICATION HISTORY: ; R. Sterner, 7 Dec, 1993 ; R. Sterner, 13 Dec, 1993 --- Added clip and _extra. ; ; Copyright (C) 1993, Johns Hopkins University/Applied Physics Laboratory ; This software may be used, copied, or redistributed as long as it is not ; sold and this copyright notice is reproduced on each copy made. This ; routine is provided as is without any express or implied warranties ; whatsoever. Other limitations apply as described in the file disclaimer.txt. ;- ;------------------------------------------------------------- pro xhistpick_event, ev widget_control, ev.id, get_uval=uval widget_control, ev.top, get_uval=d if uval eq 'OK' then begin if d.freeze lt 0 then begin widget_control, d.imgb, get_uval=img wset, d.win tvscl,img>d.v(0)!x.crange(0) ; Force left of max-xq. vline, /data, x, num=0 d.v(0) = x widget_control, d.tmn, set_val=strtrim(x,2) endif if d.status(1) eq 1 then begin ; Maximum active. d.status(0) = 0 ; Make sure Min is off. x = x>(d.v(0)+d.xq)d.v(0)xmin