Histogram: Gray Levels

Only available on StudyMode
  • Pages : 5 (890 words )
  • Download(s) : 44
  • Published : February 25, 2013
Open Document
Text Preview
Histogram Equalization
To transfer the gray levels so that the histogram of the resulting image is equalized to be a constant:

The purposes:
* To equally use all available gray levels;
* For further histogram specification.

This figure shows that for any given mapping function y = f(x) between the input and output images, the following holds:

i.e., the number of pixels mapped from x to y is unchanged. To equalize the histogram of the output image, we let p(y) be a constant. In particular, if the gray levels are assumed to be in the ranges between 0 and 1 ( ), then p(y) = 1. Then we have:

i.e., the mapping function y = f(x) for histogram equalization is:

where

is the cumulative probability distribution of the input image, which monotonically increases.

Intuitively, histogram equalization is realized by the following: * If p(x) is high, P(x) has a steep slope, dy will be wide, causing p(y) to be low to keep p(y) dy = p(x) dx; * If p(x) is low, P(x) has a shallow slope; dy will be narrow, causing p(y) to be high.

For discrete gray levels, the gray level of the input x takes one of the L discrete values: and the continuous mapping function becomes discrete:

where h[i] is the probability for the gray level of any given pixel to be i ( ):

Here h[i] is the histogram of the image and H[i] is the cumulative histogram. The resulting function y’ is in the range and it needs to be converted to the gray levels by either of the two ways: 1. 

 



2. 

 



| | | | | | | | | |
0/7| 790| 0.19| 0.19| 1/7| 0.19| 0.19| 0/7| 0.19| 0.19| 1/7| 1023| 0.25| 0.44| 3/7| 0.25| 0.44| 2/7| 0.25| 0.44| 2/7| 850| 0.21| 0.65| 5/7| 0.21| 0.65| 4/7| 0.21| 0.65| 3/7| 656| 0.16| 0.81| 6/7|  |  | 5/7| 0.16| 0.81| 4/7| 329| 0.08| 0.89| 6/7| 0.24| 0.89| 6/7| 0.08| 0.89| 5/7| 245| 0.06| 0.95| 7/7|  |  | 7/7|  |  |

6/7| 122| 0.03| 0.98| 7/7|  |  | 7/7|  |  |
7/7| 81| 0.02| 1.00| 7/7| 0.11| 1.00| 7/7| 0.11| 1.00| Here is the floor, or the integer part of a real number x, and adding 0.5 is for proper rounding. Note that while both conversions map to the highest gray level L-1, the second conversion also maps to 0 to stretch the gray levels of the output image to occupy the entire dynamic range .

Example: Assume the images have 64 x 64 = 4096 pixels in 8 gray levels. The following table shows the equalization process corresponding to the two methods:

In the following example, the histogram of a given image is equalized. Although the resulting histogram may not look constant, but the cumulative histogram is a exact linear ramp indicating that the density histogram is indeed equalized. The density histogram is not guaranteed to be a constant because the pixels of the same gray level cannot be separated to satisfy a constant distribution.

Programming Hints:
* Find histogram of given image:



 




* Build lookup table:



 




* Image Mapping:








Example:


 


Histogram Specification
Here we want to convert the image so that it has a particular histogram as specified. First consider equalization transform of the given image x:

If the desired image were available, it could also be equalized:

Here is the histogram of the output image, which is specified. The inverse of the above transform is

Since images y and y’ have the same equalized histogram, they are actually the same image; i.e., y = y’, and the overall transform from the given image x to the desired image z can be found as:

where both f and g can be found from the histogram of the given image x and the desired histogram, respectively.

* Step 1: Find histogram of input image , and find histogram equalization mapping:


 



* Step 2: Specify the desired histogram , and find histogram...
tracking img