'Difference between contrast stretching and histogram equalization

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.



Solution 1:[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:[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:[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:[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:[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.

Solution 6:[6]

I think that contrast stretching broadens the histogram of the image intensity levels, so the intensity around the range of input may be mapped to the full intensity range.

Histogram equalization, on the other hand, maps all of the pixels to the full range according to the cumulative distribution function or probability.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Jeru Luke
Solution 3 Jeru Luke
Solution 4 MH304
Solution 5 snr
Solution 6 Julian Leviston