Re: Help with code for hyperspectral image analysis [message #80372] |
Mon, 11 June 2012 09:43  |
Brian Daniel
Messages: 80 Registered: July 2009
|
Member |
|
|
Your problem is your call to ENVI_GET_DATA. POS has to be a scalar, so ENVI_GET_DATA returns only a single band at a time. You should loop through all the bands, apply your filter, then write the band to the output file using writeu. Then, call ENVI_SETUP_HEAD to write the header file.
-B
On Monday, June 11, 2012 10:59:55 AM UTC-4, Kel wrote:
> ;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
|
|
|
Re: Help with code for hyperspectral image analysis [message #80532 is a reply to message #80372] |
Wed, 20 June 2012 10:26  |
Kel
Messages: 7 Registered: June 2012
|
Junior Member |
|
|
Thanks for your reply! I'm sorry to say that I still don't understand, though.
Calling up a single band with ENVI_GET_DATA was intentional, because I wanted to make a single-band file showing ones for locations where that band was less than 40, and zeros for where it's greater than 40.
The part that I'm stuck on is how I apply that information to all pixels in my image. At each pixel, if the band value at 140 is greater than 40, I want all 156 bands zeroed out. If it's less than 40 at that one band, then it should be left alone.
Any further explanation you can give would be very appreciated!
On Monday, June 11, 2012 12:43:00 PM UTC-4, Brian J. Daniel wrote:
> Your problem is your call to ENVI_GET_DATA. POS has to be a scalar, so ENVI_GET_DATA returns only a single band at a time. You should loop through all the bands, apply your filter, then write the band to the output file using writeu. Then, call ENVI_SETUP_HEAD to write the header file.
>
> -B
>
> On Monday, June 11, 2012 10:59:55 AM UTC-4, Kel wrote:
>
>> ;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
|
|
|