% Chapter 12, Fig.12.8
% Eric Dubois, updated 2019-01-15
%Plot the 8 by 8 DCT2 basis vectors 
clear all, close all
%the basis vectors are drawn on a L by L canvas
%map the range [-.25 .25] to [0 1] 
L=584;
N1=8,
OUT = 0.2*ones(L,L);
%
beta1 = [1 2 2 2 2 2 2 2];
n1 = 0:7;
n2 = 0:7;
[Nx,Ny] = meshgrid(n1,n2);
for k1=0:7
    for k2=0:7
        z = sqrt(beta1(k1+1)*beta1(k2+1))*cos(pi*k1*(Nx+0.5)/N1)...
            .*cos(pi*k2*(Ny+0.5)/N1)/N1;
        zM = 2*(.25 + imresize(z,8,'nearest'));
        OUT(8+k2*72:71+k2*72,8+k1*72:71+k1*72)=zM;
    end
end
imshow(OUT)