i need a code for hiding a text in an image using lsb technique
Show older comments
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
sagar hepat
on 28 Oct 2014
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
Jadem Molina
on 4 Nov 2014
hello, How can I get the hidden data on the Image. Thanks!
vaishali sharma
on 9 Apr 2015
Moved: DGM
on 5 Feb 2023
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
Akhil Ram Sai
on 3 Apr 2016
can you also comment the code for reconstruction of the text
Walter Roberson
on 3 Apr 2016
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.
hudof najeeb
on 4 Dec 2016
can you give me the decoded to return back the hidden text from the original and the encoded image ...please
Image Analyst
on 4 Dec 2016
hudof najeeb
on 5 Dec 2016
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
Walter Roberson
on 5 Dec 2016
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.
Image Analyst
on 5 Dec 2016
Or you can just extract one color channel, encode the text into it, then stick it back in.
Amal
on 12 Nov 2022
i need a code for hiding a text in an image using lsb technique ?
Image Analyst
on 12 Nov 2022
@Amal see attached
Image Analyst
on 12 Nov 2022
Moved: DGM
on 5 Feb 2023
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?
Walter Roberson
on 13 Nov 2022
Moved: DGM
on 5 Feb 2023
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.
Accepted Answer
More Answers (0)
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!