;+ ; NAME: ; GAMMA_RAISE ; ; PURPOSE: ; Apply gamma correction to an array, presumably an image. ; ; CATEGORY: ; Image Processing. ; ; CALLING SEQUENCE: ; newImage = GAMMA_RAISE(image, Gamma) ; ; INPUTS: ; Gamma: The value of gamma correction. A value of 1.0 indicates a ; linear ramp, i.e., no gamma correction. Higher values of ; gamma give more contrast. Values less than 1.0 yield lower ; contrast. ; ; KEYWORD PARAMETERS: ; ; OUTPUTS: ; A gamma-corrected image. ; ; RESTRICTIONS: ; None. ; ; PROCEDURE: ; The gamma correction is implemented as x^gamma. ; ; MODIFICATION HISTORY: ; Written 14-Jul-2008 by Bill Davis ;- function gamma_raise, image, gamma, verbose=verbose if n_elements(gamma) le 0 then gamma = 1.0 if n_elements(verbose) le 0 then verbose = 0 type = SIZE( image, /type ) if verbose then minmax, image oldMax = MAX( image, MIN=oldMin ) newData = float( image) ^gamma if verbose then minmax, newData newMax = MAX( newData, MIN=newMin) newData = (newData-newMin)*(oldMax-oldMin)/(newMax-newMin) + oldMin if verbose then minmax, newData if type eq 3 then newdata = LONG( ROUND(newData) ) $ else if type eq 2 then newdata = fix( ROUND(newData) ) $ else if type eq 1 then newdata = byte( ROUND(newData) ) return, newData end