The discrete Fourier transform (DFT) transforms a complex signal into its complex spectrum. However, if the signal is real as in most of the applications, half of the data is redundant. In time domain, the imaginary part of the signal is all zero; in frequency domain, the real part of the spectrum is even symmetric and imaginary part odd. In comparison, Discrete cosine transform (DCT) transforms is a real transform that transforms a sequence of real data points into its real spectrum and therefore avoids the problem of redundancy. Also, as DCT is derived from DFT, all the desirable properties of DFT (such as the fast algorithm) are preserved.

To derive the DCT of an N-point real signal sequence
,
we first construct a new sequence of points:

This 2N-point sequence is assumed to repeat its self outside the range , i.e., it is periodic with period , and it is even symmetric with respect to the point at :

If we shift the points to the right by 1/2, or, equivalently, shift to the left by 1/2 by defining another index , then is even symmetric with respect to the origin at . In the following we simply represent this new function by .

The DFT of this 2N-point even symmetric sequence can be found as:

Here we have used the fact that is even, and are respectively even and odd, all with respect to or . Consequently the first summation of all even terms is twice that with half of the range , while the second summation of all odd terms is zero. Replacing by , we get the discrete cosine transform (DCT):

where the coefficient defined as

which can be considered as the component on the mth row and nth column of an matrix , called the DCT matrix.

As is even and of period , we further have

i.e., the second coefficients for are redundant and can be dropped. Now the the range for index is reduced to . We can show that all row vectors of are orthogonal and normalized, except the first one ():

To make DCT a orthonormal transform, we define a coefficient

so that the DCT now becomes

where is modified with , which is also the component in the nth row and mth column of the N by N cosine transform matrix:

Here is the ith row of the DCT transform matrix . As these row vectors are orthogonal:

the DCT matrix is orthogonal:

and it is real . Now the DCT can be expressed in matrix form as:

Left multiplying both sides by we get

this is the inverse DCT:

or in component form:

**Example: ** When , we have
for , and

An -point DCT matrix can be generated by to be

Assume the signal is , then its DCT transform is:

The inverse transform is:

This result is very similar to the example shown in the previous section for WHT transform. In fact, these two transforms are very comparable, as seen from the figure below:

Compared with DFT, DCT has two main advantages:

- It is a real transform with better computational efficiency than DFT which by definition is a complex transform.
- It does not introduce discontinuity while imposing periodicity in the time signal. In DFT, as the time signal is truncated and assumed periodic, discontinuity is introduced in time domain and some corresponding artifacts is introduced in frequency domain. But as even symmetry is assumed while truncating the time signal, no discontinuity and related artifacts are introduced in DCT.