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
Help with code for hyperspectral image analysis [message #80374] Mon, 11 June 2012 07:59 Go to previous message
Kel is currently offline  Kel
Messages: 7
Registered: June 2012
Junior Member
I have BIL image data of an estuary with 1674 lines, 1302 samples, and 156 bands. I need to mask everything that is land, which is easily identified by its high reflectance values in certain bands - I use band 140 to identify it in my code.

Here's the code that I've worked up, and it does indeed write an ENVI file, but it's reduced to a single band instead of having all 156 in the unmasked areas. How do I get my output file to have all 156 bands??

Parts of this code were written by someone else, so just because I did something once in this code that doesn't mean that I understand it or could apply the concept again!

Thank you so much!
-K


pro envi_masking_image

;select your image file

;Get your file
image=dialog_pickfile()

;check to see if valid for ENVI
envi_open_file, image, r_fid=fid

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

;build array based on data type
data_holder=intarr(ns, nb, nl)
help, data_holder

;open a new file for reading as IDL file unit number 1
openr, 1, image

;write the data in my image file to the file 'data_array'
readu, 1, data_holder
close, 1

;create the mask
;locate the place that you want data from.
;-1 is just because, then the next two numbers specify the first sample, last sample, first line, and last line
;that you will read from. Envi starts with 0, so to read the whole image read from 0 to ns-1 and nl-1.
dims = [-1, 0, ns-1, 0, nl-1]

;get data from the image, pos seems to indicate which band to get data from
f = ENVI_GET_DATA(fid=fid, dims=dims, pos=140)

lcmask = f LT 40


;apply the mask to the image array

masked_image=convol(data_holder, lcmask)

;write out the result as an envi file
envi_write_envi_file, masked_image, out_name='masktest'


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 13:33:38 PDT 2025

Total time taken to generate the page: 0.00453 seconds