Hiding a message in an image?
2 views (last 30 days)
Show older comments
Brian Tiffman
on 19 Nov 2015
Commented: Tommy Halim
on 9 Apr 2019
Can someone please look at this document I attached, and also my code. Im not sure if my code is correct or not. I do get the two pictures with very minimal change at the end. I just want some insight into whether my code looks good or not, it feels like im missing something.
pic=imread('Cat.png')
imshow(pic)
title('original picture')
[nrow ncol]=size(pic)
cpic=pic
Mi=input('Input message:','s')
M=double(Mi)
bin_m=dec2bin(8)
bin_m=bin_m'
bin_m=bin_m(:)
if length(M)>nrow*ncol
error('The message is too long!')
end
k=1
for r=1:nrow
for c=1:ncol
if strcmpi(bin_m(k),'0');
cpic(r,c)=cpic(r,c);
elseif strcmpi(bin_m(k),'1') && cpic(r,c)==255;
cpic(r,c)=cpic(r,c)-1;
else
cpic(r,c)=cpic(r,c)+1;
end
end
end
imshow(pic)
figure;
imshow(cpic)
1 Comment
Accepted Answer
Walter Roberson
on 19 Nov 2015
bin_m=dec2bin(8) is almost certainly wrong. Perhaps you meant
bin_m=dec2bin(M, 8);
4 Comments
Image Analyst
on 23 Nov 2015
After you read that last link, you'll know what to do if you need more help.
More Answers (0)
See Also
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!