;------------------------------------------------------------- ;+ ; NAME: ; AUTOSCALE ; PURPOSE: ; Autoscale given image as previously specified. ; CATEGORY: ; CALLING SEQUENCE: ; out = autoscale(img) ; INPUTS: ; img = image to scale. in ; KEYWORD PARAMETERS: ; Keywords: ; /SETUP displays image and allows sub-area selection. ; Sub-area used to find scaling for autoscaled images. ; Histogram scaling parameters may be set during /SETUP. ; Ex: x = autoscale(img, /SETUP) ; MEM=n selects parameter set for autoscaling (def=1). ; Ex: tv, autoscale(img, mem=2). Must do /SETUP before ; autoscaling. ; SAVE=file saves image scaling memory in the given file. ; RESTORE=file restores image scaling from the given file. ; OUTPUTS: ; out = scaled image (byte, 0 to 255). out ; COMMON BLOCKS: ; autoscale_com ; NOTES: ; MODIFICATION HISTORY: ; R. Sterner, 16 Nov, 1989 ; ; Copyright (C) 1989, 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. ;- ;------------------------------------------------------------- function autoscale, img, setup=set, memory=mem, $ save=sav, restore=res, help=hlp common autoscale_com, flag, mlox, mhix, mloy, mhiy, mloh, mhih if keyword_set(hlp) then begin print,' Autoscale given image as previously specified.' print,' out = autoscale(img)' print,' img = image to scale. in' print,' out = scaled image (byte, 0 to 255). out' print,' Keywords:' print,' /SETUP displays image and allows sub-area selection.' print,' Sub-area used to find scaling for autoscaled images.' print,' Histogram scaling parameters may be set during /SETUP.' print,' Ex: x = autoscale(img, /SETUP)' print,' MEM=n selects parameter set for autoscaling (def=1).' print,' Ex: tv, autoscale(img, mem=2). Must do /SETUP before' print,' autoscaling. print,' SAVE=file saves image scaling memory in the given file.' print,' RESTORE=file restores image scaling from the given file.' return, -1 endif if keyword_set(sav) then begin save2, sav, flag, mlox, mhix, mloy, mhiy, mloh, mhih print,' Image scaling memory saved in file '+sav endif if keyword_set(res) then begin restore2, res, flag, mlox, mhix, mloy, mhiy, mloh, mhih print,' Image scaling memory restored from file '+res endif if n_params(0) lt 1 then return, -1 if n_elements(mlox) eq 0 then mlox = intarr(10) if n_elements(mhix) eq 0 then mhix = intarr(10) if n_elements(mloy) eq 0 then mloy = intarr(10) if n_elements(mhiy) eq 0 then mhiy = intarr(10) if n_elements(mloh) eq 0 then mloh = fltarr(10) + 1. if n_elements(mhih) eq 0 then mhih = fltarr(10) + 1. ;--------- autoscale ----------------- if not keyword_set(set) then begin if n_elements(flag) eq 0 then begin print,' Must first do /SETUP.' return, -1 endif if flag ne 1 then begin print,' Must first do /SETUP.' return, -1 endif if not keyword_set(mem) then mem = 1 lox = mlox((mem-1)>0<9) hix = mhix((mem-1)>0<9) loy = mloy((mem-1)>0<9) hiy = mhiy((mem-1)>0<9) loh = mloh((mem-1)>0<9) hih = mhih((mem-1)>0<9) sz = size(img) hix = hix