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

Home » Public Forums » archive » Help with code for hyperspectral image analysis
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: Help with code for hyperspectral image analysis [message #80530 is a reply to message #80374] Wed, 20 June 2012 12:55 Go to previous messageGo to previous message
Brian Daniel is currently offline  Brian Daniel
Messages: 80
Registered: July 2009
Member
See my adjustments to Klemen's code below. This way you don't have to load the entire image, masked or otherwise, into memory. Also, untested.

pro envi_masking_image

;select your image file

;Get your file
image=dialog_pickfile()

; Pick an output filename
output = dialog_pickfile()

;check to see if valid for ENVI
envi_open_file, image, r_fid=fid
IF fid[0] EQ -1 THEN Message,'Invalid file name: '+image

;learn about the image
ENVI_FILE_QUERY, fid, ns=ns, nl=nl, nb=nb, data_type=data_type,Interleave=interleave
help, data_type

;build array based on data type
;data_holder=Make_Array(ns, nb, nl, Type=data_type) ; memory intensive

;make a mask
f = ENVI_GET_DATA(fid=fid, dims=dims, pos=140)
indx = where(f LT 40, count)
f[indx] = 0 ; now f is your mask

;apply the mask to all bands and save
OpenW, lun, output, /Get_Lun
if count gt 0 then begin
for i=0,nl-1 do begin
data = ENVI_GET_DATA(fid=fid, dims=dims, pos=i)
writeu,lun,data*f

endfor
endif

; close binary file
close,lun
free_lun, lun

; write out an envi header file
envi_setup_head, Data_Type=data_type, /Open, R_FID=masked_fid, $
/WRITE, FNAME=output, Interleave=2 ; BIP

end
[Message index]
 
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: read irregular data
Next Topic: sun symbol

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

Current Time: Wed Oct 08 17:30:15 PDT 2025

Total time taken to generate the page: 0.00237 seconds