%%%
% experimentes with 2D FFT
% different artficial images

im.r  = 256;	% number of rows
im.c  = 256;	% number of columns
vecr = [-(im.r-1)/2:(im.r-1)/2];
vecc = [-(im.c-1)/2:(im.c-1)/2];
matX = repmat(vecr',1,im.c);			% create matrices from vectors
matY = repmat(vecc,im.r,1);
matD = max(abs(matX),abs(matY));		% distances in absolute metric
matR = sqrt(matX.^2+matY.^2);		    % distances in euclidean matrix

gridc = 1:1:im.c;
gridr = 1:8:im.r;
[X,Y] = meshgrid(gridc,gridr);	% for mesh plots

scrsz = get(0,'ScreenSize');	% parameters of the screen

count = 0;
for i = [1,2,4,8,16],
  count = count+1;						% for figures
  omega = i*pi/im.c;
  im.IM = sin(omega*(matY+(im.c-1)/2));
  im.IM = im.IM - min(im.IM(:));
  im.IM = im.IM/max(im.IM(:));
  figure(count);
  set(count,'Position',[1 (scrsz(4)/2)-75 scrsz(3) scrsz(4)/2]);
  subplot(131)
  mesh(X,Y,im.IM(gridr,gridc))
  axis([1 im.r 1 im.c -1 1])
  subplot(132)
  imshow(im.IM)
  im.FD = fftshift(fft2(im.IM));
  im.P  = (abs(im.FD)).^2;
  subplot(133)
  imagesc(log(1+im.P)/log(max(im.P(:))))
  axis('image')
end
