Difference between contrast stretching and histogram equalization

34,329

Solution 1

Lets Define Contrast first,

Contrast is a measure of the “range” of an image; i.e. how spread its intensities are. It has many formal definitions one famous is Michelson’s:

He says contrast = ( Imax - Imin )/( Imax + I min )

Contrast is strongly tied to an image’s overall visual quality. Ideally, we’d like images to use the entire range of values available to them.

Contrast Stretching and Histogram Equalisation have the same goal: making the images to use entire range of values available to them.enter image description here

But they use different techniques. Contrast Stretching works like mapping

it maps minimum intensity in the image to the minimum value in the range( 84 ==> 0 in the example above )

With the same way, it maps maximum intensity in the image to the maximum value in the range( 153 ==> 255 in the example above )

This is why Contrast Stretching is un-reliable, if there exist only two pixels have 0 and 255 intensity, it is totally useless.

However a better approach is Histogram Equalisation which uses probability distribution. You can learn the steps here

Solution 2

I came across the following points after some reading.

Contrast stretching is all about increasing the difference between the maximum intensity value in an image and the minimum one. All the rest of the intensity values are spread out between this range.

Histogram equalization is about modifying the intensity values of all the pixels in the image such that the histogram is "flattened" (in reality, the histogram can't be exactly flattened, there would be some peaks and some valleys, but that's a practical problem).

In contrast stretching, there exists a one-to-one relationship of the intensity values between the source image and the target image i.e., the original image can be restored from the contrast-stretched image.

However, once histogram equalization is performed, there is no way of getting back the original image.

Solution 3

In Histogram equalization, you want to flatten the histogram into a uniform distribution.

enter image description here

In contrast stretching, you manipulate the entire range of intensity values. Like what you do in Normalization.

enter image description here

Solution 4

Contrast stretching is a linear normalization that stretches an arbitrary interval of the intensities of an image and fits the interval to an another arbitrary interval (usually the target interval is the possible minimum and maximum of the image, like 0 and 255).

Histogram equalization is a nonlinear normalization that stretches the area of histogram with high abundance intensities and compresses the area with low abundance intensities.

Solution 5

Contrast is the difference between maximum and minimum pixel intensity.

Both methods are used to enhance contrast, more precisely, adjusting image intensities to enhance contrast.

During histogram equalization the overall shape of the histogram changes, whereas in contrast stretching the overall shape of histogram remains same.

Share:
34,329
Jeru Luke
Author by

Jeru Luke

Currently working as a developer in the field of Computer Vision and Deep Learning. I have developed an interest in this field ever since I worked as an intern. I usually work with OpenCV for computer vision tasks and TensorFlow and PyTorch when it comes to Deep Learning. Here on SO you will find me answering questions related to OpenCV (a computer vision tool). I provide answers to the best of my ability after having solved it myself. Here is a small list of my contributions: Simple illumination correction for images Improve text segmentation Under the hood of Canny edge operation Homography and Affine Transformations Finding contours within a predefined ROI Drawing convex hulls GrabCut Algorithm for extracting images from foreground Appreciation: I would like to appreciate those who have taken the time to explain their problem statement to the community. My creativity is invigorated upon coming across these questions. I would like to thank the community for posting their questions on the site. Some of my favorite all-time OpenCV and image processing enthusiasts: Miki Dan Masek alkasm Rayryeng nathancy fmw42 Mark Setchell

Updated on September 20, 2020

Comments

  • Jeru Luke
    Jeru Luke almost 4 years

    I would like to know the difference between contrast stretching and histogram equalization.

    I have tried both using OpenCV and observed the results, but I still have not understood the main differences between the two techniques. Insights would be of much needed help.