A related transform is the discrete sine transform (DST), which is equivalent to a DFT of real and odd functions.

Formally, the discrete cosine transform is a linear, invertible function F : R^{n} > R^{n} (where R denotes the set of real numbers). There are several variants of the DCT with slightly modified definitions. The n real numbers x_{0}, ..., x_{n1} are transformed into the n real numbers f_{0}, ..., f_{n1} according to one of the formulas:
+ \sum_{k=1}^{n2} x_k \cos \left[\frac{\pi}{n1} j k \right]</math>
A DCTI of n=5 real numbers abcde is exactly equivalent to a DFT of eight real numbers abcdedcb (even symmetry). (In contrast, DCT types IIIV involve a halfsample shift in the equivalent DFT.) Note, however, that the DCTI is not defined for n less than 2. (All other DCT types are defined for any positive n.)
Thus, the DCTI corresponds to the boundary conditions: x_{k} is even around k=0 and even around k=n1; similarly for f_{j}.
\sum_{k=0}^{n1} x_k \cos \left[\frac{\pi}{n} j (k+1/2) \right]</math>
The DCTII is probably the most commonly used form, and is often simply referred to as "the DCT".
Some authors further multiply the f_{0} term by 1/√2 (see below for the corresponding change in DCTIII); this does not affect the basic properties, but breaks the direct correspondence with a realeven DFT of halfshifted input.
The DCTII implies the boundary conditions: x_{k} is even around k=1/2 and even around k=n1/2; f_{j} is even around j=0 and odd around j=n.
\sum_{k=1}^{n1} x_k \cos \left[\frac{\pi}{n} (j+1/2) k \right]</math>
Because it is the inverse of DCTII (up to a scale factor, see below), this form is sometimes simply referred to as "the inverse DCT" ("IDCT").
Some authors further multiply the x_{0} term by √2 (see above for the corresponding change in DCTII); this does not affect the basic properties, but breaks the direct correspondence with a realeven DFT of halfshifted output.
The DCTIII implies the boundary conditions: x_{k} is even around k=0 and odd around k=n; f_{j} is even around j=1/2 and odd around j=n1/2.
\sum_{k=0}^{n1} x_k \cos \left[\frac{\pi}{n} (j+1/2) (k+1/2) \right]</math>
A variant of the DCTIV, where data from different transforms are overlapped, is called the modified discrete cosine transform (MDCT).
The DCTIV implies the boundary conditions: x_{k} is even around k=1/2 and odd around k=n1/2; similarly for f_{j}.
In principle, there are actually four additional types of discrete cosine transform (Martucci, 1994), corresponding to realeven DFTs of logically odd order, which have factors of n+1/2 in the denominators of the cosine arguments. However, these variants seem to be rarely used in practice.
(The trivial realeven array, a lengthone DFT (odd length) of a single number a, corresponds to a DCTV of length n=1.)
The inverse of DCTI is DCTI multiplied by 2/(n1). The inverse of DCTIV is DCTIV multiplied by 2/n. The inverse of DCTII is DCTIII multiplied by 2/n (and vice versa).
Like for the DFT, the normalization factor in front of these transform definitions is merely a convention and differs between treatments. For example, some authors multiply the transforms by <math>\sqrt{2/n}</math> so that the inverse does not require any additional multiplicative factor.
Although the direct application of these formulas would require O(n^{2}) operations, as in the fast Fourier transform (FFT) it is possible to compute the same thing with only O(n log n) complexity by factorizing the computation. (One can also compute DCTs via FFTs combined with O(n) pre and postprocessing steps.)
The DCT, and in particular the DCTII, is often used in signal and image processing, especially for lossy data compression, because it has a strong "energy compaction" property: most of the signal information tends to be concentrated in a few lowfrequency components of the DCT, approaching the optimal KarhunenLoeve transform[?] for signals based on certain limits of Markov processes.
For example, the DCT is used in JPEG image compression, MJPEG video compression, and MPEG video compression. There, the twodimensional DCTII of 8x8 blocks is computed and the results are filtered to discard small (difficulttosee) components. That is, n is 8 and the DCTII formula is applied to each row and column of the block. The result is an array in which the top left corner is the DC (zerofrequency) component and lower and rightmore entries represent larger vertical and horizontal spatial frequencies. For the chrominance components, n is 16 but the frequency components beyond the first 8 are discarded.
A related transform, the modified discrete cosine transform (MDCT), is used in AAC, Vorbis, and MP3 audio compression.
DCTs are also widely employed in solving partial differential equations by spectral methods, where the different variants of the DCT correspond to slightly different even/odd boundary conditions at the two ends of the array.
Search Encyclopedia
