PuzzleImage.m - puzzle2.m This creates a puzzle consisting of 4 pieces of an image that are scrambled into random positions and rotated at random

# PuzzleImage.m - puzzle2.m This creates a puzzle consisting...

• 2

This preview shows page 1 - 2 out of 2 pages.

% puzzle2.m % This creates a puzzle consisting of 4 pieces of an image that are % scrambled into random positions and rotated at random discrete angles. close all; clear all; % load image, get size, and see original image load mandrill; [Nx,Ny] = size(X); %figure; imagesc(X); colormap(gray); % truncate image so it is square N = min([Nx,Ny]); Xt = X(1:N,1:N); figure; imagesc(Xt); colormap(gray); axis off; title('Original Image'); % We will cut into 4 square puzzle pieces which can be rotated at 90 degree % angles % The pieces are ordered as % P1 P3 % P2 P4 % In what we do next this ordering can be put in vector form for convenience as ... % [top_left bottom_left top_right bottom_right], in this case [P1 P2 P3 % P4]. % Let 1,2,3,4 correspond to piece labels. A scrambled image % P4 P1 % P2 P3 % Could thus be represented as [4 2 1 3]. % randomly scramble the pieces by randomly permuting their order. P_perms = perms([1:4]); % this will generate all the permutations of [1 2 3 4] into a matrix with n! rows.

• Spring '10
• mais

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern