function varargout = dct_2d_basis( varargin )

	if nargin==0
		N = 8;
	else
		N = varargin{1};
	end
	
	sq = 1 / sqrt(2);
	F = zeros( N, N, N, N);
	g = {};
	newfig;

	for u=0:N-1,
		for v=0:N-1,
			cu = iif( u==0, sq, 1);
			cv = iif( v==0, sq, 1);
			for j=0:N-1,
				for k=0:N-1,
					F( u+1, v+1, j+1, k+1) = ...
						cos( ((2*j+1)*u*pi)/(2*N)) * cos( ((2*k+1)*v*pi)/(2*N));
				end;
			end;
			F(u+1,v+1,:,:) = cu * cv * F(u+1,v+1,:,:);
			g{end+1} = reshape(F(u+1,v+1,:,:),[N,N]);
			subplot(N,N,u*N+v+1); 
			imagesc( g{end});
			colormap gray; 
			axis off; 
			drawnow;
		end;
	end;
	
	if nargout>0
		varargout{1} = g;
	end
			