A New Algorithm for Embedding Message in Image Steganography

DOI : 10.17577/IJERTV3IS20751

Download Full-Text PDF Cite this Publication

Text Only Version

A New Algorithm for Embedding Message in Image Steganography

Mohammad Ali Shamalizadeh Baei (PhD student),

Zeynolabedi Norozi

Faculty of Security and Cryptography Imam Hossein University

Tehran, Iran

Mohammad Reza Karami Mollaei Faculty of Electronic and Computer Babol University of Technology, Babol, Iran

Abstract Steganography is the art of hiding information and an effort to conceal the existence of the embedded information. Paying no attention to file formats, image steganography is discussed in this paper. Least Significant Bit (LSB) insertion is a common, simple approach to embedding information in a cover image, but image manipulation such as noise, filtering, compressionetc, can destroy the hidden information in this image. The focus of this paper is designing a new algorithm for embedding message bites in an image file with more robustness against the external influences and more security. In this paper instead of using the first least significant bit or LSB of the cover image pixels for embedding the message bit, second least significant bit has been used to increase the robustness and SIHS1 method is applied to produce more secured system that we call it RSIHS2 technique.

Keywords Image Steganography, LSB2, SIHS, RSIHS


    Since the rise of the internet, one of the most important factors of information technology communication has been the security of information. Cryptography was created as a technique for securing the secrecy of communication and many different methods have been developed to encrypt and decrypt data in order to keep the message secret. Unfortunately it is sometimes not enough to keep the contents of a message secret, it may also be necessary to keep existence of the message secret. The technique used to implement this is called Steganography. Steganography is the art and science of invisible communication. Throughout history, Steganography has been used to secretly communicate information between people. Steganography plays an important role in information security [1, 2]. Steganography is a technology that hides a message within an object. Todays steganographic systems uses multimedia objects like image, audio, video etc., as cover media because people often transmit digital pictures over email and other Internet communication [3]. In modern approach, depending on the nature of cover object, Steganography can be divided into five types, Audio, Video, Text, Image and Protocol steganography.(See figure 1)An image is an array of M*N matrix. Each pixel has a numerical value which represents the color and light intensity of the pixel [4]. Images are more popular cover files for

    1 Secure Information Hiding System

    2 Robustness Secure Information Hiding System

    transmission over the internet due to harmlessness and attraction. In image steganography, data is to be inserted into the cover image that gives the resultant stego-image [5]. A possible formula of the process may be represented as:

    Cover image + embedded message + stego key = stego image (See figure 2)

    There are various image steganographic [6], techniques:

    1. Spatial domain technique.

    2. Masking and filtering.

    3. Transform techniques.

    Spatial domain technique embeds the message directly in the intensity of the pixels. If message bit is embedded in least significant bit of each image pixel is called LSB or technique. A. E. Mustafa and et al, [7], for first time proposed an algorithm for embedding message bits in cover image pixels that called SIHS technique. In this method some of message bits are embedded in second least significant bite of cover image pixels. Jassim Mohammed Ahmed and

    ZulkarnainMd Ali, [8], by using LSB1 technique, a stego-key and a random number generator, presented a secure system that is called LSB2 technique. In this paper we suggest a new method of embedding message bites, by improvement of technique and use of SHIS technique with considering robustness and security that we call RSIHS it technique.


    Least significant bit (LSB) insertion is a common and simple approach to embedding message bits in cover image pixels.

    This technique works well for image steganography.

    A. Algorithm of LSB1

    Algorithm to embed text message using Grayscale Image Step1: Read the cover image and text message, which is to be hidden in the cover image.

    Step 2: Convert text message into binary.

    Step 3: Calculate LSB1 of cover image pixels.

    Step 4: Replace LSB1 of cover image pixels with each bit of secret message one by one.

    Step 5: Write stego image.

    Note that, on average, only half the LSB1 need to change. The difference between the cover (i.e. original) image and the stego image will be hardly noticeable to the human eye. Because the change on light intensity of each cover image pixel happens 0 or ±1 unit.


    As the LSB1 technique is used to hide the messages in images. However, it is decided to enhance the security system by introducing a new technique comprises of randomly dispersing the message bits in images. It is proposed in this enhancement that the embedding of message bits into the image is not only in the least significant bit but also the other bits in the pixel in the random manner. This can be achieved by comparing the message bit to the pixel bit randomly chosen from second to the last bit, r, which we produce with discrete logarithm algorithm or other technique. Based on this comparison, 1 is inserted in the least significant bit if the message bit identical to that of the image, whereas, 0 is inserted if the message bit didnt match with the chosen bit from the image(see figure 3) We see that this algorithm uses LSB1 for embedding message bits but because of using random technique for coding original

    message bits it has more secure than LSB1.

    A. Discrete logarithm algorithm and random numbers

    Discrete Logarithm calculation can be used to solve the sequence-mapping problem. The main idea here is to generate a series of random numbers of length equal to the message length, N, that ranging from 3 to 8. These series Numbers will be used in random-mapping. We defined discrete logarithm to produce random numbers. These numbers depend on the value of key (k). The values are computed from the following equation, and these numbers will be limited to the length of the message: x_i=a*x (i-1) (mod p) (1), i=1,,m.


    x0= is the sum of k digits. a=3×0


    The numbers created from the above equation is then used to generate another numbers ranging from 3 to 8.The latter are used to locate the image bit (in the pixel) that will be used in the comparison with the message bit, as

    Expressed as follow:

    Recovering a message from a steg-image demands the corresponding decoding key, k that used during the encoding process. Hence, both the sender and receiver have to share the stego-key during the communication. The k key is then used for selecting the positions of the pixel where the secret bits had been embedded. For example consider message bits and cover image in figure4 and random numbers is generated with a secret key, k, and discrete logarithm algorithm.


    This technique is an enhancement of LSB1 algorithm. In this method, some of message bites are embedded in the second least significant bites of the cover image pixels to increase the robustness of the system and protect the message against the exteral influences such as noise, filter, compressionetc.

    1. Algorithm of LSB2

      Algorithm to embed text message using Grayscale Image is as follows:

      Step1:Extract bit set of message. Bit={M1,M2,,MN}

      Step 2: The pixels of cover image. Pixel ={Pixel1,Pixel2,,PixelN}

      Step3:Extract LSB1 set of the cover image. LSB1={A1,A2,,AN}

      Step 4: Extract LSB2 set of the cover image. LSB2={B1,B2,,BN}

      Step 5:

      For i =1 to message length do


      If (Mi == Bi) Then

      do nothing



      If (Mi = = 1 and Bi = = 0) Then


      Bi = Mi; Ai=0;



      Else If (Mi = = 0 and Bi = = 1)Then


      Bi = Mi; Ai=1;

      pixeli=Pixeli +1;


      1. Embedding algorithm(RSIHS algorithm)

    In this method, a N=h×w gray scale image has been used as a cover. So, we can hide a message up to bits. We suggest the following embedding algorithm:

    Step 1: Extract Bit set of Message. Bit={M1,M2,,MN}

    Step2:The Pixels of cover image. Pixel ={Pixel1,Pixel2,,PixelN}


    To apply this algorithm, consider that we have to hide the message bites 10000001 in a cover image that its primary pixels are shown in Table1. By using above algorithm and record result in Table1, we see that the LSB2 technique embeds some of message bits in second least significant bit of cover image pixels to increase robustness.


    The LSB1 is the simplest and most straight forward approach to embed or hide a message into a cover image and hides the message in a way that the humans do not distinguish it. On the other hand embedded message based on LSB1technique easily destroy with a noise or operation so compression and etc. Therefore, there is a need to enhance theLSB1. Thats obvious that SIHS method is based on LSB1 technique. So here we design a new technique of embedding message based on LSB2 and SIHS which I call such a mechanism RSIHS. In this method we suggest an algorithm that embeds all of the message bits after coding with SIHS technique into second least significant bits of cover image pixel, so that the change on light intensity of each cover image pixel happens 0 or ±1 unit.

    Step3: Extract LSB1 set of the cover image. LSB1= {A1,A2,,AN}.

    Step4: Extract LSB2 set of the cover image. LSB2= {B1,B2,,BN}.

    Step5: for i=1 to message length do


    Generate a random integer number, pi, with discrete logarithm algorithm. (3pi=r8)

    If (rth bit of pixeli == Mi) then Mi=1; Else Mi=0;

    if (Bi== Mi ) Then do nothing

    Else If (Mi==0 and Bi==1)


    If (Ai=0)

    { Bi= 0; Ai=1; }

    Else If (Ai=1) { If (Ci=0)

    {Ci= 1; Bi =Ai=0 ;}

    Else If (Di=0)

    {Di= 1; Ci=Bi =Ai=0 ;}

    Else If (Ei=0)

    {Ei=1; Di= Ci=Bi=Ai=0 ;}

    Else If (Fi=0)

    {Fi=1; Ei= Di= Ci=Bi=Ai=0 ; }

    Else If (Gi=0) { Gi=1; Fi=Ei =Di=Ci=Bi=Ai=0 ;} Else If (H_i=0)

    {H_i=1 ; Gi = Fi =Ei =Di=Ci=Bi=Ai=0 ;}



    Else If (Mi==1 and Bi==0)


    If (Ai=1){ Bi= 1; Ai==0; }

    Else If (Ai=0){ If (Ci=1)

    {Ci= 0; Bi=Ai=1 ;}

    Else If (Di=1)

    {Di=0; Ci= Bi=Ai=1;}

    Else If (Ei=1)

    {Ei=0; Di=Ci= Bi=Ai=1;}

    Else If (Fi=1) { Fi=0; Ei =Di=Ci=Bi=Ai=1 =1 ;}

    Else If (Gi=1) { Gi =0; Fi=Ei =Di=Ci=Bi=Ai=1;} Else If (Hi=1){Hi=0 ;Gi=Fi=Ei =Di=Ci=Bi=Ai=1 ;}




    To apply this algorithm, again consider same data in table 1, namely, message bites 10000001 for embedding into a cover image that its primary light intensity pixels are shown in table 1. By using this algorithm and record results in table2.We have:

    Table2 Shows that RSIHS technique embeds all of the message bits into second least significant bit of cover image pixels and changes light intensity of each cover image pixels like LSB1 as much as 0 or ±1 unit. So this technique must be robustness of others.


    Experimental results evaluate the performance by hiding the data in LSB1, LSB2, SHIS and RSHIS method in gray scale image using MATLAB. Various performance parameters like SNR, PSNR and MSE have been used to evaluate the performance. The experiment has been taken out on figures 4,5 and 6 by embedding a message which includes ASCII characters. Table3 shows SNR, PSNR and MSE of each method for every algorithm.


In this paper we have presented an enhancement of the image steganography system using LSB approach to provide a more robustness and secure communication. In our proposed approach, all of the message bits are embedded randomly, by discrete logarithm algorithm, into the second least significant bit of cover-image pixels instead of first least significant bit. So the enhanced LSB technique namely RSISH algorithm, described in this paper helps us to successfully hide the secret data into the cover file with minimum distortion made to the cover file. Experimental results of the modified method (see Table.3.) show that, for this more robustness and secure method, SNR, MSE and PSNR are close to the other conventional method of LSB replacement or SIHS technique.


  1. Mei-Yi, W., Yu-Kun, H., Jia-Hong. L. An iterative method of palette- based image steganography,Journal of pattern recognition letters, 2004, Issue 3, Vole (25), pp.301-309.

  2. Arvind Kumar, Km. Pooja. Steganography: A data hiding technique, International journal of computer applications, 2010, Vole (9), No.7, pp. 19-23.

  3. Cole, Eric. Hiding in plain Sight: Steganography and the art of covert communication, Wiley, 2003, Indianapolis.

  4. Gonzales, R. C., and R.E. Woods, Digital image processing, Prentice Hall, Inc., New Jersey, 2nd, edition, 2002.

  5. Jagvinderkaur and sanjeevkumar. Study and analysis of various image steganography techniques, International journal of computer science and technology, 2011, Issue3, Vole (2), ISSN:2229- 4333(Print)|ISSN:0976- 491(Online).

  6. Kavehahmadi. A new method for image security and data hiding in image, American Journal of Scientific Research, 2011, ISSN:1450- 223X, Issue 38, pp. 41-49.

  7. A.E.Mustafa, A.M.F.ElGamal, M.E.ElAlmi and Ahmed.BD. A proposed algorithm for steganography in digital image based on least significant bit,Research journal specific education faculty of specific education, Mansoura University, 2011, Issue No. 21, pp. 751-766.

  8. Jassim Mohammed Ahmed and ZulkarnainMd Ali. Information hiding using LSB technique, International journal of computer science and network security, 2011, Vole (11), No.4, pp. 18-25.

Leave a Reply