%Chapter 3, Example 3.2: Figure 3.8
%Eric Dubois, updated 2018-11-14
%plot the Fourier transform of a discrete-domain separable exponential function
clear all, close all
%parameters
a=0.7;
b=0.7;
Umax = .75;
u = -Umax:Umax/24:Umax;
v=u;
[U,V] = meshgrid(u,v);
F = (1-a^2)^2*(1-b^2)^2*ones(size(U)) ./((1+a^4 -2*a^2*cos(2*pi*(U+V))).*(1+b^4 -2*b^2*cos(2*pi*(U-V))));

%perspective plot
figure
mesh(U,V,F)            % generate the perspective plot
view(-31,30);
colormap([0 0 0]);     % use black only
axis([-Umax Umax -Umax Umax 0 1])
xlabel('\itu \rm(c/px)'), ylabel('\itv \rm(c/px)');
set(gca,'ydir','reverse'); 
set(gca,'FontName','times')          %set the plot font to times
set(gca,'FontSize',8)                %set the plot size to 8pt
set(gcf,'units','centimeters','position',[0.5,0.5,15,15]);
set(gcf,'Color',[1 1 1]);

%contour plot
figure
cval=0:.1:1;             % contours will be from 0 to 1 in steps of 0.1
[C,h]=contour(U,V,F,cval); % generate the contour plot, including values to label contours
axis square
clab = [.1 .5 1];
clabel(C,clab,'FontSize',6)             %label the contours
xlabel('\itu \rm(c/px)'), ylabel('\itv \rm(c/px)');
set(gca,'ydir','reverse'); 
set(gca,'XAxisLocation','top');      %Xaxis labels on top
set(gca,'fontname','times')          %set the plot font to times
set(gca,'FontSize',8)                %set the plot size to 8pt
set(gcf,'units','centimeters','position',[0.5,0.5,15,15]);
colormap([0 0 0]);     % use black only
hold on
%plot Voronoi unit cell
plot([.5 0],[0 .5],'r',[0 -.5],[.5 0],'r',[-.5 0],[0,-.5],'r',[0 .5],[-.5 0],'r')
set(gcf,'Color',[1 1 1]);