Here we want to convert the image so that it has a particular histogram that can be arbitrarily specified. Such a mapping function can be found in three steps:
We first equalize the histogram of the input image :
We then equalize the desired histogram of the output image :
The inverse of the above transform is
However, as the image gray levels are discrete, the continuous mapping obtained above can only be approximated. The discrete histograms and are not necessarily identical. We therefore need to relate each gray level in with to a gray level in with , so that the mapping from to can be established.
Here are the specific steps of the algorithm:
The histogram of the given image and the histogram desired are shown below:
Here is the look-up table:
This is the histogram of the resulting image:
In the following example, the desired histogram is a triangle with linear increase in the lower half of the the gray level range, and linear decrease in the upper half. Again the cumulative histogram shows indeed the density histogram is such a triangle.