Search code examples
matlabsteganography

Hide text In Image Matlab


I have managed to hide one image into another using this simple method.

Cover = imread('qw.jpg', 'jpg');
Hidden = imread('qwe.jpg', 'jpg');
n = 1; % Number of bits to replace

Processed = uint8(bitor(bitand(Cover, bitcmp(2^n - 1, 8)) , bitshift(Hidden, n - 8)));
Hidden = uint8(bitand(255, bitshift(Processed, 8 - n)));

figure, imshow(Processed)
figure, imshow(Hidden)

I want to store text in the cover image and I've tried

dec2bin(text,8)

to convert text to binary but I am unable to proceed further i.e. How to store the output of

de2bin()

bit by bit in lsb of Cover. Can anyone help???


Solution

  • You can write the dec2bin() statement like this

    e.g.

     c=dec2bin(text,8);
    

    c holds the char array try this but don't convert the text directly to binary first convert them to uint8 format then use the dec2bin() statement