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)
Show older comments
% 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
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!