show by calculation that applying the histogram equalization twice to a digital image will give the same result as applying it once. in matlab

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.m
histeq(histeq(I)) = histeq(T(I))
33 chars
2 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.m
histeq(T(I)) = T(I)
20 chars
2 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.m
I = imread('input_image.jpg');
J = histeq(I);
K = histeq(J);

% Show that J and K are the same image
isequal(J, K)  % Returns true

% Show that applying histogram equalization twice gives the same result as once
L = histeq(histeq(I));
isequal(J, L)  % Returns true
265 chars
11 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.

related categories

gistlibby LogSnag