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 #80529 is a reply to message #80374] Wed, 20 June 2012 12:59 Go to previous messageGo to previous message
Kel is currently offline  Kel
Messages: 7
Registered: June 2012
Junior Member
Thanks you both so much! I had just gotten an out-of-memory error on Klemen's code, which seemed to be going ok up until that point, so I will try this modification now and hope it helps.

On Wednesday, June 20, 2012 3:55:08 PM UTC-4, Brian J. Daniel wrote:
> 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: Sat Oct 11 10:26:46 PDT 2025

Total time taken to generate the page: 1.75855 seconds