5.2 Discrete Cosine Transform

dct( X[, type=2])
Replaces the columns of a dense real matrix with their discrete cosine transforms. The second argument, an integer between 1 and 4, denotes the type of transform (DCT-I, DCT-II, DCT-III, DCT-IV). The DCT-I transform requires that the row dimension of X is at least 2. These transforms are defined as follows (for a matrix with n rows).

\begin{eqnarray*}
\mbox{DCT-I:} \qquad
X[k,:] & := & X[0,:] + (-1)^k X[n-1,:] +...
...n-1} X[j,:] \cos(\pi (j+1/2)(k+1/2)/n),
\qquad k=0,\ldots,n-1.
\end{eqnarray*}


idct( X[, type=2])
Replaces the columns of a dense real matrix with the inverses of the discrete cosine transforms defined above.