todayitryto: explain what Histogram Equalization is

Histogram Equalization is used in image processing to “enhance” a grayscale image by increasing its contrast and often used in images where both foreground and background are dark or light.

The image might actually look bad photography wise but makes it better for scientific purposes like thermal, xrays, satellite images.

An image histogram is a graph of the tonal distribution (the lightness) of an image.

(number of pixels vs pixel intensity)             got this from http://www.cambridgeincolour.com/tutorials/histograms1.htm

What histogram equalization does is to try to make the stuff in the graph above more spread out instead of the clump we see right now that’s in the middle.

How to do it

Wikipedia has a link to some pseudo-code in the “External Links” area of their page on the same subject. Here I will just show the basic steps:

You will need the grayscale image in matrix form

  1. Count total number of pixels in a certain intensity, for all intensities.
  2. Get the pixel probability (number of pixels in that intensity / total number of pixels in image)
  3. Get cumulative pixel probability (copy first probability then add the next probability. Keep doing this for all probabilities, like 0.6 = 0.6, 0.6 + 0.25 = 0.85, 0.85 + 0.03 = 0.87… until it is = 1)
  4. Multiply the cumulative probability of a pixel by the maximum intensity
  5. Round up or round down to make the new cumulative probability a whole number
  6. Map these new values to a new image matrix

The pixels should be evenly distributed through the intensity range. It should look something like this

got both from http://fourier.eng.hmc.edu/e161/lectures/contrast_transform/node2.html

Sources:
http://fourier.eng.hmc.edu/e161/lectures/contrast_transform/node2.html (the site linked in Wikipedia that has pseudo-code)

And this video https://www.youtube.com/watch?v=PD5d7EKYLcA

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s