DIGITALIMAGE PROCESSING USING MATLABEntropy of an image and imagesteganography ABSTRACT:In this reviewpaper, at first we have introduced initial contexts of image processing whichare essential to know before entering main domain of image processing science. Afterthat, fundamental steps in image processing are mentioned. The name MATLABstands for matrix laboratory. MATLAB is an interactive system whose basic dataelement is an array that does not require dimensioning.
This allows formulatingsolutions of many technical computing problems, especially those involvingmatrix representations. It takes a fraction of time to write a program in ascalar non interactive language such as C or FORTRAN. It is very easy tocalculate entropy of an image and perform image steganography using this tool. ImageSteganography hides message in the images. This technique is the most popularbecause of the fact that almost no perceivable changes occur in images afterhiding a large amount of data with wide variety of available images. INTRODUCTION:Digital image processing deals with manipulation of digital imagesthrough a digital computer. It is a subfield of signals and systems but focusparticularly on images. DIP focuses on developing a computer system that isable to perform processing on an image.
The input of that system is a digitalimage and the system process that image using efficient algorithms, and givesan image as an output. The most common example is Adobe Photoshop. It is one ofthe widely used applications for processing digital images.What is an Image?An image is nothing more than a two dimensional signal. It isdefined by the mathematical function f(x,y) where x and y are the twoco-ordinates horizontally and vertically. The value of f(x,y) at any point isgives the pixel value at that point of an image.
Every digital image processingsystem 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 befurther processed based on the need. But the application of the processingmethod or algorithm depends on how the image is inputted, and stored.
Thequality of the processed image also depends on many criterions.In this paper, we review aboutdigital image processing to calculate entropy of a grayscale image and toimplement 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 belowwith a neat diagram. (i) Image Acquisition: This is the first step or process of the fundamental steps ofdigital image processing.
Image acquisition could be as simple as beinggiven an image that is already in digital form. Generally, the imageacquisition stage involves preprocessing, such as scaling etc. (ii) Image Enhancement: Image enhancement is among the simplest and most appealingareas of digital image processing. Basically, the idea behind enhancement techniquesis to bring out detail that is obscured, or simply to highlight certain featuresof interest in an image such as, changing brightness & contrast etc.
(iii) Image Restoration: Image restoration is an area that also deals withimproving the appearance of an image. However, unlike enhancement, which issubjective, image restoration is objective, in the sense that restorationtechniques tend to be based on mathematical or probabilistic models of imagedegradation. (iv) Color Image Processing: Color image processing is an area that has been gaining itsimportance because of the significant increase in the use of digital imagesover the Internet. This may include color modeling and processing in a digitaldomain etc. (v) Wavelets and Multi-resolution Processing: Wavelets are the foundation for representing images invarious degrees of resolution. Images subdivide successively into smallerregions for data compression and for pyramidal representation.
(vi) Compression: Compression deals with techniques for reducing the storagerequired to save an image or the bandwidth to transmit it. Particularly in theuses of internet it is very much necessary to compress data. (vii) Morphological Processing: Morphological processing deals with tools for extractingimage components that are useful in the representation and description ofshape. (viii) Segmentation: Segmentation procedures partition an image into itsconstituent parts or objects.
Imagesegmentation is the process of dividing an image into multiple parts. This istypically used to identify objects or other relevant information in digitalimages. In general, autonomous segmentation is one ofthe most difficult tasks in digital image processing. A rugged segmentationprocedure brings the process a long way toward successful solution of imagingproblems that require objects to be identified individually. (ix) Representation and Description: Representation and description almost always followthe output of a segmentation stage, which usually is raw pixel data,constituting either the boundary of a region or all the points in the regionitself. Choosing a representation is only part of the solution for transformingraw data into a form suitable for subsequent computerprocessing.
Description deals with extracting attributes that resultin some quantitative information of interest or are basic for differentiatingone class of objects from another.(x) Object recognition: Recognition is the process that assigns a label, suchas, “vehicle” to an object based on its descriptors. (xi) Knowledge Base: Knowledge may be as simple as detailing regions of an imagewhere the information of interest is known to be located, thus limiting thesearch that has to be conducted in seeking that information. The knowledge basealso can be quite complex, such as an interrelated list of all major possibledefects in a materials inspection problem or an image database containinghigh-resolution satellite images of a region in connection withchange-detection applications. PART-1 TO CALCULATE ENTROPY OF AN IMAGE.
DESCRIPTION:Image entropy is a quantity which is used to describe the `business’ ofan image, i.e. the amount of information which must be coded for by acompression algorithm.
Low entropy images, such as those containing a lot ofblack sky, have very little contrast and large runs of pixels with the same orsimilar 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 otherhand, high entropy images such as an image of heavily cratered areas on themoon have a great deal of contrast from one pixel to the next and consequentlycannot be compressed as much as low entropy images.ALGORITHM: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 andstore 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: SOURCE CODE: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) OUTPUTS:• Readingthe image given below into workplace and applying the above source code,entropy can be calculated as follows: Result:Entropy of above image is 6.6586 • Entropy is a statistical measure of randomness that can beused to characterize the texture of the input image. The following image hasless entropy due to less randomness or disorder in it. Result:Entropy of above image is 4.5049 PART-2 IMAGESTEGANOGRAPHY- To hide the given message in an image for secure transmission ofthe data.
DESCRIPTION:Image Steganography hidesmessage in the images. This technique is the most popular because of the factthat almost no perceivable changes occur in images after hiding alarge amount of data with wide variety of available images. One of the popular andoldest techniques used to hide message in digital image is to hide it in theleast significant bit (LSB) of pixel value. LSB (LeastSignificant Bit) substitution is the process of adjusting the leastsignificant bit pixels of the carrier image. It is a simple approach forembedding message into the image.
The Least Significant Bit insertion variesaccording to number of bits in an image. For an 8 bit image, the leastsignificant bit i.e., the 8th bit of each byte of the image is changed to thebit of secret message. ALGORITHM: Algorithmto embed the text message:- Step 1: Read the cover image and the textmessage which is to be hidden in the cover image.
Step 2: Convert thetext message in binary format. Step 3: Calculate the LSB of each pixel of thecover image. Step 4: Replace thecover image of the LSB with each bit of secret message one by one. Step 5: Save and showthe stego image.Algorithmto retrieve text message:- Step 1: Read the stego image.
Step 2: Calculate LSBof each pixels of stego image. Step 3: Retrieve bits and convert each 8 bitinto character.Step 4: Display thehidden message. FLOWCHART: Cover image Stego image Secret Key Communication channel SOURCE CODE:CodeFor Hiding The Data(Encoding Process)-c = imread(‘download.bmp’); %read the cover imagefigure, imshow(c) % shows the cover image message = ‘MATLABPROJECT’;%message to be hide message =strtrim(message); %removes whitespace characters m =length(message) * 8; %convert lengthof message into bits AsciiCode =uint8(message); %gives ascii codes of unsigned 8-bit integers binaryString =transpose(dec2bin(AsciiCode,8)); %create binary matrix with 8 rows and 13columns binaryString =binaryString(:); %create a column vector with binary values N =length(binaryString); b = zeros(N,1);%column vector with value 0 of n rows for k = 1:N if(binaryString(k)== ‘1’) b(k) =1; else b(k) =0; end end % loop to create b=binartystring s = c; %store c in s height =size(c,1); %no. Of rows of c width =size(c,2); %no. Of columns of c k = 1; for i = 1 :height for j = 1 :width LSB =mod(double(c(i,j)), 2); %LSB value= 0 or 1 if(k>m || LSB == b(k)) s(i,j) =c(i,j); elseif(LSB ==1) s(i,j) =(c(i,j) – 1); elseif(LSB ==0) s(i,j) =(c(i,j) + 1); end k = k + 1; end end %loop to store message in LSB ofpixels imwrite(s, ‘hiddenmsgimage.bmp’);%saves the stego image imshow(‘hiddenmsgimage.
bmp’) %shows the stego image Codefor Retrieving The Data(Decoding Process)- s = imread(‘hiddenmsgimage.bmp’); %reads thehidden file height= size(s,1); %defines the constants height and width width= size(s,2); m= double( s(1:1:1) ) * 8 ; %converts into * bit matrix k = 1;for i = 1 : height for j= 1 : width if(k <= m) b(k) = mod(double(s(i,j)),2); k = k + 1; end endend %creates a matrix b containingthe secret msg in binary formbinaryVector = b;binValues = 128 64 32 16 8 4 2 1 ;%createsa matrix containing bin valuesbinaryVector = binaryVector(:); %convertsbinaryvector into a single columnif mod(length(binaryVector),8) ~= 0 % binarymatrix must a mutiple of 8error('Length of binary vector must be amultiple of 8.');endbinMatrix = reshape(binaryVector,8,);% ifnot , it converts the matrix into multiple of 8 by filling zeros in ittextString = char(binValues*binMatrix);%convertsthe binary matrix formed out of b into characters.disp(textString);% displays the output OUTPUTS:ENCODING1.
CoverImage (Without secret message) 2. StegoImage (With secret message) DECODINGOUTPUT: DigitalImage Processing RESULTS AND DISCUSSION:• An image that is perfectly flat will have entropyof zero. Consequently, they can be compressed to a relatively small size. Onthe other hand, high entropy images such as an image of heavily cratered areason the moon have a great deal of contrast from one pixel to the next andconsequently cannot be compressed as much as low entropy images.• Inthis project we mainly concentrated on embedding the data into an image. Wehave designed the steganographic application which embedded the data into theimage. • Normally,after embedding the data into the image, the image may lose its resolution.
Inthe proposed approach, the image remains unchanged in its resolution as well insize. • Thespeed of embedding the data into the image is also high in the proposed approachsuch that the image is protected and the data to the destination is sentsecurely.• Thereare many steganographic algorithms available like JSteg, F5 and LSB algorithms.We have used the Least Significant Bit algorithm in designing thesteganographic application because LSB algorithm works efficiently when weconsider bit map images .bmp files. The speed of embedding is also high whenusing LSB compared to the JSteg algorithm. CONCLUSION:The Paper gives thereview of calculating entropy of a grayscale image and also discusses basicworking of Image Steganography.
The enhanced LSB technique described in thisreport helps to successfully hide the secret data into the cover file withminimum distortion made to the cover file. MATLAB function is an easy to use,user interface function that guides a user through the process of eitherencoding & decoding a message into or from the image respectively. SinceLSB doesn’t contain any information there is no loss of information and secretimage recovering back become undistorted. REFERENCES:• Amirthanjan,R.Akila,R & Deepika chowdavarapu, P.
, 2010. A Comparative Analysis of ImageSteganography, International Journal of Computer Application. • Bandyopadhyay,S.K., 2010. An Alternative Approach of Steganography Using Reference Image. InternationalJournal of Advancements in Technology.
html: Fundamental Steps of Image Processing.• ObaidaMohammad Awad Al-Hazaimeh Hiding Data in Images Using New Random TechniqueDepartment of Information Technology, AL-BALQA Applied University/Al-HusonUniversity 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 watermarkingand Steganography.2ndEd. Elsevier.