Info

This question is closed. Reopen it to edit or answer.

I'm trying a simple LSB steganography for embedding and extracting a small message..but whenever I try to extract I keep getting different message :( something wrong with this code.can anyone help please tell me where it got wrong in the extraction..

1 view (last 30 days)
% try LSB embedding
X=imread('peppers.jpg');
X1=X(:,:,1); % embed in the first channel
msg='The secret message';
msgB=dec2bin(msg,8); % binary message
[msgr msgc]=size(msgB);
location=find(X1,msgr*msgc);
for i=1:msgr
for j=msgc
X(location(msgc*(i-1)+j))=bitset(X1(location(msgc*(i-1)+j)),1,str2num(msgB(i,j)));
end
end
X=(cat(3,X1,X(:,:,2),X(:,:,3)));
imwrite(X,'stegoLSB.jpg');
%======================================================
%try extraction
Y=imread('stegoLSB.jpg');
secret=zeros(msgr,msgc);
Y1=Y(:,:,1);
for i = 1:msgr
for j = 1:msgc
secret(i,j)=bitget(Y1(location(msgc*(i-1)+j)),1);
end
secret=num2str(secret);
secret = bin2dec(secret);
secret = transpose(secret);
disp(char(secret));
  2 Comments
Budoor Salem
Budoor Salem on 3 Oct 2016
there is no error... it just when I run this code.. the retrieved secret message that I got is:
g¿8¨àI°Ìz.K4ø
which is not the original message I actually embedded which was msg='The secret message';
there must be something I missed or went wrong in the extraction..please check if can help me on this and really thank you Mr. Walter

Answers (0)

Community Treasure Hunt

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

Start Hunting!