Re: Bits & Bytes [message #57895 is a reply to message #57894] |
Tue, 08 January 2008 04:40   |
wita
Messages: 43 Registered: January 2005
|
Member |
|
|
On Jan 8, 12:46 pm, j...@argentina.com wrote:
> Hello there...
> I'm sorry if my question is too basic. I'm working with 8 bits Spot
> Vegetation images. I have two bands:
>
> 1-NDVI data
> 2-Status Map (information about clouds, water, snow...)
>
> I need to apply the status map on the NDVI data, because I need to
> flag cloud and snow pixels.
>
> Below I have some information about the status map.
>
> From MSB to LSB
>
> Bit NR 7 (MSB): radiometric quality for B0 coded as 0 if bad and 1 if
> good
> Bit NR 6: radiometric quality for B2 coded as 0 if bad and 1 if good
> Bit NR 5: radiometric quality for B3 coded as 0 if bad and 1 if good
> Bit NR 4: radiometric quality for MIR coded as 0 if bad and 1 if good
> quality
> Bit NR 7 - 4: coded as 0 for 'no data', missing lines, sea on VGT-S
> products, adjacent blind or defective MIR detectors, interpolated
> data, saturated data, negative data after atmospheric correction
> Bit NR 3: land (code 1) or water (code 0), computed from the "Digital
> Chart of the Worlds"
> Bit NR 2: ice/snow (code 1) , code 0 if there is no ice/snow, computed
> from thresholds from reflectances
> Bit NR1: 0 0 1 1
> Bit NR0: 0 1 0 1
>
> (LSB): clear shadow uncertain cloud
>
> My question is: how can I use the status map to flag cloud and snow
> pixels? I'm reading them into ENVI, but I can't understand the byte
> numbers.
>
> Any comments very welcome.
> Best!
> Jurandir
Dear Jurandir,
You can easily convert a particular bitposition into a 0/1 mask
showing whether that bit was switched on or off using the following
function (this assumes bit nr from left to right, so binary value
10000000 = 128):
FUNCTION map_bitwise_flag, statusmap, bitposition
return, BYTE((statusmap AND (2^bitposition))/(2^bitposition))
END
You can easily test this:
d = byte(dist(250))
tvscl, d
r = map_bitwise_flag(d, 3)
tvscl, r
The simples way to apply such a function in ENVI is through the
bandmath option. So you first compile the module in ENVI, then in the
box labeled as "Enter an expression", you enter 'map_bitwise_flag(b1,
7)' in order to create a binary mask for the radiometric quality
status of B0. You then assign the statusmap to variable b1.
with best regards,
Allard
|
|
|