Hiding a message in an image?

2 views (last 30 days)
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
Tommy Halim
Tommy Halim on 9 Apr 2019
Do you have code to extract hidden message from your code?

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 19 Nov 2015
bin_m=dec2bin(8) is almost certainly wrong. Perhaps you meant
bin_m=dec2bin(M, 8);
  4 Comments
Brian Tiffman
Brian Tiffman on 23 Nov 2015
I've tried incrementing k by using k=k+1, but I keep getting an error message. I'm not sure whats going on. The link you posted at the end of your last comment did help, and is a good read for me, so thanks.
Image Analyst
Image Analyst on 23 Nov 2015
After you read that last link, you'll know what to do if you need more help.

Sign in to comment.

More Answers (0)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!