X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 23 Jan 2017 08:55 AM by  anon
masking pixels in multiple bands that match range of values
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



Basic Member


Posts:228
Basic Member


--
23 Jan 2017 08:55 AM
    I have a Landsat image with six bands stack stored into a single file (an array of three dimensions). I want to create a mask for those pixels if all bands match a value “zero”. I know how to do this in ENVI. MaskingàBuild maskà Options àImport Data Range then determine data range (min and max values) and select “Mask pixel if all bands match range”. Now can you tell me how I can translate this task in IDL? I have an array of (ns, nb, nb=6).

    Deleted User



    Basic Member


    Posts:228
    Basic Member


    --
    23 Jan 2017 01:25 PM
    To create an array that is like an ENVI mask image, containing binary pixel values of either 0 (masked) or 1 (not masked), based on whether each pixel falls inside a data range, you might use the IDL WHERE routine. WHERE returns the locations in an input array that meet the specified conditions. So you can first set up a blank output array that is the same size as your input array. In this case, it sounds like that would be (ns, nl, nb) in size. Then you can use the results of WHERE to define locations in that output image to set to 1. Everything else will stay with a value of zero. For example, say that image is a 5 x 5 x 3 integer array containing values between 0 and 200. And, say I want to make a mask for this array that shows values of 1 where the original pixels had values between 10 and 100. I could first make a blank mask array: mask=bytarr(ns, nl, nb) Then I could use WHERE like this: mask[where(image ge 10 AND image le 100)]=1 Now I have an array of the same size as the original array in all dimensions, but it has values of 1 where the original array had values between 10 and 100, and zero everywhere else. If I want to reduce this to a single band, which has values of 1 only where all bands had the right data range, I could multiply the bands together. The command could look like this: final_mask = mask[*,*,0]*mask[*,*,1]*mask[*,*,2] Or you might want to set this up as loop over the different bands in the mask array, since you'll be working with more bands than in my example. I hope this helps. Peg
    You are not authorized to post a reply.