Professional Documents
Culture Documents
GUI IN MATLAB
A PROJECT REPORT
Submitted by
SUKUMAR L (623520104046)
MURUGAN V (623520104027)
NARAYANAKUMAR S (623520104029)
of
BACHELOR OF ENGINEERING
IN
COMPUTER SCIENCE AND ENGINEERING
MAY 2023
ANNA UNIVERSITY: CHENNAI – 600 025
BONAFIDE CERTIFICATE
SIGNATURE SIGNATURE
SUKUMAR L (623520104046)
MURUGAN V (623520104027)
NARAYANAKUMAR S (623520104029)
Mr.P.KARANRAJ., M.E.,
Assistant Professor,
Department of CSE
ACKNOWLEDGMENT
We have immense pleasure in expressing our sincere thanks to our Head ofthe
Department Mrs.K.VIJAYALAKSHMI,M.E.,(Ph.D.,) Department of Computer
Science and Engineering for her meticulous guidance at every stage that helped us
in the successful completion of our Project Work.
We extremely grateful to our Parents, family members and friends for their
blessings, best wishes and willing co-operation at all stages of this academic venture.
SUKUMAR L
MURUGAN V
NARAYANAKUMAR S
ABSTRACT
This project deals with learning about the various types of steganography
available. Image steganography is performed for images and the concerning data is
also decrypted to retrieve the message image. Since this can be done in several
ways, image steganography is studied and one of the methods is used to
demonstrate it. Image steganography refers to hiding information i.e., text, images
or audio files in another image or video files. The current project aims to use
steganography for an image with another image using spatial domain technique.
This hidden information can be retrieved only through proper decoding technique.
This encryption and decryption of the images is done using MATLAB codes.
Steganography may be accustomed conceal virtually any form of digital content,
together with text, image, video, or audio content; the info to be hidden within
virtually the other form of digital content. In this paper I purposed an image based
steganography that Least Significant Bits (LSB) techniques and pseudo random
encoding technique on images to enhance the security of the communication. In the
LSB approach, the basic idea is to replace the Least Significant Bits (LSB) of the
cover image with the Bits of the messages to be hidden without destroying the
property of the cover image significantly.
V
TABLE OF CONTENT
ABSTRACT v
LIST OF TABLE ix
LIST OF FIGURE x
LIST OF ABBREVIATIONS xi
1 INTRODUCTION 1
1.1 STEGANOGRAPHY 1
CRYPTOGRAPHY
1.3.1 PAST 3
1.3.2 PRESENT 3
1.3.3 APPLICATION OF 5
STEGANOGRAPHY
1.4 OBJECTIVE 6
2 IMAGE STEGANOGRAPHY 7
TECHNIQUES
TECHNIQUES
HIDING
TECHNIQUE
ALGORITHM
ALGORITHM
4 REQUIREMENTS 20
5 PERFORMANCE ANALYSIS 21
5.1 PERFORMANCE ANALYSIS 21
7 APPENDIX 28
REFERENCES 39
LIST OF TABLES
1 Comparison of characters of 21
above two techniques
2 PSNR of Pseudo-Random Encoding 23
3 PSNR of Least Significant Bits Encoding 23
IX
S.NO LIST OF FIGURES PAGE NO
X
S.NO ABBREVIATION PAGE NO
XI
CHAPTER 1
INTRODUCTION
1.1 STEGANOGRAPHY
The word steganography is derived from the Greek words stegos meaning
cover and grafia meaning writing defining it as covered writing. In image
steganography the information is hiddenexclusively in images. Steganography is the
art and science of secret communication .It is the practice of encoding/embedding
secret information in a manner such that the existence of the information is invisible.
The original files can be referred to as cover text, cover image, or cover audio. After
inserting the secret message it is referred to as stego-medium. A stego-key is used for
hiding/encoding process to restrict detection or extraction of the embedded data.
Steganographic techniques strive to hide the very presence of the message itself
from an observer. The general idea of hiding some information in digital content has
a wider class of applications that go beyond steganography. Steganography is the
process of hiding a secret messagewithin a larger one in such a way that someone
cannot know the presence or contents of the hidden message. Although related,
Steganography is not to be confused with Encryption, which is the process of making
a message unintelligible—Steganography attempts to hide the existence of
communication. Steganography is the practice of hiding private or sensitive
information within something that appears to be nothing out to the usual.
Steganography is that the technique of hiding secret information among a normal,
non-secret,file, or message to avoid detection; the key information is then extracted at
its destination. The employment of steganography may be combined with coding as an
additional step for activity or protective information. The word steganography comes
1
from the Greek words steganos (meaning hidden or covered) and the Greek root graph
(meaning to write). Steganography may be accustomedconceal virtually any form of
digital content, together with text, image, video, or audio content; the info to be hidden
within virtually the other form of digital content. The content to be hid through
steganography -- known as hidden text -- is commonly encrypted before being
incorporated into the innocuous-seeming cowl computer file or information stream. If
not encrypted, the hidden text is often processed in a way to make the key content
undetectable.
2
the right to violate their licensing agreement when they illegally transmit the property
to other groups.
The term steganography came into use in 1500s after the appearance of
Tritheism book onthe subject Steganography.
1.3.1 PAST
1.3.2 PRESENT
3
4. A stego-key (K) may be used to hide and unhide the message.
In modern approach, depending on the cover medium, steganography can be divided
into five types:
1. Text Steganography 2. Image Steganography 3. Audio Steganography 4. Video
Steganography 5. Protocol Steganography.
• Text steganography Hiding information in text file is the most common method of
steganography.The method was to hide a secret message into a text message. After
coming of Internet and different type of digital file formats it has decreased in
importance. Text stenography using digital files is not used very often because the text
files have a very small amount of excess data.
• Image steganography Images are used as the popular cover medium for
(i) Secret Communications The use steganography does not advertise secret
communication and therefore avoids scrutiny of the sender, message, and recipient. A
trade secret, blueprint, or other sensitive information can be transmitted without
alerting potential attackers.
(ii) Feature Tagging Elements can be embedded inside an image, such as the names of
individuals in a photo or locations in a map. Copying the stego-image also copies all of
the embedded features and only parties who possess the decoding stego-key will be able
to extract and view the features.
(iii) Copyright Protection Copy protection mechanisms that prevent data, usually
digital data, frombeing copied. The insertion and analysis of watermarks to protect
5
copyrighted material is responsible for the recent rise of interest in digital
steganography and data embedding.
1.4 OBJECTIVE
The project is carried out with the following objectives:
• To hide the message or a secret data into an image which acts as a cover
6
CHAPTER 2
IMAGE STEGANOGRAPHY
An image is a picture that has been created or copied and stored in electronic
form. An imagecan be described in terms of vector graphics or raster graphics . An
image stored in raster form is sometimes called a bitmap . An image map is a file
containing information that associates differentlocations on a specified image with
hypertext links. An image is a collection of numbers that constitute different light
intensities in different areas of the image. This numeric representation forms a grid
and the individual points are referred to as pixels (picture element).Greyscale images
use 8 bits for each pixel and are able to display 256 different colours or shades of grey.
Digital colourimages are typically stored in 24-bit files and use the RGB colour model,
also known as true colour.
All colour variations for the pixels of a 24-bit image are derived from three
primary colours: red, green and blue, and each primary colour is represented by 8 bits
Thus in one given pixel, there canbe 256 different quantities of red, green and blue.
In images there are two types of compression: lossy compression and lossless
compression.In Lossless compression, With lossless compression, every single bit of
data that was originally in the file remains after the file is uncompressed. All of the
information is completely restored. The most popular image formats that use lossless
compression is GIF (Graphical Interchange Format) and BMP (bitmap file). lossy
compression reduces a file by permanently eliminating certain information, especially
7
redundant information. When the file is uncompressed, only a part of the original
information is still there. In this case the resulting image is expected to be something
similarto the original image, but not the same as the original. An example of an image
format that uses this compression technique is JPEG (Joint Photographic Experts
Group).
There are several Steganographic techniques for image file format which are as follows
8
2.3.2 MASKING AND FILTERING
9
Transform domain techniques are of different types:
10
Tamper Resistance Beyond robustness to destruction, tamper-resistance
refers to the difficulty for an attacker to alter a message once it has been
embedded in a stego-image.
There are several steganalytic tools available in market like Photo Title,
2Mosaic and Stir Mark Benchmark etc. These three steganalytic tools can remove
steganographic content from any image. This is achieved by destroying secret
message by two techniques: break apart and resample.
11
CHAPTER 3
The least significant bit (in other words, the 8th bit) of some or all of the bytes
inside an image is changed to a bit of the secret message. Digital images are mainly
of two types (i) 24 bit images and (ii) 8 bit images. In 24 bit images we can embed
three bits of information in each pixel, one in each LSB position of the three eight bit
values. Increasing or decreasing the value by changingthe LSB does not change the
appearance of the image; much so the resultant stego image looks almost same as the
cover image. In 8 bit images, one bit of information can be hidden.
The cover image is shown in Figure 4.7 and a hidden message is shown in Figure 4.8
A stego-image(figure 4.9) is obtained by applying LSB algorithm on both the cover and
hidden images. The hiddenimage is extracted from the stego-image by applying the
reverse process[1, 11]. If the LSB of the pixel value of cover image C(i,j) is equal to
the message bit m of secret massage to be embedded, C(i,j) remain unchanged; if not,
set the LSB of C(i, j) to m. The message embedding procedure is given below
S(i,j) = C(i,j) - 1, if LSB(C(i,j)) = 1 and m = 0
where LSB(C(i, j)) stands for the LSB of cover image C(i,j) and m is the next message
bit to be embedded.
S(i,j) is the stego
image As we already know each pixel is made up of three bytes consisting of either a
1 or a 0.
For example, suppose one can hide a message in three pixels of an image (24-bit
colours). Supposethe original 3 pixels are:
A steganographic program could hide the letter ”J” which has a position 74 into ASCII
character setand have a binary representation ”01001010”, by altering the channel bits
of pixels.
13
(11001001 00100100 11101001)
In this case, only four bits needed to be changed to insert the character succesfully.
The resulting changes that are made to the least significant bits are too small to be
recognised by the human eye, so the message is effectively hidden. The advantage of
LSB embedding is its simplicity and many techniques use these methods [10]. LSB
embedding also allows high perceptual transparency.
The embedding process is as follows. Inputs Cover image, stego-key and the text file
Output stegoimage Procedure
14
the text file. Step 3: Extract the characters
Step 4: Choose first pixel and pick characters of the Stego key and place it in first
component ofpixel.
Step 5: Place some terminating symbol to indicate end of the key. 0 has been used as a
terminatingsymbol in this algorithm.
Step 6: Insert characters of text file in each first component of next pixels by replacing
it.
Step 7: Repeat step 6 till all the characters has been embedded.
Step 8: Again place some terminating symbol to indicate end of data.
Step 9: Obtained stego image.
15
3.1.2 DATA EXTRACTION
Step 2: Now, start from first pixel and extract stego key characters from first
component of thepixels. Follow Step3 up to terminating symbol, otherwise follow
step 4.
Step 4: If this extracted key matches with the key entered by the receiver, then
follow Step 5,otherwise terminate the program.
Step 5: If the key is correct, then go to next pixels and extract secret message
characters from firstcomponent of next pixels. Follow Step 5 till up to terminating
symbol, otherwise follow step 6.
1. The cover and secret images are read and converted into the unit8 type.
2. The numbers in secret image matrix are conveyed to 8-bit binary. Then the matrix
is reshaped toa new matrix a.
16
4. Perform the LSB technique described above
5. The stego-image, which is very similar to the original cover image, is achieved
by reshapingmatrix b.
6. While extracting the data, the LSB of the stego image is collected and they are
reconstructed intothe decimal numbers. The decimal numbers are reshaped to the
secret image.
In this technique, A random key is used to choose the pixels randomly and
embed the message. This will make the message bits more difficult to find and
hopefully reduce the realization of patterns in the image . Data can be hidden in the
LSB of a particular colour plane (Red plane) of the randomly selected pixel in the
RGB colour space.
17
1) Read character from text file that is to be hidden and convert the ASCII value of
2) Read the RGB colour image(cover image) into which the message is to be embedded.
4) Initialize the random key and Randomly permute the pixels of cover image and
5) Initialize the stego-key and XOR with text file to be hidden and give message.
6) Insert the bits of the secret message to the LSB of the Red plane’s pixels.
In this process of extraction, the process first takes the key and then random -key.
These keys takes out the points of the LSB where the secret message is randomly
distributed . Decoding processsearches the hidden bits of a secret message into the
least significant bit of the pixels within a cover image using the random key. In
decoding algorithm the random-key must match i.e. the random- key which was used
in encoding should match because the random key sets the hiding points of themessage
in case of encoding. Then receiver can extract the embedded messages exactly using
onlythe stego-key.
18
1) Open the Stego image file in read mode and from the Image file, read the RGB
colour of eachpixel.
4) Initialize the random-key that gives the position of the message bits in the red
5) For decoding, select the pixels and Extract the LSB value of red pixels.
7) Read each of pixels then content of the array converts into decimal value that is
actually ASCIIvalue of hidden character.
8) ASCII values got from above is XOR with stego-key and gives message file, which
19
CHAPTER 4
REQUIREMENTS
• Language: C\C++
• Ram: 4GB
20
CHAPTER 5
PERFORMANCE ANALYSIS
As a performance measure for image distortion due to hidding of message, the well-
known peak-signal-to noise ratio (PSNR), which is categorized under difference
distortion metrics, can be applied to stego images. It is defined as:
PSNR =
10log(Cmax)2/MSE.
MSE = mean − square −
error,which is given as:
MSE = 1/MN( (S-C)2 ).
Cmax = 255.
Where M and N are the dimensions of the image,
S is the resultant stego-image, and C is the cover image.
PSNR values below 30 dB indicate low quality (i.e., distortion caused by embedding
is high). A high-quality stego image should strive for a PSNR of 40 dB, or higher.
We have implemented the above two techniques in MATLAB and the above
mentionedalgorithms with respect to image steganography are not void of weak
and strong points. Consequently, it is important to decide the most suitable
approach to be applied. As defined before, there are several parameters to measure
the performance of the steganographic system. Some parameters are as follows:
21
Perceptibility does embedding information distort cover medium to a visually
unacceptable level.
Capacity how much information can be hidden (relative to the change in
perceptibility)
item Robustness to attacks can embedded data survive manipulation of the stego
medium in an effort to destroy, remove, or change the embedded data.
Tamper
SL.No Imperceptibili Robustness Capacity
ty Resistance
Simple LSB High* Low High Low
Pseudo-
Random Higher* Low High High**
Encoding
Table 5.1: Comparision of characters of above two techniques
*: Indicates dependency on the used cover image
**: Indicates dependency on the used key and random seed
22
SL.No Cover Secret Stego SNR(dB) MSE PSNR(dB)
Image Message Image
23
Figure 5.1: cover image
The difference images are shown in figures 5.11 to 5.15, where white pixels indicate
the spatiallocations where the images differ.
24
Figure 5.3: Pseudo-Random Encoding
25
Figure 5.6: GUI (Graphical User Interface)
26
CHAPTER 6
CONCLUSION:
FUTURE ENHANCEMENTS:
27
CHAPTER 7
APPENDIX
7.1 SOURCE CODE:
% Begin initialization
codegui_singleton = 1;
gui_state = struct ( ‘gui_Name’, mfilename, …
‘gui_Singleton’, gui-
singleton,… ‘gui_OpeningFcn’,
@Image_openingFcn
, …‘gui_OutputFcn’,
@Image_outputFcn,
… ‘gui_LayoutFcn’, [],…
‘gui_Callback’, [ ]) ;
argumentsif nargout
[varargout {1:nargout}] = gui_mainfcn (gui_state, varargin {:});
28
else
end
gui_mainfcn (gui_state, varargin{:});
% End initialization code
% --- Executed just before Image is made visible.
Function Image_OpeningFcn (hObject, eventdata, handles, varargin)
% This function has no output args,see Outputfcn.
global
mag1
global
mag2
global
mag3
global
mag4
30
msg1 = imread
(‘messagel.bmp’);axes
(handles.axes3);
imshow(msg1);
msg1 = rgb2gray(msg1);
msg1 = imresize(msg1, [512 512]);
msg2 = imread
(‘message2.bmp’);axes
(handles.axes8) ;
imshow (msg2) ;
msg2 = rgb2gray(msg2) ;
msg2 = imresize (msg2, [512 512]);
msg3 =
imread(‘message3.bmp’);
axes(handles.axes7);
imshow(msg3);
msg3 = rgb2gray(msg3);
msg3 = imresize (msg3, [512 512]);
msg4 =
imread(‘message4.bmp’);
axes(handles.axes9);
imshow(msg4);
msg4 = rgb2gray(msg4);
msg4 = imresize (msg4, [512 512]);
% ---Executes on button press in ImportCover.
Function ImportCover_callback (hObject, eventdata, handles)
% hObject handle to ImportCover (see GCBO)
% eventdata reserved – to be defined in a future version of
MATLAB
% handles structure with handles and user data (see
31
GUIDATA)
global cvr
cvr =
imread(‘cover.bmp’);
cvr = rgb2gray(cvr);
cvr = imresize(cvr, [1024 1024]);
cvr = imnoise (cvr,’gaussian’); %addind
gaussian noiseaxes(handles.axes2);
imshow(cvr);
% ---Executes on button press in ImportCover.
Function Encrypt_Callback (hObject, eventdata,
handles)
% hObject handle to ImportCover (see GCBO)
% eventdata reserved – to be defined in a future version of
MATLAB
% Handles structure with handles and user data (see
GUIDATA)
global mag1
global
mag2
global
mag3
global
mag4
global cvr
32
imagen1 = size (cvr,2) ; % width of
cover image m2 = size (cvr,1) ;
%height of cover image n2 = size
(cvr,2) ; %width of cover image
%extract upper 4 bitplanes of
messageSteg1 = msg;
For I = 1:m2
msg_b7 (i,j) = bitand (steg1 (i,j) , 128) ; &msb of
messagemsg_b6 (i,j) = bitand (steg1 (i,j) , 64) ;
msg_b5 (i,j) = bitand (steg1 (i,j) ,
32) ;msg_b4 (i,j) = bitand (steg1
(i,j) , 16) ;end
end
%extract 8 bitplanes of cover
imagesteg2 = cvr;
for I = 1:m2
for j = 1:n2
cvr_b7 (i,j) = bitand (steg2 (i,j) , 128) ; %msb of coverimage
endend
(‘steganographic.bmp’);
34
[m,n]=size(img) ;
for i=1 :m
for j=1 :n
img_b7 (i,j) =bitand (img (i,j) , 128) ; %msb
of imageimg_b6 (i,j) =bitand (img (i,j) , 64) ;
img_b5 (i,j) =bitand (img (i,j) , 32) ;
img_b4 (i,j) =bitand (img (i,j) , 16) ;
img_b3 (i,j) =bitand (img (i,j) , 8) ;
img_b2 (i,j) =bitand (img (i,j) , 4) ;
img_b1 (i,j) =bitand (img (i,j) , 2) ;
img_b0 (i,j) =bitand (img (i,j) , 1) ; %lsb
of imageend
end
35
512) ;axes (handles.axes13);
imshow(m3);
imwrite (m3,’retrieved_image_3.bmp’) ;
m4 = message (512 : end :, 512 :
end) ;axes (handles.axes11);
imshow(m4);
imwrite (m4,’retrieved_image_4.bmp’) ;
% ---Executes on button press in
ImportCover. Function RESET_Callback
(hObject, eventdata, handles)
% hObject handle to ImportCover (see GCBO)
% eventdata reserved – to be defined in a future version of
MATLAB
% handles structure with handles and user data (see
GUIDATA)
axes
(handles.axes10);
cla () ;
axes
(handles.axes11);
cla () ;
axes
(handles.axes12);
cla () ;
axes
(handles.axes13);
cla () ;
axes
(handles.axes14);
36
cla () ;
axes
(handles.axes2);
cla () ;
axes
(handles.axes3);
cla () ;
axes
(handles.axes7);
cla () ;
axes
(handles.axes8);
cla () ;
axes
(handles.axes9);
cla () ;
% ---Executes on button press in
ImportCover. Function EXIT_Callback
(hObject, eventdata, handles)
% hObject handle to ImportCover (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see
GUIDATA)Close
37
OUTPUT:
38
REFERENCE
2021, <https://towardsdatascience.com/hiding-data-in-an-image-
imagesteganography-using-python- e491b68b1372>
3. Image Steganography in Cryptography, accessed 16 January 2021,
<https://www.geeksforgeeks.org/image-steganography-incryptography/ >
4. Image Steganography, accessed 16 January 2021,
<https://www.scribd.com/document/442028580/EE7150-
finalprojectFinalreport-Savitha-Bhallamudi-pdf>
5. SAVITHA BHALLAMUDI. Image Steganography Final project. Accessed
16 January 2021,https://www.scribd.com/document/442028580/EE7150-
finalprojectFinalreport-Savitha-Bhallamudi-pdf
39