Next: Fast DCT algorithm
Up: dct
Previous: dct
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 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
:
If we shift the signals
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
.
In the following we simply represent this new function by
.
The DFT of this 2N-point even symmetric sequence can be found as:
Note that the second summation above is zero. This is because
is even and
is odd with respect to
, all terms in the second
summation are odd and the summation is zero (while all terms in the first summation
are even). It can also be seen that all
is real and even
. Next,
we replacie
by
and get
Note that since all terms in the summation are even, only the first half of the
data points need to be used. Moreover, as cosine function is even,
is also even and periodic with period
, we have
,
indicating that a point
(
) in the second half is the
same as its corresponding point
in the first half, i.e., the second half
is redundant and therefore can be dropped. Now we have the discrete cosine transform
(DCT):
where
the nth row and mth column of the DCT matrix:
All row vectors of this DCT matrix are orthogonal and normalized except the first
one (
):
To make DCT a orthonormal transform, we define a coefficient
so that DCT now becomes
where
is modified with
, which is also the component in the nth
row and mth coloum 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:
The inverse DCT is
or in matrix form:
Example: A
-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 comparible, 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.
Next: Fast DCT algorithm
Up: dct
Previous: dct
Ruye Wang
2009-10-13