0% found this document useful (0 votes)
42 views11 pages

Contrast Enhancement

Contrast enhancement

Uploaded by

bkani14
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views11 pages

Contrast Enhancement

Contrast enhancement

Uploaded by

bkani14
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

CONTRAST ENHANCEMENT

(Unit: II)
Semester: I
Paper Code: GIS 04
Name of Paper: Digital Image Processing
PG Diploma in RS & GIS
Dr. SHYAMA PRASAD MUKHERJEE UNIVERSITY, RANCHI
CONTRAST ENHANCEMENT
1. Introduction
Image enhancement is used to enhance the information available from an image for any specific
purpose. The enhancement may be done either in the spatial domain or in the frequency
domain. The frequency domain enhancement is based on the modification of the Fourier
transformation of the original image. On the other hand, spatial domain enhancement involves
manipulation of the pixels in an image from the image plane itself.

This module we will learn the basics of image enhancement in the spatial domain.
2. Contrast stretching
Contrast stretching is used to increase the dynamic range of the gray levels in the image. For
example, in an 8-bit system the image display can show a maximum of 256 gray levels. If the
number of gray levels in the recorded image spread over a lesser range, the images can be
enhanced by expanding the number of gray levels to a wider range. This process is called
contrast stretching. The resulting image displays enhanced contrast between the features of
interests. For example, Fig. 1(a) shows the unstretched Landsat TM Band-5 image. The original
image is vague. Fig. 1 (b) shows the contrast-stretched image.

Fig. 1 Landsat TM Band-5 image before and after the contrast stretching
1
The transformation functions used to convert the values of the original image into
corresponding values in the output image may be linear or non-linear functions.

3. Linear Contrast Stretching


When the values in the original image are expanded uniformly to fill the total range of
the output device, the transformation is called linear contrast stretching. If DN is the
Digital Number of the pixel, DNst is the corresponding DN in the enhanced output image,
DNmax and DNmin are the maximum and minimum DN values in the original image, the
linear contrast stretching can be graphically represented as shown below.

Fig. 2. Graphical representation of the linear contrast stretching function

For example, for an 8-bit display system, linear contrast stretching transformation can be
achieved as given below.

(1)
where DN values in the range DNmin-DNmax are rescaled to the range 0-255 in the output
image. Fig. 3(a) shows histogram of the Landsat TM band-5 image, wherein the DN values
range from 60 to 158. Therefore in the display of the original image, display in the ranges 0-
59 and 159-255 are not utilized, giving a low contrast image as shown in Fig. 1(a). Histogram
of the enhanced image is shown in Fig. 3(b), wherein the values are expanded to fill the entire
range -255, giving better contrast. The enhanced output image is shown in Fig. 1(b).
2
Fig. 3 Histograms of the Landsat TM Band-5 image before and after contrast stretching

In the contrast stretched image the light tone areas appear lighter and the dark tone areas
appear darker. The variation in the input data, now being displayed in a wider range, thus
becomes easily differentiable.

From the histogram of the original image it can be observed that though the DN values ranges
from 60 to 158, number of pixels having DN values in the range 60-90 are very less.
Nevertheless, in linear stretching equal number of display levels are assigned to these ranges.
Consequently, for the higher values not many display levels are available. In other words,
the number of display levels available for different DN ranges are not in proportion to
the number of pixels having DN values in the range. To solve this problem, non-linear
contrast stretching has been used.
4. Non-linear Contrast Stretching
In non-linear stretching, the DN values are not stretched linearly to uniformly occupy the entire
display range. Different non-linear contrast stretching methods are available. Some of them
are the following.

✓ Histogram-equalized stretch
✓ Piece-wise linear stretch
✓ Logarithmic, power law or Gaussian stretch

Histogram–equalized stretch:
In histogram-equalized stretch the DN values are enhanced based on their frequency in the
3

original image. Thus, DN values corresponding to the peaks of the histogram are assigned to
a wider range. Fig.4 compares the histogram of a raw image with that of the images enhanced
using linear stretching and histogram-equalized stretching

Fig. 4. Histograms of (a) Unstretched image (b) Linear contrast stretched image(c) Histogram
equalised image Fig.5 (a) shows a sample histogram of an image and Fig.5 (b) shows the
corresponding histogram-equalization stretch function. Input DN values corresponding to the
peak of the histogram are stretched to a wider range as shown in the figure.

