image thumbnail
from Rectangular Image Puzzle Creator by Ahmad Saawi
Scramble pictures into Squares

imagescrambling.m
%IMAGE SCRAMBLING CODE
%Scrambles a picture into a fXf frames
clear;
[X,map] = imread('colornumber.bmp');
[l,w]=size (X);
f=3; %Number of frames per row or 
m=ceil(w/f);
n=ceil(l/f);
%Y=zeros(l,w);  % to define the size of the scrambled image
vp=randperm (f);
Y= [];
for i=1:f
for j=1:f
Sfr=[X((i-1)*m+1:i*m,(j-1)*n+1:j*n)];%Selecting a frame
    Y ((vp(i)-1)*m+1:vp(i)*m,(vp(j)-1)*n+1:vp(j)*n)=Sfr; %Scrambling the Frames
end
end

Contact us at files@mathworks.com