This document summarizes a student's work on an image processing homework assignment. The student was tasked with using histogram equalization techniques to reveal a hidden message in an provided image. The student wrote MATLAB code to perform histogram equalization on the full image and sections of the image. Equalizing the entire image did not clearly show the message, but equalizing a section revealed the word "Congratulation!" more clearly. Further dividing and equalizing the section produced the best results, mostly revealing the hidden message. The student concluded more practice with histogram equalization and combining it with other transformations could improve the results.
2. Smith
2
Objectives
Using the histogram techniques discussed in class, search the image provided to recover the
hidden message. Utilize histogram equalization to adjust the intensity values for the given image
to create a new image that shows the hidden message.
Equipment and Materials
Time
Matlab
Files from Dr. Gleb
3. Smith
3
Methods
A message is hidden in this image.
The histogram for this image is shown below.
This graph shows the color intensities verses the bit counts for the original image.
Using this image and histogram I created multiple m-files in Matlab which implemented the
formula
𝑠 𝑘 = 𝑇( 𝑟 𝑘) =
(𝐿 − 1)
𝑀𝑁
∑ 𝑛𝑗 𝑤ℎ𝑒𝑟𝑒 𝑘 = 0,1,2, … , 𝐿 − 1
𝑘
𝑗=0
4. Smith
4
to create a map for transforming the image. The transformed image would allow us to read the
hidden message.
Results
For this project I wrote multiple m-files to transform the given image. My first attempt was a
global histogram transformation.
clear all
closeall
A = imread('image01.bmp')
% Load the image into the matrix A
[Counts,X]=imhist(A);
% Gathers data about the intensity values in the image
for k=1:1:256
% Loop that builds thehistogramvalues for the new image
if k == 1
s(k) = ((255)/(417*400))*Counts(k,1);
p = Counts(k,1);
elseif k>1
s(k) = ((255)/(417*400))*(Counts(k,1)+p);
p = p + Counts(k,1);
end
end
s=round(s)';
% Converts the new intensities to intager values
for L = 1:255
% Writes a new image based on the old image and the new histogram
% values
for x = 1:417
for y = 1:400
if A(x,y) == L-1
B(x,y) = s(L);
end
end
end
end
figure(1), imagesc(B)
colorbar
colormap('gray')
5. Smith
5
This code transforms the entire image and produced this linear transformation and converted
image.
The word “Congratulation!” is written across the top above the motor, but it is not very visible.
To improve the visibility I pulled the part of the image containing the word, and then
transformed just that section of the picture.
clear all
closeall
6. Smith
6
A = imread('image01.bmp');
% Load the image into the matrix A
C = A(50:100,100:350);
% Load the section of the image with the word into the matrix C
[Counts1,X1]=imhist(C);
% Gathers data about the intensity values in the image
for k=1:1:256
% Loop that builds thehistogramvalues for the new
if k == 1
s1(k) = ((255)/(417*400))*Counts1(k,1);
p1 = Counts1(k,1);
elseif k>1
s1(k) = ((255)/(417*400))*(Counts1(k,1)+p1);
p1 = p1 + Counts1(k,1);
end
end
s1=round(s1)';
% Converts the new intensities to intager values
for L = 1:255
% Writes a new image based on the old image and the new histogram
% values
for x = 1:51
for y = 1:251
if C(x,y) == L-1
B(x,y) = s1(L);
end
end
end
end
figure(1), imagesc(B)
colorbar
colormap('gray')
This code gave me the following image and transformation curve.
7. Smith
7
This section of the image had only a few different color intensities in comparison to the main
image. The first image is with very close borders which reduced the number of intensities
included, and the second image is with further expanded borders thus including more bit
intensities and producing a better averaging transformation. Performing the transformation and
converting the image made the message easier to read. This local transformation produced much
better results.
To try and further improve the readability of the message I cut the extracted image of the word in
half and applied histogram equalization to each image separately. I then put the image back
together to see the results.
clear all
closeall
A = imread('image01.bmp');
C = A(50:100,100:225);
D = A(50:100, 226:350);
[Counts1,X1]=imhist(C);
[Counts2,X2]=imhist(D);
8. Smith
8
for k=1:1:256
if k == 1
s1(k) = ((255)/(417*400))*Counts1(k,1);
p1 = Counts1(k,1);
elseif k>1
s1(k) = ((255)/(417*400))*(Counts1(k,1)+p1);
p1 = p1 + Counts1(k,1);
end
end
s1=round(s1)';
for w=1:1:256
if w == 1
s2(w) = ((255)/(417*400))*Counts2(w,1);
p2 = Counts2(w,1);
elseif w>1
s2(w) = ((255)/(417*400))*(Counts2(w,1)+p2);
p2 = p2 + Counts2(w,1);
end
end
s2=round(s2)';
for L = 1:255
for x = 1:51
for y = 1:126
if C(x,y) == L-1
B(x,y) = s1(L);
end
end
end
end
for H = 1:255
for m = 1:51
for n = 1:125
if D(m,n) == H-1
E(m,n) = s2(H);
end
end
end
end
figure(1), imagesc([B,E])
colorbar
colormap('gray')
9. Smith
9
The image produced is shown below.
This image was the best image I could produce using histogram equalization. It is fairly clear
and readable.
I did try to break the section of the image into four small pictures to use histogram equalization
on each one, but the results were terrible.
This image is almost as bad as the original image. The hidden word is almost indistinguishable
from the background. I learned from this that more is not always better. I think that there was
not enough of a range of differences in the histograms to produce a useful equalization function.
The histogram for the far right image is shown below.
10. Smith
10
This histogram shows that the concentration of color is very dark and the equalization process
would not change this enough to help us view the image. The transformation plot for the far
right image is shown below.
This transformation curve only sets a small range of bit intensities.
I also tried adjusting the image using both the power and logarithmic transformations. Each of
these methods caused a portion of the hidden word to become visible, but not the full word.
My image is not as clear as I would like and I think that further testing and familiarization with
the method of histogram equalization would improve the results. I also think that applying
different types of image transformations along with the histogram equalization would produce a
better image.