FUNCTION IMSCALE, IMAGE, RANGE=RANGE, BOTTOM=BOTTOM, NCOLORS=NCOLORS, $ NEGATIVE=NEGATIVE, SQUARE_ROOT=SQUARE_ROOT ;- 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 linear 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 ;- Apply square root enhancement if required if keyword_set(square_root) then begin table = byte(round(sqrt(lindgen(ncolors + 1L))/sqrt(ncolors) * ncolors)) scaled = table[scaled] endif ;- Return the scaled image in the correct color range return, scaled + byte(bottom) END