The histogram equalization function in Matlab is histeq
. We can show that applying the function twice gives the same result as applying it once mathematically.
Let's say our input image is I
, and applying histogram equalization to it gives an output image J
. Applying histogram equalization again to J
would result in another output image K
.
We can show that J
and K
are the same image as follows:
main.m33 chars2 lines
where T
is the transformation function used by histeq
.
The transformation function T
is computed using the cumulative distribution function (CDF) of the image histogram. The CDF is a monotonically increasing function that maps pixel intensities to cumulative probability values.
Applying histogram equalization to the input image I
first computes the transformation function T1
using the CDF of I
, and then applies T1
to I
to get the output image J
.
Applying histogram equalization again to J
uses the CDF of J
to compute the transformation function T2
, and then applies T2
to J
to get the output image K
.
We can simplify the equation above as follows:
main.m20 chars2 lines
This is because the transformation function T
is normalized so that T(I)
has the same mean and variance as I
.
Therefore, applying histogram equalization twice to an image I
using the same transformation function T
results in the same image T(I)
.
To demonstrate this in Matlab, we can apply histogram equalization twice to an image and compare the result to applying it once:
main.m265 chars11 lines
This code loads an input image, applies histogram equalization twice, and compares the result to applying it once. The isequal
function is used to check if two images are the same.
gistlibby LogSnag