clear all;
%close all;

x1 = ones(1,6);
x2 = ones(1,5);
x3 = ones(1,4);
x4 = ones(1,3);
x5 = ones(1,2);


x6 = ones(1,1*1);
y1 = [x1 0*x1]; ly1 = length(y1);
y2 = [x2 0*x2]; ly2 = length(y2);
y3 = [x3 0*x3]; ly3 = length(y3);
y4 = [x4 0*x4]; ly4 = length(y4);
y5 = [x5 0*x5]; ly5 = length(y5);
y6 = [x6 0*x6]; ly6 = length(y6);
L = [ly1 ly2 ly3 ly4 ly5 ly6];
temp = L(1);
for i = 1:length(L)-1
  temp = lcm(temp, L(i+1));
end


y1 = repmat(y1, temp, temp/ly1); %y1 = rot90(y1);

y2 = repmat(y2, temp, temp/ly2); %y2 = rot90(y2);

y3 = repmat(y3, temp, temp/ly3); %y3 = rot90(y3);

y4 = repmat(y4, temp, temp/ly4); %y4 = rot90(y4);

y5 = repmat(y5, temp, temp/ly5); %y5 = rot90(y5);

y6 = repmat(y6, temp, temp/ly6); %y6 = rot90(y6);
y = [y1 y2 y3; y4 y5 y6];

figure; h=imshow(y,[]); colormap('cyan');

%------------------------------------------------------------------
L11_1 = sum(y1(1:64,1:64),2);
L12_1 = sum(y2(1:64,1:64),2);
L13_1 = sum(y3(1:64,1:64),2);

L21_1 = sum(y4(1:64,1:64),2);
L22_1 = sum(y5(1:64,1:64),2);
L23_1 = sum(y6(1:64,1:64),2);

L = [max(L11_1),max(L12_1),max(L13_1), max(L21_1),max(L22_1),max(L23_1)];
Lmax = max(L);

figure;  subplot(231),plot(L11_1/Lmax); zoom on; grid;
         subplot(232),plot(L12_1/Lmax); zoom on; grid;
         subplot(233),plot(L13_1/Lmax); zoom on; grid;
         subplot(234),plot(L21_1/Lmax); zoom on; grid;
         subplot(235),plot(L22_1/Lmax); zoom on; grid;
         subplot(236),plot(L23_1/Lmax); zoom on; grid;

vert_spatial = [L11_1/Lmax; L12_1/Lmax; L13_1/Lmax; L21_1/Lmax; L22_1/Lmax; L23_1/Lmax];
save D:\My_Documents\Christine\psych221\tutorials\project\vert_spatial vert_spatial;
%------------------------------------------------------------------------------------

f11_1 = abs(fftshift(fft(L11_1)));
f12_1 = abs(fftshift(fft(L12_1)));
f13_1 = abs(fftshift(fft(L13_1)));
f21_1 = abs(fftshift(fft(L21_1)));
f22_1 = abs(fftshift(fft(L22_1)));
f23_1 = abs(fftshift(fft(L23_1)));


f = [max(f11_1),max(f12_1),max(f13_1), max(f21_1),max(f22_1),max(f23_1)];
fmax = max(f);

figure;  subplot(231),plot(f11_1/fmax); zoom on; grid;
         subplot(232),plot(f12_1/fmax); zoom on; grid;
         subplot(233),plot(f13_1/fmax); zoom on; grid;
         subplot(234),plot(f21_1/fmax); zoom on; grid;
         subplot(235),plot(f22_1/fmax); zoom on; grid;
         subplot(236),plot(f23_1/fmax); zoom on; grid;

vert_transform = [f11_1/fmax; f12_1/fmax; f13_1/fmax; f21_1/fmax; f22_1/fmax; f23_1/fmax];
save D:\My_Documents\Christine\psych221\tutorials\project\vert_transform vert_transform;
