X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 22 May 2013 12:01 AM by  anon
Maximum reflectance in spectra
 6 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
22 May 2013 12:01 AM
    Hi List, How do I the following?: From a number of multispectral bands, I wanted to produce 2 images: 1) showing the maximum reflectance value across the bands and 2) the band number where the maximum came from. I know that using Band Math expression 'max(b1,..,bn)' applies only to one band and it gets local maxima in the band image tile and not across the spectra for each pixel. I was expecting that Spectral Math 'max(s1)' and using the image as input variable would do the trick but ENVI returned an error saying: 'Error: "REFORM: New subscripts must not change the number of element in RESULT." The result may be valid. Any pointers, everyone?

    Deleted User



    New Member


    Posts:
    New Member


    --
    22 May 2013 07:34 AM
    I do not like this solution, but it is quite working. Example of band math expressions for images with 4 bands: Second image: ((b1 gt b2) and (b1 gt b3) and (b1 gt b4))*1+((b2 gt b1) and (b2 gt b3) and (b2 gt b4))*2+((b3 gt b1) and (b3 gt b2) and (b3 gt b4))*3+((b4 gt b1) and (b4 gt b2) and (b4 gt b3))*4+((b1 eq b2) and (b1 eq b3) and (b1 eq b4))*0 where b1, b2, b3, b4 - image bands First image: (b100 eq 1)*b1+(b100 eq 2)*b2+(b100 eq 3)*b3+(b100 eq 4)*b4+(b100 eq 0)*0 where b1, b2, b3, b4 - image bands, b100 - second image

    Deleted User



    New Member


    Posts:
    New Member


    --
    21 Feb 2017 08:13 PM
    I am also looking for an efficient way to do this. I need to classify each pixel by the band index with the highest value. I don't need to know exactly what that value is, just for each pixel, return a value that designates which of the 30 bands in the file has the largest value. I have begun writing out a spatial math formula along the lines suggested above ( and also trying a decision tree in the same vein to classify the image), but with 30 bands it is quite unwieldy. If anyone has a suggestion as to a more efficient way to to this, I'd appreciate it.

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    22 Feb 2017 05:53 AM
    You could try the code shown in this post: http://www.harrisgeospatial.com/Suppo...

    Deleted User



    New Member


    Posts:
    New Member


    --
    22 Feb 2017 06:52 AM
    Thanks, if I understand that code correctly, it returns a 2 band file with the maximum and minimum value for each pixel. I don't need to know what the max and minimum values are, I just need to know in which band the maximum value is found for each pixel. For example, for pixel (1,1) say I have 5 bands* with the values (0.21, 0.03, -0.56, 0.3, 0.64) I need to output a single band image or classification that has the value 5, for band 5, at pixel (1,1). (or a similar unique value that can be referred to band 5) an so on through the image *in reality I have 30 bands, which is why working with a (b1 bt b2) (b1 bt b3) etc etc spatial math equation or decision tree classification becomes unwieldy. Thanks

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    22 Feb 2017 07:53 AM
    It will still require that you find the maximum so you could add on to this code to do an additional check for which band index the maximum value is found and return that instead of the maximum.

    Deleted User



    New Member


    Posts:
    New Member


    --
    22 Feb 2017 08:41 AM
    Ah, I see the process you are recommending. I was hoping there was a way to do it with spatial math or a decision tree classification, a shortcut for (b1 gt b2) AND (b1 gt b3) AND..... something like (b1 gt [all other bands]) Can you use arrays in decision tree expressions? In my 5 band example above, could I use an array: b1 GT [b2, b3, b4, b5] which for pixel 1 would return NO but b5 GT [b1, b2, b3, b4,] would return YES? In the first example above, the OR statements all had to be separated, can they be nested in a decision tree? ie b1 GT (b2 OR b3 OR b4 OR b5) I'll try implementing these when I get to the processing computer, I cannot tell from help files alone if either one of these would work.
    You are not authorized to post a reply.