Histogram Specification

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 $p_x$ of the input image $x$:

$\displaystyle y=f(x)=\int_0^x p_x(u) du$ (17)

We then equalize the desired histogram $p_z$ of the output image $z$:

$\displaystyle y'=g(z)=\int_0^z p_z(u) du$ (18)

The inverse of the above transform is

$\displaystyle z=g^{-1}(y')$ (19)

As the two intermediate images $y$ and $y'$ both 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 to be:

$\displaystyle z=g^{-1}(y')=g^{-1}(y)=g^{-1}(f(x))$ (20)

However, as the image gray levels are discrete, the continuous mapping obtained above can only be approximated. The discrete histograms $h_y[i]$ and $h_{y'}[i]$ are not necessarily identical. We therefore need to relate each gray level in $x$ with $h_x[i]\ne 0$ to a gray level in $z$ with $h_z[j]\ne 0$, so that the mapping from $y$ to $y'$ can be established.

hist_specify.gif

Here are the specific steps of the algorithm:

Example:

The histogram of the given image and the histogram desired are shown below:

hist_specify_1.gif

In the following example, the desired histogram is a triangle with linear increasing slope in the lower half of the the gray level range, and linear decreasing slope in the upper half. Again the cumulative histogram shows indeed the density histogram is such a triangle, i.e., its derivative is the desired triangle.

HistogramEqSp.jpg