% steganall2.m modified from steganall.m written by Cleve Moler.
% STEGANALL  Steganography.  Here are all images hidden in the
% default CDATA for the IMAGE command.

p = [1  6 11 16 17 18 19 20 25 30 35 36 40 44 48 52];
q = [5 10 15 16 17 18 19 24 29 34 35 39 43 47 51 52];

clf     % clear current figure.
image   % returns a handle to an IMAGE object.
imageh = get(gca,'child');
% A is a 64x64 matrix with values in [0 1].
A = get(imageh,'cdata')/32;
clf
shg
colormap(gray(32));
bigscreen;

% Image obtained from the entire original data:
subplot(1,2,1);
imagesc(A);
title('Image from the full data');
axis image; axis ij; axis off;
   
% This shows the image obtained using only 
% the top most significant bit of the data:
subplot(1,2,2);
m = 1; n = 5;
U = mod(floor(2^n*A),2^(n-m+1));   
V = U+1;
imagesc(V)   %Scale data and display as image
title([int2str(m) ':' int2str(n)])
axis image; axis ij; axis off;
   
pause;

% The following shows that 15 other images are
% secretly embedded in the original one.
for k = 1:16
   subplot(4,4,k)
   m = p(k);    n = q(k);
   U = mod(floor(2^n*A),2^(n-m+1));   
   V = U+1;
   imagesc(V)   %Scale data and display as image
   title([int2str(m) ':' int2str(n)])
   axis image; axis ij; axis off;
end
