i need a code for hiding a text in an image using lsb technique

hello, i need a code to hide a message in an image using lsb technique(Steganography).... im new user to use a matlab... i just only knew the basic command of matlab.... plzzzzzzzzz help

17 Comments

c = imread('any_image.jpg');
message = 'hi this is sagar from nagpur..'
message = strtrim(message);
m = length(message) * 8;
AsciiCode = uint8(message);
binaryString = transpose(dec2bin(AsciiCode,8));
binaryString = binaryString(:);
N = length(binaryString);
b = zeros(N,1); %b is a vector of bits
for k = 1:N
if(binaryString(k) == '1')
b(k) = 1;
else
b(k) = 0;
end
end
s = c;
height = size(c,1);
width = size(c,2);
k = 1; Array=[];l=1;my=1;
for i = 1 : height
for j = 1 : width
LSB = mod(double(c(i,j)), 2);
if (k>m || LSB == b(k))
s(i,j) = c(i,j);
l=k+1;
else
if(LSB == 1)
s(i,j) = c(i,j) - 1;
else
s(i,j) = c(i,j) + 1;
Array(my)=l;
l=l+1;
my= my + 1;
end
k = k + 1;
end
end
end
imwrite(s, 'hiddenmsgimage.bmp');
k = 1;my=1;ur=1;
for i = 1 : height
for j = 1 : width
if( k<=m )
if (my<numel(Array) && Array(my)==ur)
b(k)=~(mod(double(s(i,j)),2));
else
b(k) = mod(double(s(i,j)),2);
end
k = k + 1;
my= my + 1;
end
ur=ur+1;
end
end
try this dude enjoy
hello, How can I get the hidden data on the Image. Thanks!
you can upload and decryp.Please
hello sir m beginner and m implementing lsb but i didnt get why we are using : for k = 1:N if(binaryString(k) == '1') b(k) = 1; else b(k) = 0; end end
can you also comment the code for reconstruction of the text
Akhil Ram Sai, who are you addressing that to? sagar hepat is unlikely to see your request a year and half after they posted the question, and the volunteers who read this are likely to refer you to http://www.mathworks.com/matlabcentral/answers/?term=tag%3A%22steganography%22 as a number of other people have already commented their reconstruction code.
can you give me the decoded to return back the hidden text from the original and the encoded image ...please
sir,it was very interesting program but it used gray-level image .I want color image.how i can get it and if I want to get the hide text from cover image what i must do ?I mean the second part when I have original and cover image thx
Reshape your color image to rows by (columns * 3) and now the code cannot tell it was not just a wide gray image. Afterwards, reshape() it back.
Or you can just extract one color channel, encode the text into it, then stick it back in.
i need a code for hiding a text in an image using lsb technique ?
i need a code for hiding a text in an image using lsb technique in the GUI interface inside the button?
What do you mean by the image is inside the button? How can you have an image inside the button? You mean a button with a little picture or icon on it? An image that could fit inside a button would most likely not have enough pixels in it to hide anything. Then there's the problem of getting the image out of the button. Why do you want/need to do this anyway?
How is text selected in the GUI interface in Matlab?
If you have a uicontrol style 'edit' (traditional figures), or if you have a uitext (uifigures) and those have text in them, then matlab does not provide any way itself to find out what text is selected.
The same is true for edit fields.
You can find out which cells of a table are selected, or which entries of a list box or drop box are selected, but not what text is selected within a field.

Sign in to comment.

 Accepted Answer

Attached is one where I hide an image. You can adapt it to hide text if you want.

6 Comments

Not sure. One way might be to just make an image out of the text by having each pixel of the image be the ASCII value of the text. I don't know if that's the most common way since steganography is not my field, but it should work .
sir, why are you converting your image into binary image to hide a watermark into it.... is there is not any solution rather than this...?? because i done watermarking based on limitation watermark must be 1/8 of the host image. and if i insert the image into host based on this, then it only inserted into the left side on host image.... can you help??
The cover image stays 8 bit while the watermark/hidden image is 1 bit (binary). That's just the way the person wanted it when I wrote the demo originally for him.
but sir. there is very much of watermarked_image data loss.
That demo does not hide a gray scale image in another gray scale image. It only uses the cameraman gray scale image to create the binary image. It is actually the binary image that I'm hiding, and there is no data loss for that. I just made this demo a long time ago following what one poster said he wanted to do. If you have a version that hides a grayscale image inside another grayscale image, please post it.
sure sir..!! i will, presently i am working on this problem.. thanks a lot your demo help me in my work..

Sign in to comment.

More Answers (0)

Asked:

on 28 Mar 2014

Moved:

DGM
on 5 Feb 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!