X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 10 Oct 2012 03:40 PM by  anon
Replace negative and zero values for all bands in image
 8 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
10 Oct 2012 03:40 PM
    Hi, I would like to replace all negative AND zero values with another value in an image with four bands. I attempted file math using the following expression: ((b1 le 0) * (-999)) + ((b1 gt 0) * b1). The above expression worked fine on replacing negative values with -999; however, in band 4 I am still seeing some zero values with multiple occurrences. These pixels should be -999 also. Obviously, I am missing or misunderstanding something about expressions and band/file math. Can anyone point me in the right direction? Thank you, Jamie McBeth, USGS

    Deleted User



    New Member


    Posts:
    New Member


    --
    11 Oct 2012 07:11 AM
    I think the problem is that (-999 * 0) = 0. You will want to use a different expression for the pixels that start out with values of 0. You might want to try something like: ((b1 eq 0) -999) - Peg Exelis VIS Tech Support

    Deleted User



    New Member


    Posts:
    New Member


    --
    15 Oct 2012 10:08 AM
    Hi Peg, This makes sense except... Based on what I read in the Help, I was thinking any pixel that is "true" would be 1 and then 1 would be multiplied by the replacement value (--999 in my example). In my example, under the first half of the expression--((b1 le 0) * (-999))--any pixel with a zero value is "true" and would be 1*(-999) as opposed to 0*(-999). Am I misunderstanding? Jamie

    Deleted User



    New Member


    Posts:
    New Member


    --
    15 Oct 2012 12:15 PM
    Ah, you are right. So, then, I think your original expression should do what you were hoping. How are you determining that there are still zero values? Are you using Cursor Location/Value to point to pixels, and finding that some of them report values of zero? Or are you doing it some other way. - Peg

    Deleted User



    New Member


    Posts:
    New Member


    --
    15 Oct 2012 01:47 PM
    Hi Jamie, You might also consider creating a mask based on the range of values that you'd like to reassign. In the masking process you can choose the value that you'd like to assign to the masked areas.

    Deleted User



    New Member


    Posts:
    New Member


    --
    16 Oct 2012 09:48 AM
    Thanks Peg and Crystal. I found in Help that masking would be a way to achieve the same thing. I am just trying to learn the band math method, too. My comment on having zero values comes from running QuickStats on the image. I am seeing a lot of negative values with no occurrences (no Npts), which is good; however, the value zero has a number of occurrences (Npts). (If you explain how to insert or attach a graphic I can send you a screen cap of what I am seeing.) Jamie

    Deleted User



    New Member


    Posts:
    New Member


    --
    16 Oct 2012 11:00 AM
    I'm guessing that the problem is in the binning of the histogram values in your stats report. When calculating histogram stats, ENVI bins the results into a set number of bins. If the natural range of data values does not divide into one pixel value per bin, then you would have a bin that would include pixel values of 0, if there were any, and also other pixel values. The DN shown in the stats result for that bin might be 0, while the actual pixel values that fall into that bin could include 0 and other pixel values. I'm guessing that's what you saw. - Peg

    Deleted User



    New Member


    Posts:
    New Member


    --
    16 Oct 2012 11:35 AM
    You are right! This is what I am seeing. What is the quickest/easiest way to confirm that I have no zero pixels (and, therefore, confirm that the expression worked)?

    Deleted User



    New Member


    Posts:
    New Member


    --
    17 Oct 2012 08:46 AM
    There are lots of ways to do this. Personally, I usually use the Density Slice tool (in classic ENVI, from the display menu, choose Tools > Color Mapping > Density Slice. In ENVI 5, display your data, then right click on the layer, and choose Raster Color Slices. I then delete the default slices, and set up one that includes only pixels with values of 0. - Peg Exelis VIS Tech Support
    You are not authorized to post a reply.