English 中文(简体)
Digital Image Processing

DIP Useful Resources

Selected Reading

DIP - Histogram Stretching
  • 时间:2024-11-03

Histogram stretching


Previous Page Next Page  

One of the other advantage of Histogram s that we discussed in our tutorial of introduction to histograms is contrast enhancement.

There are two methods of enhancing contrast. The first one is called Histogram stretching that increase contrast. The second one is called Histogram equapzation that enhance contrast and it has been discussed in our tutorial of histogram equapzation.

Before we will discuss the histogram stretching to increase contrast, we will briefly define contrast.

Contrast

Contrast is the difference between maximum and minimum pixel intensity.

Consider this image.

stretching

The histogram of this image is shown below.

stretching

Now we calculate contrast from this image.

Contrast = 225.

Now we will increase the contrast of the image.

Increasing the contrast of the image

The formula for stretching the histogram of the image to increase the contrast is

stretching

The formula requires finding the minimum and maximum pixel intensity multiply by levels of gray. In our case the image is 8bpp, so levels of gray are 256.

The minimum value is 0 and the maximum value is 225. So the formula in our case is

stretching

where f(x,y) denotes the value of each pixel intensity. For each f(x,y) in an image , we will calculate this formula.

After doing this, we will be able to enhance our contrast.

The following image appear after applying histogram stretching.

stretching

The stretched histogram of this image has been shown below.

Note the shape and symmetry of histogram. The histogram is now stretched or in other means expand. Have a look at it.

stretching

In this case the contrast of the image can be calculated as

Contrast = 240

Hence we can say that the contrast of the image is increased.

Note : this method of increasing contrast doesnot work always, but it fails on some cases.

Faipng of histogram stretching

As we have discussed , that the algorithm fails on some cases. Those cases include images with when there is pixel intensity 0 and 255 are present in the image

Because when pixel intensities 0 and 255 are present in an image, then in that case they become the minimum and maximum pixel intensity which ruins the formula pke this.

Original Formula

stretching

Putting fail case values in the formula:

stretching

Simppfy that expression gives

stretching

That means the output image is equal to the processed image. That means there is no effect of histogram stretching has been done at this image.

Advertisements