Contrast Stretching and Density Slicing - Lecture Material - Completely Remote Sensing tutorial, GPS, and GIS -
Contrast Stretching and Density Slicing

We move now to two of the most common image processing routines for improving scene quality. These routines fall into the descriptive category of Image Enhancement or Transformation. We used the first image enhancer, contrast stretching, on most of the Morro Bay TM images we have looked at so far in the previous 12 pages to enhance their pictorial quality . Different stretching options are described next, followed by a brief look at density slicing. We will then evaluate the other routine, filtering, shortly.

As we said on page 1-4, contrast stretching, which involves altering the distribution and range of DN values, is usually the first and commonly a vital step applied to image enhancement. Both casual viewers and experts normally conclude from direct observation that modifying the range of light and dark tones (gray levels) in a photo or a computer display is often the singlemost informative and revealing operation performed on the scene. When carried out in a photo darkroom during negative developing and positive printing, the process involves shifting the gamma (slope) or film transfer function of the plot of density versus exposure (H-D curve). This is done by changing one or more variables in the photographic process, such as the type of recording film, paper contrast, developer conditions, etc. Frequently the result is a sharper, more pleasing picture, but certain information may be lost through trade-offs, because some of the gray levels are "overdriven" into states that are too light or too dark.

Contrast stretching by computer processing of digital data (DNs) is a common operation, although we need some user skill in selecting specific techniques and parameters (range limits). The reassignment of DN values is based on the particular stretch algorithm chosen (see below). Values are accessed through a Look-Up Table (LUT).

The fundamental concepts that underlie how and why contrast stretching is carried out are summarized in this diagram:

The principles of contrast stretching.
From Lillesand & Kiefer, Remote Sensing and Image Interpretation, 4th Ed., 1999

In the top plot (a), the DN values range from 60 to 158 (out of the limit available of 0 to 255). But below 108 there are few pixels, so the effective range is 108-158. When displayed without any expansion (stretch), as shown in plot b, the range of gray levels is mostly confined to 40 DN values, and the resulting image is of low contrast - rather flat.

In plot c, a linear stretch involves moving the 60 value to 0 and the 158 DN to 255; all intermediate values are moved (stretched) proportionately. This is the standard linear stretch. But no accounting of the pixel frequency distribution, shown in the histogram, is made in this stretch, so that much of the gray level variation is applied to the scarce to absent pixels with low and high DNs, with the resulting image often not having the best contrast rendition. In d, pixel frequency is considered in assigning stretch values. The 108-158 DN range is given a broad stretch to 38 to 255 while the values from DN 107 to 60 are spread differently - this is the histogram-equalization stretch. In the bottom example, e (labeled 'special stretch'), some specific range, such as the infrequent values between 60 and 92, is independently stretched to bring out contrasty gray levels in those image areas that were not specially enhanced in the other stretch types.

Commonly, the distribution of DNs (gray levels) can be unimodal and may be Gaussian (distributed normally), although skewing is usual. Multimodal distributions (most frequently, bimodal but also polymodal) result if a scene contains two or more dominant classes with distinctly different (often narrow) ranges of reflectance. Upper and lower limits of brightness values typically lie within only a part (30 to 60%) of the total available range. The (few) values falling outside 1 or 2 standard deviations may usually be discarded (histogram trimming) without serious loss of prime data. This trimming allows the new, narrower limits to undergo expansion to the full scale (0-255 for Landsat data).

Linear expansion of DN's into the full scale (0-255) is a common option. Other stretching functions are available for special purposes. These are mostly nonlinear functions that affect the precise distribution of densities (on film) or gray levels (in a monitor image) in different ways, so that some experimentation may be required to optimize results. Commonly used special stretches include:1) Piecewise Linear, 2) Linear with Saturation 3) Logarithmic, 4) Exponential 5) Ramp Cumulative Distribution Function, 6) Probability Distribution Function, and 7) Sinusoidal Linear with Saturation.

Now, to apply these ideas to the Morro Bay TM bands. For Landsat data, the DN range for each band, in the entire scene or a large enough subscene, is calculated and displayed as a histogram (recall the histogram for TM Band 3 of Morro Bay on page 1-1; there is a frequency peak at about DN = 10 and most of the pixels fall between DN 0 and DN 60).

To illustrate contrast stretching (also called autoscaling) we utilize several IDRISI STRETCH functions to enhance Band 3. Recall that the histogram of raw TM values shows a narrow distribution that peaks at low DN values. We might predict from this that we have a dark, flat image. This is indeed the case:

The image resulting from an unstretched raw data display of TM Band 3 for Morro Bay. Only the waves are shown in contrasting tones.

When IDRISI's standard linear stretch program was applied, this somewhat improved image resulted.

Most of the DN values, however, lie between 9 and 65 (there are values up to 255 in the original scene but few of them). We can perform a selective linear stretch so that 9 goes to 5 and 65 goes to 255, with all values in between getting stretched proportionately. We show this expanded histogram, and the resulting new image below it.

 Histogram of Band 3 data after a linear stretch was applied. TM Band 3 image of Morro Bay after a linear stretch.

Now, most of the scene features are discriminable. But the image still is rather dark. Let's try instead to choose new limits in which we take DNs between 5 and 45 and expand these to 0 to 255. The procedure is like (special) case e in the diagram near the top of this page. This stretch results in the following histogram and image:

In this histogram, the values in the original (raw) Band 3 histogram that fell mostly between DN 5 to 45 have been expanded from 0 to 255. Values less than 5 have been discarded.The resulting cropped linear stretch image of Band 3 is now notably lighter in overall tone.

