You are on page 1of 26

Lecture 12

Discrete Cosine Transform


What is a transform?
• Function: rule that tells how to obtain
result y given some input x
• Transform: rule that tells how to obtain a
function G(f) from another function g(t)
Periodic function
• Definition: g(t) is periodic if there exists P
such that g(t+P) = g(t)
• Period of a function: smallest constant P
that satisfies g(t+P) = g(t)
Attributes of periodic function
• Amplitude: max value of g(t) in any period
• Period: P
• Frequency: 1/P, cycles per second, Hz
• Phase: position of the function within a
period
Time and Frequency
• example : g(t) = sin(2pf t) + (1/3)sin(2p(3f) t)
Time and Frequency
• example : g(t) = sin(2pf t) + (1/3)sin(2p(3f) t)

= +
Time and Frequency
• example : g(t) = sin(2pf t) + (1/3)sin(2p(3f) t)

= +
Time and Frequency
1, −a/2 < t < a/2
• example : g(t) {
= 0, elsewhere
Time and Frequency
1, −a/2 < t < a/2
• example : g(t) {
= 0, elsewhere

= +

=
Time and Frequency
1, −a/2 < t < a/2
• example : g(t) {
= 0, elsewhere

= +

=
Time and Frequency
1, −a/2 < t < a/2
• example : g(t) {
= 0, elsewhere

= +

=
Time and Frequency
1, −a/2 < t < a/2
• example : g(t) {
= 0, elsewhere

= +

=
Time and Frequency
1, −a/2 < t < a/2
• example : g(t) {
= 0, elsewhere

= +

=
Time and Frequency
1, −a/2 < t < a/2
• example : g(t) {
= 0, elsewhere


1
= A∑ sin(2π kt )
k =1 k
Time and Frequency
• If the shape of the function is far from regular
wave its Fourier expansion will include infinite
num of frequencies.

1
= A∑ sin(2π kt )
k =1 k
Frequency domain
• Spectrum of freq. domain : range of freq.
• Bandwidth of freq. domain : width of the
spectrum
• DC component (direct current): component of
zero freq.
• AC – all others
Fourier transform
• Every periodic function can be
represented as the sum of sine and cosine
functions
• Transform a function between a time and
freq. domain

G( f ) =
−∞
∫ g (t )[cos(2π ft ) − i sin(2π ft )] dt

g (t ) = ∫ G( f )[cos(2π ft ) + i sin(2π ft )] df
−∞
Fourier transform

Discrete Fourier Transform:


1 n −1 2π ft 2π ft
G ( f ) = ∑ g (t )[cos( ) − i sin( )] 0 ≤ f ≤ n − 1
n t =0 n n
1 n −1 2π ft 2π ft
g (t ) = ∑ G ( f )[cos( ) + i sin( )] 0 ≤ t ≤ n − 1
n t =0 n n

0 n-1
Sampling theory
• Image = continuous signal of intensity
function I(t)
• Sampling: store a finite sequence in
memory I(1)…I(n)
• The bigger the sample, the better the
quality? – not necessarily
Sampling theory
• We can sample an image and reconstruct
it without loss of quality if we can :
– Transform I(t) function from to freq.
Domain
– Find the max frequency fmax
– Sample I(t) at rate > 2 fmax
– Store the sampled values in a bitmap
2fmax is called Nyquist rate
Sampling theory
• Some loss of image quality because:
– fmax can be infinite.
• choose a value such that freq. > fmax do not
contribute much (low amplitudes)
– Bitmap may be too small – not enough
samples
Fourier Transform
• Periodic function can be represented as
sum of sine waves that are integer
multiple of fundamental (basis)
frequencies
• Frequency domain can be applied to a non
periodic function if it is nonzero over a
finite range
Discrete Cosine Transform
• A variant of discrete Fourier transform
– Real numbers
– Fast implementation
Discrete Cosine Transform
• Definition of 2D DCT:
– Input: square image I(i, j) 0 ≤i ≤N-1, 0 ≤j ≤N-1
– Output: a new “image” B(u, v), each pixel stores
the corresponding coefficient of the DCT
N −1 N −1
⎛ π ⋅u ⎞ ⎛π ⋅v
B(u , v ) = C (u , v )∑∑ I (i, j ) cos⎜ (2i + 1)⎟ cos⎜ (2i + 1)⎞⎟
i =0 j =0 ⎝ 2N ⎠ ⎝ 2N ⎠
where
⎧1
⎪⎪ N , if u = 0 or v = 0
C (u , v ) = ⎨
⎪ 2 , otherwise
⎪⎩ N
Discrete Cosine Transform
• Definition of 2D inverse DCT:
N N
⎛ π ⋅u ⎞ ⎛π ⋅v ⎞
I (i, j ) = ∑∑ C (u , v )B(u , v ) cos⎜ (2i + 1)⎟ cos⎜ (2 j + 1)⎟
u =1 v =1 ⎝ 2N ⎠ ⎝ 2N ⎠
where C (u , v ) is defined as before.
Discrete Cosine Transform
• Applications.
• Feature extraction
• De-noising
• Image compression

You might also like