Take the 2-minute tour ×
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It's 100% free, no registration required.

I'm doing a college project about digital image steganography on MATLAB. So far i've been able to get the help i needed from cool guys on stackoverflow but i now need to make my algorithm more hard to detect. This is what i have so far:

  • My main function reads 4 grayscale RGB 24-bit images and one RGB 24-bit image to encode the four images into. The first two are supposed to be blueprints and the other two are images containing only text (in large size). All the images are of the same size.

  • Before encoding, the pixel positions of each grayscale image are randomly shuffled by (eg: the 1st pixel becomes the 24th pixel, the second pixel becomes the 300th pixel) this is done by generating a random permutation of numbers that represent the new pixel positions using a seed. This is done to make the code harder to crack to an outsider and the seed will act as a password that would be needed at the receiving end to recover the images.

  • The first shuffled grayscale image is encoded into the R plane of the RGB image, and the second shuffled image is encoded into the G plane. This is done by testing each pixel in each image eg: pixel in position (x,y): if black-->make lsb of the pixel in position (x,y) in the chosen plane =0. if white-->make lsb of the pixel=1.

  • The other two shuffled grayscale images that contain text only are combined to form one grayscale image by choosing a chessboard-like patter of pixel positions of the first and the complement pattern of the second. And the resulting grayscale image is encoded into the B plane of the RGB image same as done to the first two. And this is done in that way because you don't need much details to be able to read a text but you do need details to be able to make out a blueprint, the recovered text grayscales will be a little distorted but they'll be readable. Now the process encoding is done and S/N ratio is calculated for the resulting encoded RGB image to measure the difference from the original RGB image and in result the difference is not noticeable to the untrained eye.

  • Recovering the grayscale images is done by reversing the operations done to the encoded RGB image in reverse order.

So there you go. I'm now looking for a way to make my code way more harder to detect and crack. Maybe using Wavelet Transform? I've been reading on that for a while but i don't now how that would work for my project.

share|improve this question
You should try make your injected data as close as possible to what's expected by the host format. Ie. if you're injecting in an image, it should statistically look like an image. Interesting Defcon talk on the subject. In stenography the goal isn't to make it hard to crack; we already have algorithms for that. The point is to make it hard to detect. I also notice there's no key for your function; that means anyone who knows the algorithm (assume everyone does) can reverse it no problem. –  rath Feb 15 at 16:50
@rath you're right. i really need help with this, i made an experiment in which i tried to extract the lsb information of a non encrypted bmp image and view that information as a black and white image (lsb=0==>black, lsb=1==>white) and i noticed that it looked like noise but also it also had the general shape of that image so it was a biased noise. When i tried to do this on an encrypted bmp image it looked like homogeneous noise. I figured that i need the noise that comes out of the encryption to be biased too to make the encryption concealed. –  Ahmed Ihsan Tawfeek Feb 15 at 17:56

1 Answer 1

up vote 5 down vote accepted

Some general advice about steganography:

  • Much like in the physical world, the smaller what you want to hide, the easiest that goal is. Thus you may want to compress the payload(s), and treat the result as the new, smaller payload consisting of arbitrary bits. Because your payload consists of images, some lossy scheme such as JPEG or JPEG 2000 might be used to get excellent compression. Also, the bigger the apparent vector message is, the easier hiding into it is (all other things being equal, like the format of that vector message).
  • Shuffling bits (second bullet in the question) is a primitive technique to try to make data unintelligible. In order to protect the confidentiality of the payload, use encryption. If done correctly, that makes it demonstrably hopeless to recover the original payload from the message (as opposed to detecting the presence of the payload), for one not holding the decryption key. One simple form of encryption is generating a pseudo-random stream of data from a key, and exclusive-ORing that with the plaintext (possibly compressed as above), with the caveat that the same portion of the stream must never be reused (see e.g. AES-CTR). Using authenticated encryption (e.g. AES-GCM) can in addition make it hopeless for an adversary to induce an undetected alteration of the hidden message.
  • Now comes the hard part: hiding the modified payload into a vector message (here, passable as an image) in a way such that presence of the payload won't be discovered. Stenography schemes attempting that could be rated on three coarse levels:
    1. Undetectability depends on the adversary (interceptor trying to prove there is a message hidden) not knowing the scheme itself. An example would be sending the payload in a portion of a vector file that most normal programs skip, like some comment field, or trailer. Such schemes fail as soon as known.
    2. Undetectability relies on the adversary not noticing some minute characteristics of the vector data. An example would be encoding the payload in the low bit of the bytes coding the RGB values in the vector, leaving all the rest untouched. Such schemes often fail (for example if the pristine vector is an uncompressed computer screen capture at a moment when a GUI is displaying areas of exactly uniform color, there will be extreme redundancy in the low-oder bits, and the scheme described will remove that, enabling detection, perhaps even with a sharp eye).
    3. Undetectability (to some quantifiable degree) is demonstrable under some assumptions, typically that a key is unknown to the adversary, and most critically assuming a model of the data in the vector (sorry, my only simple example is when that model is: true random data). In a real world, such schemes still can fail because the adversary has some better model (e.g. taking into account some details about how a particular camera allegedly the source of the vector image generates its files, or some characteristics of its sensor or lens).
  • In addition, some steganography schemes have another, even harder goal: prevent removal of the hidden payload without drastically altering the perceived quality of the vector (or at least, by casual transformation leaving the vector mostly undisturbed, e.g. saving an image as highly-compressed JPEG, or recoding digital audio as MP3). That would be necessary in some DRM schemes. Sometime this is called (digital) watermarking, but the analogy with the eponymous printing paper-manufacturing technique is reversed: in DRM, the designer's hope is that an unauthorized copy holds the watermark/payload, when on a banknote the hope is that the watermark is not copied. The three coarse levels above hold with some alterations.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.