ENVI's algorithm is more complex than what I show here, but you are on the right track when you wonder whether the histogram is involved. The image processing is some variation of IDL's HIST_EQUAL. The following code steps will not give you the exact result of ENVI, but it is close:
; My 'enviImg' image is an export to IDL of the 3 bands of ENVI example
; data 'cup95eff.init' which are displayed by default.
help, enviImg
;ENVIIMG INT = Array[400, 350, 3]
window, /FREE, XSIZE=400, YSIZE=350
tvscl, enviImg, TRUE=3 ; bytescale but no stretch produces low contrast
stretchedImg = bytarr(400,350,3)
; A 2% linear sctretch of an RGB image done with HIST_EQUAL
for i = 0, 2 do stretchedImg[*,*,i] = hist_equal(enviImg[*,*,i], PERCENT=2)
WINDOW, /FREE, XSIZE=400, YSIZE=350
tv, stretchedImg, TRUE=3, /ORDER
James Jones
|