function getFileInfo, name envi_open_file, name, r_fid=id if id eq -1 then return, {errorstruct, name:name, ns:-1, nl:-1, nb:-1} envi_file_query, id, nb=nb, nl=nl, ns=ns, h_map=maph, descrip=desc, $ interleave=interleave, data_type=type if maph eq -1 then return, {errorstruct, name:name, ns:-1, nl:-1, nb:-1} handle_value, maph, map envi_file_mng, id=id, /remove return, {imagestruct, name:name, ns:ns, nl:nl, nb:nb, map:map, desc:desc, $ interleave:interleave, type:type} end function rescale, data, n_percent nbands = n_elements(data(0,0,*))-1 bmin = fltarr(nbands+1) bmax = fltarr(nbands+1) for band = 0, nbands do begin img = data(*,*,band) hist = histogram(img) bmin(band)=0 i=1 full = float(n_elements(where(img ne 0))) while bmin(band) lt n_percent do begin bmin(band)=bmin(band)+hist(i)/full i=i+1 endwhile bmin(band) = i-1 bmax(band)=0 i=255 while bmax(band) lt n_percent do begin bmax(band)=bmax(band)+hist(i)/full i=i-1 endwhile bmax(band) = i+1 ;; this doesn't actually rescale the image, but it allows tvscl to do a n_percent rescale index = where(img gt bmax(band)) if index(0) ne -1 then begin img(index) = byte(bmax(band)) print, 'reseting max for band ', band+1 endif index = where(img lt bmin(band)) if index(0) ne -1 then img(index) = byte(bmin(band)) img = img - bmin(band) data(*,*,band) = img endfor return, data end pro previewBSQ, greyscale=greyscale, sz=sz, tile=tile, pstrch=pstrch envistart screen=1600-sz if not keyword_set(pstrch) then pstrch=0.03 if not keyword_set(sz) then sz=1000 window, xsize=sz, ysize=sz shrinkfactor = 7.5 j=0 filelist = findfile('*.bsq') for i=0, n_elements(filelist)-1 do begin print, filelist(i) openr, un, filelist(i), /get info = getFileInfo(filelist(i)) data = bytarr(info.ns, info.nl, info.nb) readu, un, data ; data = congrid(data, fix(info.ns/shrinkfactor), ; fix(info.nl/shrinkfactor), info.nb) data = congrid(data, sz,sz,info.nb) if pstrch gt 0.01 then $ data = rescale(data, pstrch) if not keyword_set(greyscale) then begin if info.nb ge 3 then begin img = data img(*,*,0) = data(*,*,2) img(*,*,2) = data(*,*,0) tvscl,img, true=3, /order endif else $ tvscl, data, /order endif else begin for j=0, info.nb-1 do begin if pstrch lt 0.01 then begin print, pstrch tv, data[*,*,j],/order endif else tvscl, data[*,*,j], /order if keyword_set(tile) and j ne info.nb-1 then window, (i+1)*(j+1), $ xsize=sz, ysize=sz, xpos=((i+1)*(j+1)*(sz+10))mod screen, $ ypos=(((i+1)*(j+1)*sz)/screen)*(sz+15) & $ ; print, ((i+1)*(j+1)*sz)/screen, ((i+1)*(j+1)*sz), $ ; ((i+1)*(j+1)*sz) mod screen endfor endelse if keyword_set(tile) and i ne n_elements(filelist)-1 then $ window, (i+1)*(j+1),xsize=sz, ysize=sz endfor end