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
|