;------------------------------------------------------------------------------- FUNCTION IMSCALE, IMAGE, RANGE=RANGE, BOTTOM=BOTTOM, NCOLORS=NCOLORS, $ NEGATIVE=NEGATIVE ;- Byte-scale an image (called by IMDISP) ;- Check arguments if (n_params() ne 1) then message, 'Usage: RESULT = IMDISP_IMSCALE(IMAGE)' if (n_elements(image) eq 0) then message, 'Argument IMAGE is undefined' ;- Check keywords if (n_elements(range) eq 0) then begin min_value = min(image, max=max_value) range = [min_value, max_value] endif if (n_elements(bottom) eq 0) then bottom = 0B if (n_elements(ncolors) eq 0) then ncolors = !d.table_size - bottom ;- Compute the scaled image scaled = bytscl(image, min=range[0], max=range[1], top=(ncolors - 1)) ;- Create a negative image if required if keyword_set(negative) then scaled = byte(ncolors - 1) - scaled ;- Return the scaled image in the correct color range return, scaled + byte(bottom) END