close all %close all open figure windows
im1=ones(32,32); %solid white image
im1(1,1)=0;
subplot(2,4,1)
imagesc(im1);colormap(cool)
f1=fft2(im1); %take the 2D fft
mf1=abs(f1); %extract the magnitude of the fft
subplot(2,4,5)%put the fft under the original image
imagesc(mf1)%show the fft

%create image with maximum frequency content in both x and y
z=[0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1];
z1=1-z;
z=[z;z1];
z=[z;z];
z=[z;z];
z=[z;z];
z=[z;z];
im2=z; %32 x 32 checkerboard pattern
subplot(2,4,2)
imagesc(im2);
f2=fft2(im2); %take the 2D fft
mf2=abs(f2); %extract the magnitude of the fft
subplot(2,4,6)%put the fft under the original image
imagesc(mf2)%show the fft

%create image with maximum frequency content in y (horiz. stripes)
z1=ones(1,32);
z2=zeros(1,32);
z=[z1;z2];%2 rows
z=[z;z];%4 rows
z=[z;z];
z=[z;z];
z=[z;z];%32 rows
im3=z; %32 x 32 checkerboard pattern
subplot(2,4,3)
imagesc(im3);
f3=fft2(im3); %take the 2D fft
mf3=abs(f3); %extract the magnitude of the fft
subplot(2,4,7)%put the fft under the original image
imagesc(mf3)%show the fft

for c=1:32
for r=1:32
cm=mod(c,3);
im4(r,c)=cm*mod(r,3);
end
end
f4=fft2(im4);
mf4=abs(f4);
subplot(2,4,4)
imagesc(im5)
subplot(2,4,8)
imagesc(mf5)

%break

im6=imread('sara2012_32.jpg');
im6=rgb2gray(im6);
im6=double(im6);
mx6=max(max(im6));
im6=im6/mx6;
figure
imagesc(im6);
f6=fft2(im6);
mf6=(abs(f6));
figure
imagesc(mf6)
figure
[x,y]=meshgrid(1:32,1:32);
surf(x,y,mf6)
axis([0 40 0 40 0 10]);