MATLAB: Hiding a message in an image

homework

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)

Best Answer

bin_m=dec2bin(8) is almost certainly wrong. Perhaps you meant
bin_m=dec2bin(M, 8);