Fig.5 (a) Sample histogram of an image and (b) Function used for histogram equalized stretch
For example, for an 8-bit display system, the histogram equalization function used for
stretching the input image can be represented as follows.
4
where nj is the number of pixels having DN values in the jth range, k is the number of DN
value ranges, and N is the total number of pixels in the input image.

By assigning more display levels to the higher frequency region that contains majority of
the information, better information enhancement is possible using histogram-equalized
stretch.
(a)

(b)

Fig. 6 Landsat ETM+ Band 5 images and the corresponding histograms (a) before contrast
stretch and (b) after histogram equalization stretch
5
Piece-wise Linear Stretch

In piece-wise linear stretch, different linear functions are used for enhancing the DN values in
different ranges within the same image. In other words, different parts of the histogram are
stretched by different amounts. It is generally useful in cases where the original image has bi-
modal histogram.

Fig.7 shows a sample bimodal function for piece-wise linear stretching.

Fig. 7. A sample bi-modal histogram, piece wise linear function used for the contrast stretching
and the histogram after piece wise contrast stretch

Using the piece-wise linear stretch function, region between the two modes of the histogram
may be compressed, whereas the regions corresponding to the histogram peaks may be
enhanced as shown in Fig.7. It is also used to enhance any special features in the image.

Logarithmic, power law or Gaussian stretch


In logarithmic stretching, curves having the shape of the logarithmic function are used for
rescaling the original DN levels into the wider output range, as shown in Fig. 8.
6

Fig. 8. A sample logarithmic stretch function


General form of logarithmic stretching uses the following form.

DNst = c log (1+DN)

where c is a constant.

As shown in Fig. 8, in logarithmic stretching, smaller values are stretched to a wider range,
whereas narrower output range is used for higher values. This type of stretching is generally
used to enhance the information contained in the dark pixels, during which process the
information contained in the lighter pixels are compressed.

Application of power law executes the stretching in an opposite way. Power-law contrast
stretching generally uses the following form.
DNst = c DNn

where c and n are positive constants. Fig. 9 shows the sample power function for contrast
stretching. While using the power functions, higher values are expanded to a wider range. This
enhances information contained in the higher DN values, whereas the lower DN values are
compressed.

Fig. 9. A sample function used for power law contrast stretching

In Gaussian contrast stretch, the DN values are modified in such a way that the stretched
brightness value distribution resembles a normal distribution. Fig. 10 shows the Landsat ETM+
Band 5 image after applying the Gaussian contrast stretching. Original image is shown in Fig.
6(a).
7
Fig.10. Landsat ETM+ Band 5 image after applying the Gaussian contrast stretching

Fig. 11 gives the schematic representation of all the above contrast stretching methods.
Histogram of the original image is shown in Fig. 11(a). The values are only in the range
60-
158. Therefore in an 8-bit display system, only the range 60-158 is used for the image display
resulting in poor contrast. Fig.11 (b) shows the linear stretching, wherein the range 60-158 is
equally transformed into the full range 0-255 using linear function. Fig.11 (c) shows the
schematic of the histogram equalization stretch. The range 60-108, having low frequency, is
transformed into a relatively narrower range 0-38, whereas the high frequency range 108-
158 is transferred to a wider range 38-255. Fig.11 (d) shows special stretch wherein only
the range 60-92 is stretched to occupy the full display range. The remaining ranges are
compressed.
8
Fig. 11. Schematic representation showing various contrast stretching algorithms (Courtesy:
Lillesand et al., 2004)

5. Look-up Table

In contrast stretching, DN values in the original image are transformed into another range and
the resulting new DN values (DNst) represent the enhanced image. If the transformation has to
be estimated for every pixel of an image using the transformation functions, the procedure
would involve significantly large amount of computation. For example, a 60 x 60 km
multispectral SPOT image would require new DNs to be calculated for 27 million pixels.
Assuming 500,000 arithmetic operations a second, this procedure would take nearly four
minutes.
9
On the other hand, since the transformation functions are well defined, it is possible to
calculate DNst for all possible DN values in a single stretch, and can be presented in a tabular
form, as shown in Fig. 12. Such a table is called look-up table (LUT). Fig. 12 (a) shows a
sample linear transformation function used for contrast stretching. Fig. 12 (b) shows the LUT
for this function.

Fig. 12 (a) A sample linear transformation function used for contrast stretching (b) LUT for
this function

LUT can be used to simplify the contrast stretching process. For any pixel in the original image,
the corresponding DNst may be obtained from the LUT, and thus the contrast stretching
procedure can be speeded up.

10

You might also like