You are on page 1of 16

DISCRETE COSINE TRANSFORM

1-D DCT

The 1-D discrete cosine transform is defined as

(2 x 1)u

C (u ) a (u ) f ( x) cos

x 0
2N
N 1

The inverse DCT is defined as

(2 x 1)u

f ( x ) a (u )C (u ) cos

u 0
2N
N 1

1-D DCT Cont..

Where

x = 0,1,N-1
u = 0,1,N-1

a (u )

1
N

u0

2
N

u 1, , N 1

1-D DCT Cont..

So for N=4, the 1-D DCT basis vectors can be found as


follows:
{Cos(u/8); Cos(3u/8); Cos(5u/8); Cos(7u/8)} for u
= 0,1,2,3.
The transformation matrix can be obtained as

1
1
1
1
0.924 0.383 0.383 0.924
0.707 0.707 0.707 0.707

0.383 0.924 0.924 0.383

2-D DCT

The 2-D DCT pair of equations is given by:


N 1 N 1

C (u , v) a (u )a (v)
x 0 y 0

(2 x 1)u
(2 y 1)v
f ( x, y ) cos
cos

2N
2N

( 2 x 1)u
(2 y 1)v

f ( x, y ) a (u ) a (v)C (u , v) cos
cos

u 0 v 0
2N
2N

N 1N 1

u , v 0,1, , N 1

2-D DCT Basis Images

The 2-D basis images can be found from the 1-D


basis vectors.

1 1
1 1

1 1

1 1
0.707
0.707
0.707
0.707

1 1 0.924
0.924
0.924
0.924
1 1 0.383
0.383
0.383
0.383
1 1 0.383 0.383 0.383 0.383

1 1 0.924 0.924 0.924 0.924


0.707
0.707
0.707 0.383
0.383
0.383
0.383
0.707 0.707 0.707 0.924 0.924 0.924 0.924
0.707 0.707 0.707 0.924
0.924
0.924
0.924

0.707
0.707
0.707 0.383 0.383 0.383 0.383

2-D Basis Images for N = 4


v
u
0

DCT-Advantages

The DCT is a real and orthogonal transform.


It is a separable transform.
The DCT has excellent energy compaction
properties.
Among the currently known unitary transforms it
is the best approximation for the optimal KLT.
There are fast algorithms to compute the DCT
similar to the FFT.

Example:

Example: x(n) = [1 2 3 4]
C(k) = [5 -2.23 0 -0.16]
Reconstruction with first 2 coefficients

x(n) = [1.04 1.89 3.10 3.96]

With DFT:
X(k) = [10 -2+ 2i -2 -2- 2i]
Reconstruction with first 2 coefficients

x(n) = [1.5 1.5 3.5 3.5]

Example:2-D
1 2 3 4
1 2 3 4

A( x, y )
1 2 3 4

1
2
3
4

A' ( x, y )

1.0429
1.0429

1.0429
1.0429

C (k1, k 2)

10 4.46 0 0.32
0

0
0
0

1.8964 3.1036 3.9571


1.8964 3.1036 3.9571
1.8964 3.1036 3.9571

1.8964 3.1036 3.9571

Example:2-D
Using 2-D DFT

1.5
1.5
A' ( x, y )
1.5

1.5

1.5
1.5
1.5
1.5

40 8 8i 8 8 8i
0

0
0
0

X (k1, k 2)
0
0
0
0

0
0
0
0

3.5
3.5
3.5
3.5

3.5
3.5
3.5

3.5

DCT from DFT

To relate DFT and DCT we obtain DCT from DFT


using the following method.
N point
2 N point DFT 2 N point
N point
x ( n)

y ( n)

y (k )

C x (k )

The sequence x(n) is related to y(n) by

y(n) = x(n) + x(2N-1-n)


y(n) =

x(n),

x(2 N 1 n),

or
0 n N 1

N n 2 N 1

DCT from DFT Cont..

An example for x(n) and y(n) for N=4 is


given,
DCT

DFT

.. . .

DCT from DFT Cont..

The 2N point DFT is given by


Y (k )

2 N 1

kn
y
(
n
)
W

2N ,

0 k 2N 1

n 0

N 1

Y ( k ) x ( n) W
n 0

kn
2N

2 N 1

kn
x
(
2
N

n
)
W

2N , 0 k 2N 1

n N

DCT from DFT Cont..

With a change of variables and after some algebraic


manipulations we get,
N 1

k 2n 1 , 0 k 2 N 1
2N

Y (k ) W2Nk / 2 2 x(n) cos


n 0

So the N-point DCT of x(n), Cx(k) can be obtained


from Y(k) as
k /2
C x (k )

W2 N Y (k ),
0

0 k N 1

otherwise

DCT and DFT Compared

The DFT coefficients are obtained by taking the periodic


extension of the input sequence (eg. N=4 1-D sequence).
The periodic extension of the input sequence introduces
sharp artificial discontinuities which arise from joining the
beginning and end parts of the input sequence.
These discontinuities contribute energy to high frequencies
and reduces the DFTs efficiency in energy compaction.
The 2N point sequence used for the construction of DCT
from DFT is symmetric and doesnt contain any artificial
discontinuity and thus DCTs efficiency in energy
compaction is improved.

You might also like