%Chapter 2, Fig 2.4 %Eric Dubois updated 2018-11-07 %Illustration of a 2D sinusoidal signal 0.5cos(2pi(ux + vy))+0.5 %Spatial frequencies are u = 1.5 c/ph and v = 2.5 c/ph, which can be %changed by modifying u and v. %Sinusoid is a square image of size 1ph x 1ph, sampled as 1201x1201 %Required function: sRGB_gamma_correction (optional) clear all, close all %generate the sinusoid L1=0; L2=1; del = 1/1200; x=0:del:1; y=x; %x and y values between 0 and 1 spaced by del [X,Y]=meshgrid(x,y); % generate a 2D grid of xy values u=1.5; v=2.5; % horizontal and vertical spatial frequencies Z_lin=0.5+0.5*cos(2*pi*(u*X+v*Y)); %Z= sRGB_gamma_correction(Z_lin); %optional statement to apply gamma %correction. Not used in the book. Z=Z_lin; %no gamma correction %create the plot figure image([L1,L2],[L1,L2],Z,'CDataMapping','scaled'); colormap(gray) set(gca,'dataaspectratio',[1 1 1]); %make the plot square set(gca,'ydir','reverse'); %vertical axis points down 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]); set(gcf,'Color',[1 1 1]); xlabel('\itx \rm(ph) '), ylabel('\ity \rm(ph) '); hold %draw the line y = (5/3)x xl = [0 1]; yl = [0 v/u]; plot(xl,yl,'k'); axis([0 1 0 1]);