Go to the USGS Home Page

USGS MIPS Stretch Documentation






This program is used to apply various types of contrast stretch s or DN  remapping transformations to a digital image . The "stretching" or remapping is done using input dn versus output dn stretch pairs  in the format INPUT;OUTPUT. A stretch pair is one of the input and output DN combinations. For example, consider the following four stretch pairs:

INPUT;OUTPUT
0;0
10;0
100;255
255;255
The first two pairs, 0;0 and 10;0, will map all input DN values from 0 to 10 to a single output DN value of 0. Then the two pairs 10;0 and 100;255 will map the input DN values from 10-100 linearly to between the output values of 0 to 255 using the following equation:

   
            (255 -  0)
output dn = ---------- + (input dn - 100) + 255
            (100 - 10)
The general equation for any two pairs (i1,o1) and (i2,o2) is:

   
            (o2 - o1)
output dn = --------- + (input dn - i2) + o2
            (i2 - i1)
The restrictions on an input DN value for a stretch pair is that it is greater than the input DN value of the previous stretch pair and that it is within the valid range of dn values for the type of input data(e.g, 0 to 255 for unsigned 8-bit  data and -32768 to 32767 for signed 16-bit , etc). The only restriction on the output DN value is that it must be within the valid range of values for the type of output data. Note that the input and output DN values do not have to be of the same type, so conversion of images to a different type can be achieved. For example, given a signed 16-bit image with DN values from -500 to 9000, it could be converted to an unsigned 8-bit data type using the following stretch pairs:

-500;0
9000;255
If the extremes for the input data type are not entered on a stretch pair they are automatically mapped to the extremes of the output type. Thus the complete stretch pair parameters used for the example above are actually:

INPUT;OUTPUT
-32768;0
-500;0
9000;255
32767;255
The number of stretch pairs is limited to 128. Therefore, both piecewise and non-linear stretching transformations can be applied using this program.

  

Files

This program accepts as input an unsigned 8-bit, signed 16-bit, or 32-bit  floating point image file. If an output file is specified the program will generate an output image with a data type specified by the user. If an output file is not entered then a stretch file will be added to the image. The following information is automatically transferred from the input image label file to the output image label file(if appropriate):

Image labels 
Mosaic labels
Projection labels
Sonar labels
Navigation  file
History  file
      

Parameters

UBYTE, SWORD or FLOAT

These options are used to select the data type of the output image file to be created. The default data type is equal to that of the input image data type(i.e., 8-bit in and 8-bit out). However, the data type can be changed(e.g., 8-bit to 16-bit; 8-bit to 32-bit; 16-bit to 8-bit).

STRETCH

This parameter is used to define the stretch pairs. The stretch pairs must be separated by spaces and the DN values separated by a semi-colon(i.e., INPUT1;OUTPUT1 INPUT2;OUTPUT2 etc). For example, 0;0 10;0 100;255 255;255.

TITLE

This parameter is used to add a title to the stretch print file for the given stretch pairs. It is used if the output image generation option is not selected, so that the only output generated by the program is a print file containing the full input and output dn values stretch transformation for the given stretch pairs.

Uses

A major use of this program is to increase the brightness/contrast of an image. Because imaging sensor have to record radiance values covering a very wide dynamic range, no one image will make use of all the DN values available(e.g., 0 for black to 255 for white/maximum brightness). Therefore, to maximize the contrast and improve the visual image information the given DN range of an image must be "stretched" over the available range of the hardcopy or image display device. For example, an image may be too dark to see any information when it is viewed because the DN range is too low (e.g., less than 50 in a 0 to 255 range) or the image could be too bright and does not contain any dark values. The visual appearance of the image can be improved by applying a contrast stretch. Note, for an overall image contrast stretch the program PICSTR can be used to automatically select the stretch parameters needed for this program.

Examples

From left to right, original Landsat MSS Band 6, same image with contrast stretch applied using stretch pairs selected by the the program PICSTR, a linear stretch to highlight dark dn values, and a linear stretch to lightlight bright dn values.

[Example Image] [Example Image] [Example Image] [Example Image]



From left to right, contrast stretched Landsat MSS Band 6 and a negative of the same image using the stretch "0;255 255;0" applied.

[Example Image] [Example Image]

See Also

Applystr 
Gauss 
Histeq 
Picstr 
Decstr 
Autostr 
Colorcode 
U.S. Department of the Interior | U.S. Geological Survey | Jobs
Home | Search | Disclaimers & Privacy Web Rings
Send comments to webman@TerraWeb.wr.usgs.gov
URL:
Last Modified: Thu Oct 31 15:08:22 MST 2002
FirstGov: Your First Click to the U.S. Gov ernment