Pixel Replacement Technique Using Steganography Computer Science Essay

Published: Last Edited:

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

As we know, the field of cryptography has got more attention nowadays. More and more complex techniques for encrypting the information are proposed every now and then. But, as usual, when a small step is made to improve the security, more work is done in the opposite direction by the hackers to break it. Thus they are able to attack most of these algorithms and that too, successfully.

So, to deceive the hackers, people have started to follow a technique called 'Steganography'. It is not an entirely new technique and has been in the practice from ancient times. In this method, the data is hidden behind unsuspecting objects like images, audio, video etc. so that people cannot even recognize that there is a second message behind the object. Images are commonly used in this technique.

In this paper, we have proposed a technique for hiding data secretly behind images. The existing techniques for image Steganography have some serious drawbacks and we have tried to overcome those with ours. Here, the pixels in the images are replaced with the new ones, which are almost identical to the old ones, in a manner that can be used to retrieve back the hidden data.

Steganography is a term used to describe files that have other types of files secretly embedded inside. Usually, when we talk about Steganography, we mean the embedding of a text file, or a secret message, inside an image. Not only is the message itself hidden, but the fact that a message exists is hidden. It is in this way that steganography is a method of concealing the fact that communication is taking place in addition to actually concealing a file.

"The goal of Steganography is to hide messages inside other harmless messages in a way that does not allow any enemy even to detect that there is a second secret message present."

The advantage of steganography over cryptography is that messages do not attract attention to themselves. Plainly visible encrypted messages. No matter how unbreakable and will arouse suspicion, and may in themselves be incriminating in countries where encryption is illegal. Therefore, whereas cryptography protects the contents of a message, steganography can be said to protect both messages and communicating parties.


The first recorded uses of steganography can be traced back to 440 BC when Herodotus mentions two examples of steganography in The Histories of Herodotus. Demaratus sent a warning about a forthcoming attack to Greece by writing it directly on the wooden backing of a wax tablet before applying its beeswax surface. Wax tablets were in common use then as reusable writing surfaces, sometimes used for shorthand. Another ancient example is that of Histiaeus, who shaved the head of his most trusted slave and tattooed a message on it. After his hair had grown the message was hidden. The purpose was to instigate a revolt against the Persian.

But now in digital era the term steganography is used in computer communications. And provides high vulnerablity to attacks.

4. Steganographic TYPES:

4.1 Physical steganography:

Hidden messages on paper written in secret inks, under other messages or on the blank parts of other messages.

Messages written in morse code on knitting yarn and then knitted into a piece of clothing worn by a courier.

Messages written on the back of postage stamps.

4.2 Digital steganography:

Modern steganography entered the world in 1985 with the advent of the personal computer applied to classical steganography problems. Development following that was slow, but has since taken off, going by the number of 'stego' programs available: Over 725 digital steganography applications have been identified by the Steganography Analysis and Research Center. Digital steganography techniques include:

Image of a tree. Removing all but the last 2 bits of each colour component produces an almost completely black image. Making that image 85 times brighter produces the image below.

Image of a cat extracted from above image.

