Re: Problem reading multiband-ENVI file [message #54580] |
Sat, 23 June 2007 08:08 |
Jeff N.
Messages: 120 Registered: April 2005
|
Senior Member |
|
|
On Jun 22, 9:53 pm, "aleks.fra...@gmail.com" <aleks.fra...@gmail.com>
wrote:
> I have an Envi file with 6 bands and I need to take the bands apart in
> separate variables so that I can display them in my GUI routine.
> That's what I have:
>
> :: Starts here
> envi_select, title="WAVECHANGE: Select 'Initial State' Image",$
> fid=fid1, dims=dims1, pos=pos1
> if (fid1 eq -1) then return
>
> envi_file_query, fid1, fname=fname1, bname=bname1,$
> data_type=data_type1,$
> ns=ns1, nl=nl1, nb=nb1,$
> sname=sname1, xstart=xstart1, ystart=ystart1
>
> ;get number of slices
> n_slices = nb1
> img = BYTARR((dims1(2)+1),(dims1(4)+1),n_slices)
>
> ;for each slice in the selection
> for i = 0, n_slices-1 do begin
>
> ;get filename
> file = fname1
>
> ;create empty slice
> image = bytarr((dims1(2)+1),(dims1(4)+1))
>
> ;open file and fill in slice
> OpenR, lun, file, /Get_lun
> ReadU, lun, image
> Free_lun, lun
>
> ;store slice in volume
> img[*,*,i]=image
> endfor
>
> ;image = CONGRID(image, dims1(2)+1, dims1(4)+1)
> WINDOW, 3, XSIZE = dims1(2)+1 , YSIZE = dims1(4)+1
> image = bytscl(image)
> TV, image
>
> ;;Ends here
>
> This is not working with my envi file. I don't know if this is the
> right way to do it. I have no experience with envi files.
>
> Any help would be appreciated..
>
> thank you
>
> Aleksander
I see two potential problems. One, you can probably avoid the loop
where you read in a single slice of data that ultimately gets
assembled into the img variable (your loop looks wrong to me anyway).
Two, you're not dealing with the file's interleave.
I'd have a look at ENVI_GET_DATA. It's a pretty flexible routine for
getting data into memory. You can get the entire image cube or a
single band. The ENVI helpfile has an example of getting just the
first band of a file.
Another option is to use tiling routines if your data is too large to
fit into memory. They can be a bit overwhelming at first, but they
really aren't that bad.
Jeff
|
|
|