A couple of options.
You could also return the number of bands from the envi_file_query, and construct an array large enough to hold the entire x,y,z image.
eg
ENVI_OPEN_FILE, r_file, r_fid=fid
ENVI_FILE_QUERY, fid, dims=dims, nb=nb, nl=nl, ns=ns
data = FLTARR(ns,nl,nb) ;Float32 might suffice, but you could go to double, DBLARR()
;Loop over the bands
FOR i=0, nb-1 DO BEGIN
data[*,*,i] = ENVI_GET_DATA(fid=fid, dims=dims, pos=i)
ENDFOR
Now just use TOTAL(data), STDDEV(data), MEAN(data) to return the sum, standard deviaiton and mean.
This approach would use a lot of memory.
Alternatively just read a single band at a time, and use recursive formula to calculate the mean and standard deviation.
Cheers
Josh
|