function c = dctmatx2(n)
%DCTMTX2 Unitary 2-D Discrete Cosine Transform matrix.
%	D = DCTMTX2(N) returns the N-by-N unitary 2-D DCT transform
%	matrix.  DCTMTX2 uses a slightly different definition of the
%	discrete cosine transform than the function DCT.
%
%	Using this definition, D*A is the DCT of A and D'*A is the
%	inverse DCT of A (when A is N-by-N).
%	
%	See also: DCT.

%	Author:  Steven L. Eddins, 1993
%	Copyright (c) 1993 by The MathWorks, Inc.
%	$Revision: 1.4 $  $Date: 1993/10/21 12:59:32 $

%	References:
%	Jain, Fundamentals of Digital Image Processing, p. 150.

[cc,rr] = meshgrid(0:n-1);

c = sqrt(2 / n) * cos(pi * (2*cc + 1) .* rr / (2 * n));
c(1,:) = c(1,:) / sqrt(2);
