X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 25 Oct 2012 07:57 AM by  anon
Bandmath (file math really) multiple equations to multiple bands in same file?
 3 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
25 Oct 2012 07:57 AM
    I have a group of hyperspectral scenes I'm trying to do a brightness temperature calcualtion on. So I have 256 bands of data in each image file, that I need to apply a band math equation to but that equation is different for every band (as it uses the band wavelength in it's calculation). The band math dialog is easy enough to apply a single equation to a bunch of bands in the same image file, but it doesn't seem like you can import an array of band math equations and then assign all the variables to each band without stepping through each equation seperately for every band of every image file, then getting 256 results in memory that have to be combined using "save as" is there an easy way to take an array of equations and apply or link them to them to multiple bands in the same envi file? Unfortunately I'm just not up to speed enough on IDL to write something from the ground up to do it, which might be the only good option. Thanks in advance, Todd

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    25 Oct 2012 08:05 AM
    There is no good way to do this directly in Band Math. You would have to apply the equation one band at a time, then save them back together into a single file. The better solution is to write a program using ENVI's MATH_DOIT on a file. There are some simple examples, but not exactly what you need, in this help article: http://www.exelisvis.com/.../ArticleId/3893.aspx The key will be to build the correct equation in a loop for each band. You might give the example code a try and if you run into difficulty, contact technical support directly.

    Deleted User



    New Member


    Posts:
    New Member


    --
    29 Oct 2012 04:37 PM
    Thanks for the help, I actually had been working without luck on that sample code but it turned out to be a conflict with IDL/ENVI working directories. So I've ran into another snag. The code works fine and does a brightness temp conversion to all the bands, but the wavelength header file information is lost in the translation from the orignal multi-band file, to the individual band math results using math_doit, to the stacked result using cf_doit. Essentially the code asks the user for a directory the files are in, queries the user for a unique string to identify the image files to work on, then uses a while loop with a file counter to step through and do the band math conversion on each band of each multiband file. envi_open_file and envi_query_file are used to get specifics on the file, a file of band math expressions and band wavelengths are opened and read into arrays. My main issue is that neither math_doit or cf_doit allow for appending the header file with wavelength info, all that can be modifed is band names, which is okay until you want to use the Z-profile, and you have only band numbers instead of wavelengths as an X axis. I tried using envi_setup_header to create a whole new header, but for some reason I get odd output, it's very banded horizontally, values are correct, and the text of the header files are identical. If I let ENVI create a header file when it builds the stacked image they are fine, but again no wavelength info. Is there a function that allows for simply appending the WL value to a header file that could be tucked into the loop? Thanks, Todd

    Deleted User



    New Member


    Posts:
    New Member


    --
    29 Oct 2012 04:54 PM
    Solved it! When envi was outputing the band math results they were in BSQ, instead of BIP as the orignal data was, so when I was writing a new header after the results were stacked I was using the wrong Interleave in the header. The really weird part is, if ENVI builds a stacked header by default, it lists the interleave as BIP in the header and the data looks fine, however when I'd create a new header using envi_setup_head with BIP it was giving bad output. Very odd.
    You are not authorized to post a reply.