The histogram for this image is polymodal, with a lower limit near 25 and a large number of DN pixels at or near 255. This accounts for the greater scene brightness (light tones).

Next we try a Linear-with-Saturation stretch. Here we assign the 5% of pixels at each end (tail) of the histogram to single values. The consequent histogram and image are:

In the linear with saturation mode of stretch all DN values at the lowest and highest 5% intervals are lumped into single values, so that there are peaks at either end of the histogram.Band 3 image made by a linear with saturation stretch.

The image appears as a normal and pleasing one, not much different from the others. But, comparing this one with either of the linear-stretched versions shows that real and informative differences did ensue.

Histogram Equalization is a stretch that favorably expands some parts of the DN range at the expense of others by dividing the histogram into classes containing equal numbers of pixels. For instance, if most of the radiance variation occurs in the lower range of brightness, those DN values may be selectively extended in greater proportion to higher (brighter) values. Here, we carry out a Histogram Equalization stretch, with these results:

Shown here is the effect of a histogram equalization stretch in which the DNs are reassigned  values as a function of their frequency of occurrence, such that the value range that is dominant is stretched out over a larger spread of DNs; this affects the less common values beyond this range by combining them into several single values.Band 3 displayed after a histogram equalization stretch. Often, this gives the best balance of gray levels or tonal contrast.

The image is similar to the Saturation version. Note that pixel frequencies are spread apart at low DN levels and (closely-spaced) at high intervals.

In the Introduction it was stated that the human eye can see and distinguish between thousands of differing colors whereas only about 20 or so successive levels of gray are discernible. Applying colors to stretched images can be a big aid in picking up differences that may relate to actual features or classes in the scene. Consider these three images (of an area not in the Morro Bay scene):

Landsat Band 3 image Stretch of Band 3 image

The left image is an unstretched Band 3 image; the right is a simple stretch. The stretch version is obviously easier for picking out differences in gray levels that seem to some degree representative of different ground classes. Now look at the scene when levels have been assigned different colors (red, green, blue, yellow):

Gray tones assigned different colors.

Let us reiterate. Probably no other image processing procedure or function can yield as much new information or aid the eye in visual interpretation as effectively as stretching. It is the first step, and most useful function, to apply to raw or preprocessed data.

1-12: Comments have been made above about the relative quality and information content of each of the stretches displayed. In your opinion, which seems best and is most pleasing to the eye. ANSWER

The last (colorized) image is related to another enhancement procedure. This is based on combining ("lumping together") DNs of different values within a specified range or interval into a single value. This density slice (also called "level slice") method works best on single band images. It is especially useful when a given surface feature has a unique and generally narrow set of DN values. The new single value is assigned to some gray level (density) for display in a photo or on the computer monitor (or in an alphanumeric character printout). However, for an image with a range of DNs, these will be subdivided into a series of single values or gray level slices. To illustrate: suppose the range of the predominant DNs is 30 to 150; every 5 successive DNs are combined into a single value; this produces 150 - 30 = 120 divided by 5 = 24 single value increments. All other DNs can be assigned another level, usually black. This yields a simple map of the distribution of the combined DNs. The new sets of slices are commonly assigned different colors in a photo or display.

Version 2.0 of IDRISI FOR WINDOWS unfortunately does not have a simple density slicing routine, so the Morro Bay scene cannot be used here to illustrate this type of enhancement. We will instead take examples from different (Internet) sources.

We saw several black and white level slices in the subsection of the Introduction covering Medical Remote Sensing. As a reminder, here is a density slice image made from a Magnetic Resonance Imaging scan of a human head, showing primarily variations in brain tissue:

Density slice through a human head.

Color-coded density slicing is commonplace in medical studies. One example would be selective color staining of organic tissue. Or, an image made by a scanner can be processed to bring out certain features recognizable as having distinctive tones, to which one or more colors are assigned:

Density sliced image of tissue, with certain characteristics displayed in red.

Examples of density- sliced and color-assigned images from satellites are scattered throughout the Tutorial. Here are gray level slices representing temperature variations that are colored to indicate thermal differences in the U.S. Great Lakes (AVHRR data set):

Color slices showing variations in surface temperatures within the Great Lakes.

If classes or features within an image have gray tones that are narrow and distinct (not associated with other classes), the density sliced rendition can serve as a "quick and dirty" classification. These sliced subscenes are from a MSS Band 6 (vegetation bright) image acquired in July 1975 over Harrisburg, PA (the subject of the Exam found at the end of this Section):

Density sliced images of an area that includes Harrisburg, PA.

The upper map has four levels or slices. The lavender tends to demarcate a gray level (DN 43 to 48) that associates with urban areas. The lower map (pixels enlarged) covers part of the northern reaches of Harrisburg (the bridge is Interstate 81). Six gray levels (each representing a DN range) have been colorized as follows: Black = (DN) 0-19; Blue = 20-34; Red = 35-44; White = 45-54; Brown = 55-69; Green = 70+. The black pattern is almost entirely tied to water; the blue denotes heavily built up areas; the green marks vegetation; the other colors indicate varying degrees of suburbanization and probably some open areas.

However, one must be wary of accepting a density-sliced image as a bonafide classification map. In any band, the DNs and their corresponding image gray levels can include contributions from several classes to a limited range. But, if one class with a particular level dominates, the density slice rendition is a reasonable "first cut" at specifying its distribution.