Note that the decoding can be achieved much more efficiently with these three lines of codes:
cat = double(imread('Cat.png'));
codedcat = double(imread('CodedCat.png'));
message = char(bin2dec(char(reshape(abs(cat - codedcat)' == 1, 8, [])' + '0'))');
This is probably even more efficient since there's no number -> char -> number conversion to compute the ascii code of each character:
message = char(sum(bsxfun(@times, reshape(abs(cat - codedcat)' == 1, 8, []), 2 .^ (7:-1:0)')));
Best Answer