comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » envi_get_data
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: envi_get_data [message #58369 is a reply to message #58273] Fri, 25 January 2008 09:18 Go to previous messageGo to previous message
peter.eddy@shaw.ca is currently offline  peter.eddy@shaw.ca
Messages: 19
Registered: March 2005
Junior Member
Hi,
Typical ENVI format files are "usually" band sequential:
Array=fltarr(ns, nl, nb) as its quickest to display.
You can obtain the interleave within the ENVI_FILE_QUERY with the
keyword Interleave=interleave where bsq=0, bil=1 and bip=2 - or by
looking at the header. Next I would check the datatype of your input
file. In your code you read in the file, query the datatype create a
new float array then write the file with the datatype of your input.
What if your input was byte or integer? Since you're output is float
you could hardcode the data_type=4 (or 5 for double).

For example you could do the following:

pro cal
envi, /restore_base_save_files
envi_init, /batch_mode
envi_open_file,'F:\testinput.img',r_fid=fid
if (fid eq -1) then return
envi_file_query, fid, ns=ns, nl=nl, nb=nb, data_type=data_type, $
interleave=interleave, dims=dims
;Could have an "if" statement to check and set the interleave
map_info = envi_get_map_info(fid = fid)
;dims = [-1L, 0, ns - 1, 0, nl - 1] **you can get the dimensions from
the query above
pos=lindgen(nb)
image=fltarr(ns, nl, nb) ; storage array for multi band processing
(loop over bands)
;image2=fltarr((nb,nl,ns) ** not required
For i=0, nb-1 Do Begin
;read band and convert to float
inBand = Float(envi_get_data (fid=fid,dims=dims,pos=i)) ;read the
2d array
image[*,*,i]=inBand* 0.8 + 100 ;do processing and store in
array
Endfor
ENVI_WRITE_ENVI_FILE,image,data_type=4,nb=nb,nl=nl,ns=ns,map _info=
map_info, $
out_name='F:\testoutput.img'
END

With this method you may run into memory problems, as you are reading
by entire bands and storing the whole image. When the image gets
larger you will have to look into ENVI's tiling routines.

Hopefully this gets you started,

Pete
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Beginner: Oplot line t^(-5/3)
Next Topic: Curve Fitting Question

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:33:57 PDT 2025

Total time taken to generate the page: 0.00449 seconds