Steganography In Images Using Pixel Replacement Technique Computer Science Essay


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

In this age of universal electronic connectivity, of viruses and hackers, of electronic eavesdropping and electronic fraud, there is indeed no time at which security of information does not matter. The explosive growth of computer systems and their interconnections via networks has increased the dependency on the information stored and communication using these systems. This has led to a heightened awareness of the need to protect the data transmitted.

Thus the field of cryptography has got more attention nowadays. More and more complex techniques for encrypting the information are proposed every now and then. Some advanced encryption algorithms like RSA, DES; AES etc. which are extremely hard to crack have been developed. 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. Even complex algorithms like RSA are no exception to this.

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. We have implemented this technique practically and found the results satisfying.

In today's world of increased security concern in the Internet due to hacking, strong cryptography techniques are required. But, unfortunately, most of the cryptography techniques have become vulnerable to attack by the snoopers. This applies to some of the advanced encryption methods too. So, the need of the hour is to find new methods for keeping the information secret. One such method commonly proposed nowadays is 'Steganography'.

1 Steganography Defined

Steganography is the art and science of communicating in a way which hides the existence of the communication. In contrast to cryptography, where the "enemy" is allowed to detect, intercept and modify messages without being able to violate certain security premises guaranteed by a cryptosystem, " the goal of steganography is to hide messages inside other harmless messages in a way that does not allow any enemy to even detect that there is a second secret message present."

2 Steganography In Images

In essence, image steganography is about exploiting the limited powers of the human visual system. Within reason, any plain text, ciphertext, other images, or anything that can be embedded in a bit stream can be hidden in an image. The common methods followed for hiding data in images are the 'Least Significant Bit (LSB) Insertion' technique in which the LSB of the pixel values are replaced with the data to be encoded in binary form, the 'Masking Technique' in which the original bits are masked with data bits and the 'Filtering Technique' in which certain transformations are done on the image to hide data. The last two techniques hide data by marking an image in a manner similar to paper watermarks But, there are some drawbacks with these methods which hinders their use.

3 Drawbacks In The Current Techniques

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.

4 The Pixel Replacement Techniuque

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


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

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

Encrypt the message and the password.

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.

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

Set a pixel value as a threshold.

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:

Get the Image and the Password.

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

Find the value of the reference pixel.

Search the entire row for the same pixel value.

Find the position of that pixel and decode the character.

Repeat steps 3 thro 5 till the threshold is reached.

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

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

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

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

Display the result.


The flow diagram of our propsed system may be shown as:



6 Implementation

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.

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.

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 occurence 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 eg. any value instead of 50 can be used)

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.

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 eg., 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.fig(1)

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.

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.

Hiding the Password

The same steps of chosing 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.

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 diaplayed.

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.

7 Practical Implementation

We have completed a project using this pixel replacement technique using Visual Basic 6.0. Various types of images like JPEG, BMP, GIF etc are used as source image and the results are noted. The results are promising. Let us see one of the results here which uses a BMP image:

An illustration of the Pixel Replacement technique

realized using Visual Basic

*****Original Image*****

***Contaminated Image***

As seen from this example, there are no big changes visible between the actual image and the one in which data is hidden. Thus, our proposed technique can be an useful one for hiding messages in images.

8 Advantages Of Our Technique

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.

Wrapping Up

To overcome the drawbacks in the existing cryptography and steganography techniques, we have proposed a new technique for hiding data in images. Our technique is less prone to attacks and since the data is strongly encrypted and the cost of retrieving it by unauthorized persons is extremly high. Since the pixels are replaced with almost identical pixels, it is difficult to even identify that there is a second message hidden. So, we hope that our technique will be used widely in the future.


Image Before (b) Image After

Replacement Replacement

Writing Services

Essay Writing

Find out how the very best essay writing service can help you accomplish more and achieve higher marks today.

Assignment Writing Service

From complicated assignments to tricky tasks, our experts can tackle virtually any question thrown at them.

Dissertation Writing Service

A dissertation (also known as a thesis or research project) is probably the most important piece of work for any student! From full dissertations to individual chapters, we’re on hand to support you.

Coursework Writing Service

Our expert qualified writers can help you get your coursework right first time, every time.

Dissertation Proposal Service

The first step to completing a dissertation is to create a proposal that talks about what you wish to do. Our experts can design suitable methodologies - perfect to help you get started with a dissertation.

Report Writing

Reports for any audience. Perfectly structured, professionally written, and tailored to suit your exact requirements.

Essay Skeleton Answer Service

If you’re just looking for some help to get started on an essay, our outline service provides you with a perfect essay plan.

Marking & Proofreading Service

Not sure if your work is hitting the mark? Struggling to get feedback from your lecturer? Our premium marking service was created just for you - get the feedback you deserve now.

Exam Revision

Exams can be one of the most stressful experiences you’ll ever have! Revision is key, and we’re here to help. With custom created revision notes and exam answers, you’ll never feel underprepared again.