Linear contrast stretching uniformly expands the intensity values in an image to utilize the full range of available intensities. Histogram equalization spreads out intensity values to improve contrast by effectively stretching the most frequent values. Piecewise linear stretching uses different linear functions to enhance different intensity ranges differently. Logarithmic stretching compresses higher intensity values while expanding lower ones, enhancing dark areas. Contrast stretching techniques aim to improve poor contrast by modifying intensity distributions, but can increase noise and lose original brightness levels.
2. Introduction
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.
Contrast stretching is an Image Enhancement method which attempts to improve an image by stretching the range of
intensity values.Here, we stretch the minimum and maximum intensity values present to the possible minimum and
maximum intensity values.
Contrast stretching is only possible if minimum intensity value and maximum intensity value are not equal to the possible
minimum and maximum intensity values. Otherwise, the image generated after contrast stretching will be the same as
input image.
3. Contrast Enhancement Techniques
1. Linear Contrast Stretch
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.
Example: If the minimum intensity value(r min ) present in the image is 100 then it is stretched to the possible
minimum intensity value 0. Likewise, if the maximum intensity value(r max) is less than the possible maximum intensity
value 255 then it is stretched out to 255.(0–255 is taken as standard minimum and maximum intensity values for 8-bit
images).
General Formula for Contrast Stretching:
4. For I min = 0 and I max = 255 (for standard 8-bit grayscale image)
where,
r = current pixel intensity value ,r min = minimum intensity value present in the whole image , r max = maximum
intensity value present in the whole image.
Example of Linear contrast stretching :
Input Image Output Image
5. 2. Histogram Equilization
Histogram Equalization is a computer image processing technique used to improve contrast in
images. It accomplishes this by effectively spreading out the most frequent intensity values, i.e.
stretching out the intensity range of the image. This method usually increases the global contrast of
images when its usable data is represented by close contrast values. This allows for areas of lower local
contrast to gain a higher contrast.
Steps of Histogram Equilization :
a. Convert the input image into a grayscale image
b. Find frequency of occurrence for each pixel value i.e. histogram of an image (value lie in the
range [0, 255] for any grayscale image)
c. Calculate Cumulative frequency of all pixel values
d. Divide the cumulative frequencies by total number of pixels and multiply them by
maximum graycount (pixel value) in the image.
6. Example of Histogram Equilization :
Input Image Output Image
Histogram of Input Image Histogram of Output Image
7. 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.
The following figure shows a sample bimodal function for piece-wise linear stretching.
A sample bi-modal histogram, piece wise linear function used for the contrast stretching and the
histogram after piece wise contrast stretch.
8. 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
Figure. It is also used to enhance any special features in the image.
Example of piece-wise linear search :
Input Image Output Image
9. Logarithmic 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 Figure.
A sample logarithmic stretch function
General form of logarithmic stretching uses the following form.
𝐷𝑁𝑠𝑡= c log (1+DN)
Where 𝐷𝑁𝑠𝑡 and DN are the pixel values of the output and the input image and c is a constant. The
value 1 is added to each of the pixel value of the input image because if there is a pixel intensity of 0 in
the image, then log (0) is equal to infinity. So 1 is added, to make the minimum value at least 1.
10. As shown in Figure 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.
Example of Logarithmic stretching :
Input Image Output Image
11. Fig. 1 gives the schematic representation of all the above contrast stretching methods. Histogram of the original image is shown in Fig. 1(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.1 (b) shows the linear stretching, wherein the range 60-158 is equally transformed into the full range 0-255 using linear
function. Fig.1 (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.1(d) shows special
stretch wherein only the range 60-92 is stretched to occupy the full display range. The remaining ranges are compressed.
Summary of all the contrast stretching methods :
Fig. 1 : Schematic representation showing various contrast
stretching algorithms .
12. Uses of Contrast Stretching algorithms :
• Linear stretch technique can be applied to images where substantial lack of contrast can result in false identification
of objects, its spacial relationship and significance. Contrast enhancement by linear stretch can be applied to images
with very low or very high variations of brightness.
• Histogram equilization method usually increases the overall contrast of many images, especially when the usable
data of the image is represented by close contrast values. This adjustment allows the intensities to be distributed
better on the histogram. This allows areas of lower contrast to gain a higher contrast.
• Piece-wise linear stretch function is used to enhance any special features in the image.
• Log transformation of an image means replacing all pixel values, present in the image, with its logarithmic values. Log
transformation is used for image enhancement as it expands dark pixels of the image as compared to higher pixel
values.
13. Drawbacks of using contrast stretching algorithms:
• The result is less dramatic, but tends to avoid the sometimes artificial appearance of equalized images.
• The drawback of linear contrast stretching method is that outliers can reduce the effectiveness of the operation.
• If the histogram equalization function is known, then the original histogram can be recovered. The calculation is
not computationally intensive. A disadvantage of the method is that it is indiscriminate. It may increase the contrast of
background noise , while decreasing the usable signal.
• Histogram equalization fails when the input image has a large area low-intensity background.
• Histogram equalization is not the best method for contrast enhancement because the mean brightness of the output
image is significantly different from the input image.
14. CONCLUSION
This project provides the visual results of various techniques. In the computer simulated results, the original
image is blurred. Although it has good global contrast, but the local contrast is poor as the objects in the image
are not easily perceivable.
Histogram Equalization when applied to the original image, improves the contrast of the image but the white
regions of the image get over enhanced. This is because the Histogram Equalization treats the image globally.
The Histogram Equilization method is useful in images with backgrounds and foregrounds that are both bright
or both dark. The global techniques cannot improve the contrast of the image satisfactorily.
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. It is also used to
enhance any special features in the image.
Logarithmic 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.