Various kinds of images can be displayed in IDL. This list describes them:

  • Binary Images: Binary images contain only two values (off or on). The off value is usually 0 and the on value is usually 1. This type of image is commonly used as a multiplier to mask regions within another image.
  • Grayscale Images: Grayscale images represent intensities. Pixels range from least intense (black) to most intense (white). Pixel values usually range from 0 to 255 or are scaled to this range when displayed.
  • Indexed Images: Instead of intensities, a pixel value within an indexed image relates to a color value within a color lookup table. Since indexed images reference color tables composed of up to 256 colors, the data values of these images are usually scaled to range from 0 to 255.
  • RGB Images: Within the three-dimensional array of an RGB image, two of the dimensions specify the location of a pixel within an image. The other dimension specifies the color of each pixel. The color dimension always has a size of 3 and is composed of the red, green, and blue color bands (channels) of the image.

Pixel Values in Image Data


Pixel values in an image file can be stored in many different data types. The original data type of an image is reflected in IDL when importing the image, but you can convert the type once the image is stored in an IDL variable. The following types are commonly used for images:

  • Byte: An 8-bit unsigned integer ranging from 0 to 255. Pixels in images are commonly represented as byte data.
  • Unsigned Integer: A 16-bit unsigned integer ranging from 0 to 65535.
  • Signed Integer: A 16-bit signed integer ranging from -32,768 to +32,767.
  • Unsigned Longword Integer: A 32-bit unsigned integer ranging from 0 to approximately four billion.
  • Longword Integer: A 32-bit signed integer ranging in value from approximately minus two billion to plus two billion.
  • Floating-point: A 32-bit, single-precision, floating-point number ranging from -1038 to 1038, with approximately 6 or 7 decimal places of significance.
  • Double-precision: A 64-bit, double-precision, floating-point number ranging from -10308 to 10308 with approximately 14 decimal places of significance.

While pixel values are commonly stored in files as whole numbers, they are usually converted to floating-point or double-precision data types prior to performing numerical computations. See the examples section of REFORM for more information.

Use these IDL functions to convert data from one type to another:

  • BYTE: Convert to byte
  • BYTSCL: Scale data to range from 0 to 255 and then convert to byte
  • UINT: Convert to 16-bit unsigned integer
  • FIX: Convert to 16-bit integer, or optionally other type
  • ULONG: Convert to 32-bit unsigned integer
  • LONG: Convert to 32-bit integer
  • FLOAT: Convert to floating-point
  • DOUBLE: Convert to double-precision floating-point