Concealing messages within the lowest bits of noisy images or sound files. Concealing data within encrypted data or within random data. The data to be concealed is first encrypted before being used to overwrite part of a much larger block of encrypted data or a block of random data (an unbreakable cipher like the one-time pad generate cipher texts that look perfectly random if you don't have the private key).

Chaffing and winnowing.

Mimic functions convert one file to have the statistical profile of another. This can thwart statistical methods that help brute-force attacks identify the right solution in a cipher text-only attack.

Concealed messages in tampered executable files, exploiting redundancy in the i386 instruction set.

Pictures embedded in video material (optionally played at slower or faster speed).

Injecting imperceptible delays to packets sent over the network from the keyboard.

Content-Aware Steganography hides information in the semantics a human user assigns to a datagram. These systems offer security against a non-human adversary/warden.

4.3 Blog-Steganography:

Messages are fractionalized and the (encrypted) pieces are added as comments of orphaned web-logs (or pin boards on social network platforms). In this case the selection of blogs is the symmetric key that sender and recipient are using; the carrier of the hidden message is the whole blogosphere.

4.4 Printed steganography:

Digital steganography output may be in the form of printed documents. A message, the plaintext, may be first encrypted by traditional means, producing a ciphertext. Then, an innocuous covertext is modified in some way to as to contain the ciphertext, resulting in the stegotext. For example, the letter size, spacing, typeface, or other characteristics of a covertext can be manipulated to carry the hidden message. Only a recipient who knows the technique used can recover the message and then decrypt it. Francis Bacon developed Bacon's cipher as such a technique.

5. Steganographic Techniques IN COMPUTERS:


How Steganography is done in terms of computers? There are several ways, some of which become very complicated to understand.


Least Significant Bit Steganography:

One simple method is LSB, or Least Significant Bit Steganography. An image is nothing more than strings and strings of bytes, each byte representing a different colour. The last few bits in a colour byte, however, do not hold as much significance as the first few. This is to say that two bytes that only differ in the last few bits can represent two colours that are virtually indistinguishable to the human eye. For example, 00100110 and 00100111 can be two different shades of red, but since it is only the last bit that differs between the two, it is impossible to see the colour difference. LSB Steganography, then, alters these last bits by hiding a message within them. 





Discrete Cosine Transform Steganography:

Another method of steganography involves using the DCT (Discrete Cosine Transform) coefficients in JPEG files. DCT coefficients are more frequently thought of as being used for JPEG compression, but they come into play in steganography as well. In a JPEG file, the image is made up of these coefficients, and when a file is steganographically embedded into a JPEG image, the relation of these coefficients is altered. Instead of actual bits being changed like in LSB steganography, it is the relation of the coefficients to one another that is altered, holding a secret message.

5.2 Steganalysis:

 Stegananalysis means the way a stegonagraphic image is detected. Remember, it is not just the message within the image that is being searched; it is the fact that a hidden file

exists within the image that is most important to find. Stegananalysis can sometimes (but, very rarely) be done using visual detection. Visual detection simply means using oneÕs eye to literally look at the image to see if any visible changes have occurred. Since the original image is almost never known, however, it proves difficult to compare an image with an embedded file with what it looked like beforehand. This task of simple visual detection is easier, however, if there is not a gradual change of colour in the image.


Statistical analysis is what is frequently used in steganography detection. This is done using advanced statistics techniques. Basically what is done is the colour pairs in an image are measured, meaning it is observed how close each colour in the image to its adjacent colour. These two colours, which do not differ greatly, are known as a close colour pair. In a steganographic image, the occurrence of each individual colour approaches the occurrence of its colour pair. This is to say that the individual colours become Òless differentÓ when a file is embedded into the image. The occurrences of these colours are measured using statistics.

RQP (Raw Quick Pairs) Method:

One specific technique is the RQP (Raw Quick Pairs) Method. In this method, the ratios between the close colour pairs and all colour pairs are measured in an image. Then, a message is deliberately embedded in the image and the same measurements are taken again. If there is a large difference between the two measurements, then it is unlikely a message has been embedded in the original.


Observe the following two images [FIGURE 2]. The one on the left is the original image, and the one on the right is the same image with a text file embedded in it. The change is easy to detect visually, since the colour changes in the original image are not gradual. When there is a noticeable contrast between the colours, it becomes easier to detect an embedded file.






Extremely liable to attacks like Image Manipulation techniques where the pixels will be scanned for a possible relation which will be used to trace out the actual characters.

Only 24 bit messages are suitable and 8 bit images are to be used at great risk.

Extreme Care needs to be taken in the selection of the cover image, so that changes to the data will not be visible in the stego-image.

Commonly known images, such as famous paintings must be avoided.


Because of the drawbacks in the currently followed techniques, we propose a new technique for hiding data in images. Here, we replace the existing pixels in the image with the new ones in such a way that no difference is visible between the steganographed and the original image.



The Algorithm used for encoding in this technique can be described with the

following steps.

1. Get the Image, Message to be hidden and the Password.

2. Encrypt the message and the password.

3. Move some rows below the first row in the image and fix a reference position near the left edge for odd characters and near the right for even characters.

4. For each character in the original data do find a position corresponding to that character search the surrounding pixels and find a pixel value closer to all of them replace the current pixel and the reference pixel with this value move to the next row.

5. Set a pixel value as a threshold.

6. Repeat steps 4 and 5 for the Password from the bottom of the image.


The Algorithm for retrieving the original message from the steganographed image follows this sequence.

1. Get the Image and the Password.

2. Move to the bottom row in the image where password hiding starts.

3. Find the value of the reference pixel.

4. Search the entire row for the same pixel value.

5. Find the position of that pixel and decode the character.

6. Repeat steps 3 thro 5 till the threshold is reached.

7. Concatenate all the characters found so far (Actual Password).

8. If the found password does not match the given password go to step 11.

9. Move to the top row in which the first character of original data was stored.

10. Repeat the sequence followed in steps 3 to 7 to get the original message.

11. Display the result.


With the algorithm described in brief, let us describe the pixel replacement technique in detail. First, we shall see how the original message and the password are hidden into the image and then we'll discuss how to retrieve message for the authorized person who knows the correct password.

STEP 1: Encrypting the Message & Password:

First, the original message and the password are got from the user. Then, they are encrypted using any of the encryption algorithms like RSA, DES etc. This encryption step is an additional safety feature added to the technique to ensure maximum safety. Then, this encrypted message is fed as the input to the next step.

STEP 2: Choosing a position to hide the character:

The actual process of Steganography starts here. The Image is scanned from the top row - wise. First few rows are omitted and a suitable row is reached. The message is

split into individual characters. The following process is repeated for all the characters in the message. A position for hiding the character is chosen according to some relation with that character. The relation can be something like the ASCII value of the character, the order of occurrence of that character in the Alphabetical or Reverse order if it is an alphabet etc.

For example, the position of the character 'R' can be chosen as: ASCII Value of 'R' = 82,

So, position = 82 - 50 = 32.

(Only e.g. any value instead of 50 can be used)

STEP 3: Finding a Suitable Colour:

Once a position is chosen, the values of all the pixels surrounding the pixel in that position are found. Since this position is usually not near the edge of the image, there will be 8 pixels surrounding it. A pixel value, i.e., a colour, is chosen so that it does not differ much from those of the 8 pixels. This is the most difficult step in the whole process. The value will differ only by a small value. Such a small change in the colour will be indiscernible to the users.

STEP 4: Replacing the pixels:

Now, with the colour to be replaced being found, it's time to replace the pixels with the new colour. A position near to the left side of the row is fixed as the reference position for the odd numbered character i.e., the 1st, 3rd, 5th character and so on. Similarly, for the even numbered characters, a position close to the right side of the row is selected as the reference position. These reference positions are the same for all the characters. When the reference position is chosen, the pixel in that position is replaced with the new colour . Then, the pixel in the already found position for the character (in our e.g., this is 32) is also replaced with the new colour.


Let us consider a sample image whose pixels are replaced in this way. This can be explained by the following figure:

For the sake of explanation, the pixels are shown clearly in this figure. But, in real situations, these will not be visible at all because the COLOUR chosen for replacing is so close to the original COLOUR that cannot be found by the human eye but still can be found out by the computer. The above mentioned steps of finding a suitable COLOUR and replacing the pixels is continued for all the characters in the encrypted message.

STEP 5: Setting a Threshold:

The final step in hiding the message is to set a threshold pixel in a fixed position to indicate the end of the encrypted message. This is essential for decoding the message from the image. Otherwise, we cannot find the end of the message.

STEP 6: Hiding the Password:

The same steps of choosing the COLOUR, replacing the pixels and setting a threshold are repeated for hiding the password but the only difference is that the image is scanned row - wise from the last row instead of from the first row.

STEP 7: Retrieving the Message:

The process of retrieving the original message from the steganographed image is similar to that of the hiding process except in the reverse order. First, the password is got from the user. The image is scanned from the last row and the row in which the password hiding started is reached. The reference pixel value is found and the position of that COLOUR in that row is noted. Then, again the relation used previously for finding the position is used to get the original character. This can be explained as:

If the position is 32, then

32 + 50 = 82,

The character of ASCII value 82 is 'R'.

Similarly, the other characters are found till the threshold is reached and all of them are concatenated to get the original password. Now, the given password and the original are checked and if they match, then further processes are done, otherwise, an error message is displayed.

If the password matches, then the image is scanned from the top and the starting row from where the data hiding started is reached. The same steps of finding the reference pixel and the position of the other pixel are repeated again till the threshold . Then, all the characters are joined and the original message is displayed.


Cost of cracking the hidden message is extremely high.

The data cannot be easily decoded without the key using Image Manipulation techniques.

Any type of image, 8 or 24 bits can be used.

There is no increase in the size of the image due to data in it.

There are no constraints on the choice of the image.

10. Future of Steganography:

  Steganography is still a fairly new idea. There are constant advancements in the computer field, suggesting advancements in the field of steganography as well. It is likely that there will soon be more efficient and more advanced techniques for steganalysis. A hopeful advancement is the improved sensitivity to small messages. Knowing how difficult it is to detect the presence of a fairly large text file within an image, imagine how difficult it is to detect even one or two sentences embedded in an image! It is like finding a microscopic needle in the ultimate haystack. What is scary is that such a small file of only one or two sentences may be all that is needed to commence a terrorist attack. In the future, it is hoped that the technique of steganalysis will advance such that it will become much easier to detect even small messages within an image.


To overcome the drawbacks in the existing cryptography and Steganography

Techniques, we have proposed a new technique for hiding data in images. This technique is less prone to attacks and since the data is strongly encrypted and the cost of retrieving it by unauthorized persons is extremely high. Since the pixels are replaced with almost identical pixels, it is difficult even to identify that there is a second message hidden. So, we hope that this technique will be used widely in the future.