X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 10 Apr 2014 04:27 PM by  anon
Reading Hyperspectral image using ENVI and summing in IDL code
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
10 Apr 2014 04:27 PM
    Dear Users, I am trying to write and IDL code in which I read a few hyperspectral cubes with ENVI and sum over all pixels and bands in each cube. I used the following example: ENVI_OPEN_FILE, r_file, r_fid=fid ENVI_FILE_QUERY, fid, dims=dims data = ENVI_GET_DATA(fid=fid, dims=dims, pos=0) This gives me the first band image. By changing pos, I am getting the data in different bands. Then by using total(data), I am summing the values within that image. Is there a way to get the data for all bands at once? I am basically trying to calculate some kind of a mean value of the cube and some overall standard deviation. I appreciate your suggestions. Thanks, - NG

    Deleted User



    New Member


    Posts:
    New Member


    --
    14 Apr 2014 06:37 AM
    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

    Deleted User



    New Member


    Posts:
    New Member


    --
    14 Apr 2014 03:18 PM
    Josh, Thank you for the detailed explanations, which made few things more clear for me now. Best regards, - NG
    You are not authorized to post a reply.