IMAGE PROCESSING USING MATLAB
Entropy of an image and image
In this review
paper, at first we have introduced initial contexts of image processing which
are essential to know before entering main domain of image processing science. After
that, fundamental steps in image processing are mentioned. The name MATLAB
stands for matrix laboratory. MATLAB is an interactive system whose basic data
element is an array that does not require dimensioning. This allows formulating
solutions of many technical computing problems, especially those involving
matrix representations. It takes a fraction of time to write a program in a
scalar non interactive language such as C or FORTRAN. It is very easy to
calculate entropy of an image and perform image steganography using this tool. Image
Steganography hides message in the images. This technique is the most popular
because of the fact that almost no perceivable changes occur in images after
hiding a large amount of data with wide variety of available images.
Digital image processing deals with manipulation of digital images
through a digital computer. It is a subfield of signals and systems but focus
particularly on images. DIP focuses on developing a computer system that is
able to perform processing on an image. The input of that system is a digital
image and the system process that image using efficient algorithms, and gives
an image as an output. The most common example is Adobe Photoshop. It is one of
the widely used applications for processing digital images.
What is an Image?
An image is nothing more than a two dimensional signal. It is
defined by the mathematical function f(x,y) where x and y are the two
co-ordinates horizontally and vertically. The value of f(x,y) at any point is
gives the pixel value at that point of an image.
Every digital image processing
system can be represented by a block diagram containing three main elements.
Image processing started with the input of an image in the processing system.
The integrated software within the chip handles the task. Again, it can be
further processed based on the need. But the application of the processing
method or algorithm depends on how the image is inputted, and stored. The
quality of the processed image also depends on many criterions.
In this paper, we review about
digital image processing to calculate entropy of a grayscale image and to
implement image steganography using MATLAB.
FUNDAMENTAL STEPS OF DIGITAL IMAGE PROCESSING:
There are some fundamental steps but as they are fundamental,
all these steps may have sub-steps. The fundamental steps are described below
with a neat diagram.
(i) Image Acquisition:
This is the first step or process of the fundamental steps of
digital image processing. Image acquisition could be as simple as being
given an image that is already in digital form. Generally, the image
acquisition stage involves preprocessing, such as scaling etc.
(ii) Image Enhancement:
Image enhancement is among the simplest and most appealing
areas of digital image processing. Basically, the idea behind enhancement techniques
is to bring out detail that is obscured, or simply to highlight certain features
of interest in an image such as, changing brightness & contrast etc.
(iii) Image Restoration:
Image restoration is an area that also deals with
improving the appearance of an image. However, unlike enhancement, which is
subjective, image restoration is objective, in the sense that restoration
techniques tend to be based on mathematical or probabilistic models of image
(iv) Color Image Processing:
Color image processing is an area that has been gaining its
importance because of the significant increase in the use of digital images
over the Internet. This may include color modeling and processing in a digital
(v) Wavelets and Multi-resolution Processing:
Wavelets are the foundation for representing images in
various degrees of resolution. Images subdivide successively into smaller
regions for data compression and for pyramidal representation.
Compression deals with techniques for reducing the storage
required to save an image or the bandwidth to transmit it. Particularly in the
uses of internet it is very much necessary to compress data.
(vii) Morphological Processing:
Morphological processing deals with tools for extracting
image components that are useful in the representation and description of
Segmentation procedures partition an image into its
constituent parts or objects. Image
segmentation is the process of dividing an image into multiple parts. This is
typically used to identify objects or other relevant information in digital
images. In general, autonomous segmentation is one of
the most difficult tasks in digital image processing. A rugged segmentation
procedure brings the process a long way toward successful solution of imaging
problems that require objects to be identified individually.
(ix) Representation and Description:
Representation and description almost always follow
the output of a segmentation stage, which usually is raw pixel data,
constituting either the boundary of a region or all the points in the region
itself. Choosing a representation is only part of the solution for transforming
raw data into a form suitable for subsequent computer
processing. Description deals with extracting attributes that result
in some quantitative information of interest or are basic for differentiating
one class of objects from another.
(x) Object recognition:
Recognition is the process that assigns a label, such
as, “vehicle” to an object based on its descriptors.
(xi) Knowledge Base:
Knowledge may be as simple as detailing regions of an image
where the information of interest is known to be located, thus limiting the
search that has to be conducted in seeking that information. The knowledge base
also can be quite complex, such as an interrelated list of all major possible
defects in a materials inspection problem or an image database containing
high-resolution satellite images of a region in connection with
PART-1 TO CALCULATE ENTROPY OF AN IMAGE.
Image entropy is a quantity which is used to describe the `business’ of
an image, i.e. the amount of information which must be coded for by a
compression algorithm. Low entropy images, such as those containing a lot of
black sky, have very little contrast and large runs of pixels with the same or
similar DN values. An image that is perfectly flat will have entropy of zero.
Consequently, they can be compressed to a relatively small size. On the other
hand, high entropy images such as an image of heavily cratered areas on the
moon have a great deal of contrast from one pixel to the next and consequently
cannot be compressed as much as low entropy images.
Step 1: Read the image into the workspace.
Step 2: Show the grayscale image.
Step 3: Determine the height and width of image.
Step 4: Calculate the normalized histogram counts returned from inhist and
store the sum in ‘sum’.
Step 5: Label x and y axes as ‘Pixel Value’
and ‘Relative Count’ respectively.
Step 6: Calculate entropy using -sum(p.*log2(p)) where p contains the normalized histogram counts returned from inhist.Step 7: Print the value of entropy. FLOWCHART:
function H = entropy(x)figure,imshow(x)Height, Width=size(x);m,Binsx=inhist(x);m=m/(Height*Width);sprintf(‘sum of histogram=%g’,sum(m));figure,plot(Binsx,m,’k’)xlabel(‘Pixelvalue’),ylabel(‘relativecount’)H=sum(-m.*log2(m+le-10));sprintf(‘the entropy of the image is=%g’,H)
the image given below into workplace and applying the above source code,
entropy can be calculated as follows:
Entropy of above image is 6.6586
Entropy is a statistical measure of randomness that can be
used to characterize the texture of the input image. The following image has
less entropy due to less randomness or disorder in it.
Entropy of above image is 4.5049
STEGANOGRAPHY- To hide the given message in an image for secure transmission of
Image Steganography hides
message in the images. This technique is the most popular because of the fact
that almost no perceivable changes occur in images after hiding a
large amount of data with wide variety of available images.
One of the popular and
oldest techniques used to hide message in digital image is to hide it in the
least significant bit (LSB) of pixel value. LSB (Least
Significant Bit) substitution is the process of adjusting the least
significant bit pixels of the carrier image. It is a simple approach for
embedding message into the image. The Least Significant Bit insertion varies
according to number of bits in an image. For an 8 bit image, the least
significant bit i.e., the 8th bit of each byte of the image is changed to the
bit of secret message.
to embed the text message:-
Step 1: Read the cover image and the text
message which is to be hidden in the cover image.
Step 2: Convert the
text message in binary format.
Step 3: Calculate the LSB of each pixel of the
Step 4: Replace the
cover image of the LSB with each bit of secret message one by one.
Step 5: Save and show
the stego image.
to retrieve text message:-
Step 1: Read the stego image.
Step 2: Calculate LSB
of each pixels of stego image.
Step 3: Retrieve bits and convert each 8 bit
Step 4: Display the
For Hiding The Data(Encoding Process)-
c = imread(‘download.bmp’); %read the cover image
figure, imshow(c) % shows the cover image
message = ‘MATLABPROJECT’;
%message to be hide
strtrim(message); %removes whitespace characters
length(message) * 8; %convert length
of message into bits
uint8(message); %gives ascii codes of unsigned 8-bit integers
transpose(dec2bin(AsciiCode,8)); %create binary matrix with 8 rows and 13
binaryString(:); %create a column vector with binary values
b = zeros(N,1);
%column vector with value 0 of n rows
for k = 1:N
end % loop to create b=binartystring
s = c; %store c in s
size(c,1); %no. Of rows of c
size(c,2); %no. Of columns of c
k = 1;
for i = 1 :
for j = 1 :
mod(double(c(i,j)), 2); %LSB value= 0 or 1
(k>m || LSB == b(k))
(c(i,j) – 1);
(c(i,j) + 1);
k = k + 1;
end %loop to store message in LSB of
%saves the stego image
imshow(‘hiddenmsgimage.bmp’) %shows the stego image
for Retrieving The Data(Decoding Process)-
s = imread(‘hiddenmsgimage.bmp’); %reads the
= size(s,1); %defines the constants height and width
= double( s(1:1:1) ) * 8 ; %converts into * bit matrix
k = 1;
for i = 1 : height
= 1 : width
(k <= m) b(k) = mod(double(s(i,j)),2); k = k + 1; end end end %creates a matrix b containing the secret msg in binary form binaryVector = b; binValues = 128 64 32 16 8 4 2 1 ;%creates a matrix containing bin values binaryVector = binaryVector(:); %converts binaryvector into a single column if mod(length(binaryVector),8) ~= 0 % binary matrix must a mutiple of 8 error('Length of binary vector must be a multiple of 8.'); end binMatrix = reshape(binaryVector,8,);% if not , it converts the matrix into multiple of 8 by filling zeros in it textString = char(binValues*binMatrix);%converts the binary matrix formed out of b into characters. disp(textString);% displays the output OUTPUTS: ENCODING 1. Cover Image (Without secret message) 2. Stego Image (With secret message) DECODING OUTPUT: Digital Image Processing RESULTS AND DISCUSSION: • An image that is perfectly flat will have entropy of zero. Consequently, they can be compressed to a relatively small size. On the other hand, high entropy images such as an image of heavily cratered areas on the moon have a great deal of contrast from one pixel to the next and consequently cannot be compressed as much as low entropy images. • In this project we mainly concentrated on embedding the data into an image. We have designed the steganographic application which embedded the data into the image. • Normally, after embedding the data into the image, the image may lose its resolution. In the proposed approach, the image remains unchanged in its resolution as well in size. • The speed of embedding the data into the image is also high in the proposed approach such that the image is protected and the data to the destination is sent securely. • There are many steganographic algorithms available like JSteg, F5 and LSB algorithms. We have used the Least Significant Bit algorithm in designing the steganographic application because LSB algorithm works efficiently when we consider bit map images .bmp files. The speed of embedding is also high when using LSB compared to the JSteg algorithm. CONCLUSION: The Paper gives the review of calculating entropy of a grayscale image and also discusses basic working of Image Steganography. The enhanced LSB technique described in this report helps to successfully hide the secret data into the cover file with minimum distortion made to the cover file. MATLAB function is an easy to use, user interface function that guides a user through the process of either encoding & decoding a message into or from the image respectively. Since LSB doesn't contain any information there is no loss of information and secret image recovering back become undistorted. REFERENCES: • Amirthanjan,R. Akila,R & Deepika chowdavarapu, P., 2010. A Comparative Analysis of Image Steganography, International Journal of Computer Application. • Bandyopadhyay, S.K., 2010. An Alternative Approach of Steganography Using Reference Image. International Journal of Advancements in Technology. • http://www.onlineclassnotes.com/2011/10/describe-fundamental-steps-of-digital.html : Fundamental Steps of Image Processing. • Obaida Mohammad Awad Al-Hazaimeh Hiding Data in Images Using New Random Technique Department of Information Technology, AL-BALQA Applied University/Al-Huson University College, Irbid, Al-Huson, 50, Jordan. • https://in.mathworks.com/help/images/ref/entropy.html : Entropy of an image. • Cox, I. Miller, M. Bloom, J. Fridrich, J & Kalker, T. 2008. Digital watermarking and Steganography.2ndEd. Elsevier.