# Stretch function

The Stretch function enhances an image by changing properties such as brightness, contrast, and gamma through multiple stretch types.

The Stretch function uses the statistics from the rasters within the mosaic dataset. Therefore, if you use this function, you must make sure statistics have been calculated.

The inputs for this function are the following:

• Input raster
• Stretch type
• Output minimum and maximum
• Percent clip minimum and maximum
• Standard deviation n value
• Gamma
• Statistics, Estimate Statistics, Dynamic Range Adjustment

## Stretch types

The stretch type defines a histogram stretch that will be applied to the rasters to enhance their appearance. The stretch types include Minimum-Maximum, Standard Deviation, Percent Clip, and None. Stretching improves the appearance of the data by spreading the pixel values along a histogram from the minimum and maximum values defined by their bit depth. For example, an 8-bit raster dataset or mosaic dataset will be stretched from 0 to 255. Different stretches will produce different results in the raster display.

Below shows an example of a stretch: Histogram A represents the pixel values in image A. By stretching the values (shown in histogram B) across the entire range, you can alter and visually enhance the appearance of the image (image B).

### Minimum-Maximum

This stretch type applies a linear stretch based on the output minimum and output maximum pixel values, which are used as the endpoints for the histogram. For example, in an 8-bit dataset, the minimum and maximum values could be 33 and 206. A linear stretch is used to distribute the values across 256 values, from 0 to 255. Features in the imagery are easier to distinguish as the pixel values are distributed across the entire histogram range, brightening and increasing the contrast of the image.

### Standard Deviation or Percent Clip

In many cases, you can assume that the majority of the pixel values fall within an upper and lower limit. Therefore, it's reasonable to trim off the extreme values. You can do this statistically by defining either a standard deviation or clipping percent. The Standard Deviation stretch type applies a linear stretch between the values defined by the standard deviation (n) value. The Percent Clip stretch type applies a linear stretch between the percent clip minimum and percent clip maximum pixel values defined.

When you use either of these stretch types, all the values in the histogram falling outside the values defined will be pushed to the ends. For example: Your histogram has the same range of values as above, 33 to 206, and you've defined a percent clip minimum and maximum of 2. If 2 percent at the low end is values 33 to 45 and 2 percent at the high end is 198 to 206, the histogram will be redistributed to spread the values from 0 to 255, all values 33 to 45 becoming 0 and 198 to 206 becoming 255, with all others spread in between. Similarly, if you define a 2 standard deviation, then the values beyond the 2nd standard deviation become 0 or 255 and the remaining values are stretch in between 0 to 255.

### None

If the stretch type is None, no stretch method will be applied, even if statistics exist.

## Gamma

Gamma refers to the degree of contrast between the midlevel gray values of a raster dataset. Gamma does not affect the black or white values in a raster dataset, only the middle values. By applying a gamma correction, you can control the overall brightness of a raster dataset. Additionally, gamma changes not only the brightness but also the ratios of red to green to blue.

Gamma values lower than one decrease the contrast in the darker areas and increase the contrast in the lighter areas. This darkens the image without saturating the dark or light areas of the image. This helps bring out details in lighter features, such as building tops. Conversely, gamma values greater than one increase the contrast in darker areas, such as shadows from buildings. Gamma values greater than one can also help bring out details in lower elevation areas when working with elevation data.

In the example below, you can see the effect of adjusting the gamma values used to display a raster dataset.

## Statistics, Estimate Statistics, Dynamic Range Adjustment

You can enter your own statistics in the Statistics section of the dialog box. By default, the statistics are retrieved from the data; however, any values you enter in this parameter will be used instead.

If Estimate Statistics is checked, then the statistics are calculated from a 1000 x 1000 sampling from the center of the raster and used by the stretch. If this is checked and the raster has statistics or you've entered values in the Statistics table, they will be used instead of estimating, unless the stretch requires a histogram. If the stretch requires a histogram that doesn't exist, then it will be estimated.

If Dynamic Range Adjustment is checked, the statistics are calculated from output image and used by the stretch. This option is generally applied when the image will be published and used in a web Application that cannot perform this type of stretch.

9/10/2014