  function ShowScramble(m,n)
% read in a jpeg that is in the current working directory, e.g.,
A = imread('Cornell_Clock.jpg');
% Determine the pixel dimensions of the tiles that are obtained
% by chopping up the picture...
[rows,cols,p] = size(A);
m1 = floor(rows/m);
n1 = floor(cols/n);
% Construct a cell array of these tiles...
C = cell(m*n,1);
k = 0;
S = zeros(m1,n1,3,'uint8');
for i=1:m
    for j = 1:n
        % Copy tile (i,j) into S...
        S(:,:,1) = A(1+(i-1)*m1:i*m1,1+(j-1)*n1:j*n1,1);
        S(:,:,2) = A(1+(i-1)*m1:i*m1,1+(j-1)*n1:j*n1,2);
        S(:,:,3) = A(1+(i-1)*m1:i*m1,1+(j-1)*n1:j*n1,3);
        k = k+1;
        C{k} = S;
    end
end
% Will house the scrambled image data in B where...
B = zeros(m*m1,n*n1,3,'uint8');
% Generate a permutation of 1:m*n...
[z,idx] = sort(rand(m*n,1));
% Now revisit the tile locations row-by-row just as in the above double loop.
% At each position, grab a random sub-image from the cell array C...
k = 0;
for i=1:m
    for j=1:n
        % Store a random sub-image in S
        k = k+1;
        S = C{idx(k)};
        % Now patch it into B...
        B(1+(i-1)*m1:i*m1,1+(j-1)*n1:j*n1,1) = S(:,:,1);
        B(1+(i-1)*m1:i*m1,1+(j-1)*n1:j*n1,2) = S(:,:,2);
        B(1+(i-1)*m1:i*m1,1+(j-1)*n1:j*n1,3) = S(:,:,3);
    end
end
imwrite(B,'Scrambled.jpg')
imshow('Scrambled.jpg')