function b=dct(a,n) %DCT Discrete cosine transform. % % Y = DCT(X) returns the discrete cosine transform of X. % The vector Y is the same size as X and contains the % discrete cosine transform coefficients. % % Y = DCT(X,N) pads or truncates the vector X to length N % before transforming. % % If X is a matrix, the DCT operation is applied to each % column. This transform can be inverted using IDCT. % % See also FFT, IFFT, IDCT. % Author(s): C. Thompson, 2-12-93 % S. Eddins, 10-26-94, revised % Copyright 1988-2004 The MathWorks, Inc. % $Revision: 1.7.4.2 $ $Date: 2004/12/26 22:15:37 $ % References: % 1) A. K. Jain, "Fundamentals of Digital Image % Processing", pp. 150-153. % 2) Wallace, "The JPEG Still Picture Compression Standard", % Communications of the ACM, April 1991. if nargin == 0, error('Not enough input arguments.'); end if isempty(a) b = []; return end % If input is a vector, make it a column: do_trans = (size(a,1) == 1); if do_trans, a = a(:); end if nargin==1, n = size(a,1); end m = size(a,2); % Pad or truncate input if necessary if size(a,1)