Discrete cosine transform

Back to Signal transforms

The discrete cosine transform (DCT) is an invertible linear mapping defined by:

, where , and

The unitary discrete cosine transform is given by multiplying the first row of by , and the rest of by .

Theory

The unitary DCT has the convenient property of preserving 2-norms. The DCT can be viewed as a change of basis from the standard basis to a cosine basis. The inverse of the DCT is given by :

, where ,

, and

Real vs complex

Since the matrix is real, the DCT and IDCT are closed under . Using the DCT on real vectors is arguably the most common use-case. In this real case the unitary version is called an orthogonal discrete cosine transform.

Applications

The DCT is interesting for the same reasons as the discrete Fourier transform. However, especially when applied to natural images, the DCT has a strong energy compaction property, which means that most of the information (length) of a vector is contained in the first few coefficients. This property has been extensively taken advantage of in image compression.

Practice

Pastel implements efficient algorithms for computing the DCT and the IDCT, when is a power of two. Both the standard and the orthogonal version are provided, as well as both real and complex versions.

Range algorithms

Pastel also provides the in-place versions of the DCT as range algorithms, so that applying them to arrays is easy.

See also

Discrete Fourier transform

Files

Discrete cosine transform