USDA ARS

Format of Pixel Data in IPW Images

The pixels in an IPW image are floating-point values. These values usually represent physical quantities such as air temperature, precipitation, elevation, etc.

Pixels are stored as binary data in an IPW image file. Each band in an IPW image uses a fixed number of bits to store the pixels in that band. Different bands in an image may use different numbers of bits to store their respective pixels. For example, a 2-band image might use 8 bits to store the pixels in its first band (band 0) while using 12 bits to store the pixels in its second band (band 1).

The number of bits used to store a pixel determines the range of possible binary values:

    N      = number of bits used to store pixels in a band
    2N     = number of possible binary values
    0      = minimum binary value
    2N - 1 = maximum binary value
For example, if 8 bits are used to stored a band of pixels, then the set of possible binary values has 256 values ranging from 0 to 255.

Linear Quantization: storing floating-point pixels as binary values

The range of binary values used to store a band of pixels represents a range of floating-point values. For example, a band of pixels representing air temperatures in Celsuis might range from -40 C to 50 C.

Although the range of pixel values is finite, the set of possible pixel values is infinite because they are floating-point values. Using a finite set of binary values to represent this infinite set of pixel values is called quantization.

Logically, the minimum binary value (0) represents the minimum pixel value, while the maximum binary value (2N - 1) represents the maximum pixel value. Combining the previous two examples, if the pixels representing air temperatures from -40 C to 50 C are stored using 8 bits each, then the binary value 0 represents the pixel value -40 C, while the binary value 255 represents the pixel value 50 C.

To determine the binary value that represents any other floating-point pixel value other than the minimum and maximum values, this formula is used:

    b = round( (x - MINpix)/P )
where
    x      = floating-point pixel value
    b      = corresponding binary value
    MINpix = minimum floating-point pixel value
    P      = precision (see below)
    round  = function to round to nearest integer
Because this formula is a linear function, the representation of floating-point pixels as binary values in an IPW image is referred to as linear quantization.

Precision

Because of quantization, each floating-point pixel value does not have a unique corresponding binary value. However, each binary value does represent a unique floating-point pixel value. Because the quantization is linear, the difference between the floating-point pixel values for two adjacent binary values is the same regardless of which two binary values are considered. This fixed difference is known as the quantization's precision, and is calculated as follows:

    P = (MAXpix - MINpix) / (2N - 1)

Using the previous example where 8 bits are used to store pixel values for air temperatures ranging from -40 C to 50 C, the precision of this particular quantization is:

    P = (50 C - -40 C) / (28 - 1) = .353 C
      = .353 C
Therefore, each binary value in this particular quantization represents a step of .353 C in the range of corresponding pixel values. Using this precision, the function for computing binary values in this example becomes:
    b = round( (x - -40 C)/.353 C )
Hence, freezing (i.e., 0 C) is represented by the binary value 113.

Another way of looking at precision is to realize that any two floating-point pixel values that differ by more than the precision of a particular quantization will be represented by different binary values.

Mapping binary values to floating-point pixels

The formula to determine the floating-point pixel value represented by a particular binary value is simply the inverse of the function above:

    x = MINpix  +  b * P

    (Note:  The asterisk character "*" represents multiplication.)
Using the above example with 8-bit quantization for air temperatures, this function becomes:
    x = -40 C  +  b * .353 C
Hence, the binary value 78 represents the pixel value -12.47 C.

Linear quantization (LQ) headers

The parameters for linear quantization are stored in a band's LQ header. See the previous section of this user's guide for a general description of an IPW image header. The map datum lines in an LQ header specify the range of floating-point pixel values for the designated band:

     !<header> lq 0 $Revision: 1.4 $
     map = 0 0
     map = 255 56.78
In this example, the first datum line specifies that the binary value 0 maps into the pixel value 0, and the second datum line specifies that the binary value 255 maps into the pixel value 56.78; therefore, the pixel values in this image's first band (band 0) range from 0 to 56.78.


IPW documentation / Last revised 20 May 2009 / IPW web site