Docsity

Lecture 11 : Discrete Cosine Transform, Slides of Fourier Transform and Series

Partial preview of the text

Download Lecture 11 : Discrete Cosine Transform and more Slides Fourier Transform and Series in PDF only on Docsity!

Lecture 11 : Discrete

Cosine Transform

Moving into the Frequency Domain

Frequency domains can be obtained through the transformation from one ( time or spatial ) domain to the other ( frequency ) via Fourier Transform (FT) ( see Lecture 3) — MPEG Audio. Discrete Cosine Transform (DCT) ( new ) — Heart of JPEG and MPEG Video , MPEG Audio.

Note We mention some image (and video) examples in this

section with DCT (in particular) but also the FT is commonly applied to filter multimedia data. External Link: MIT OCW 8.03 Lecture 11 Fourier Analysis Video

What do Frequencies Mean in an Image?

Large values at high frequency components mean the data is changing rapidly on a short distance scale. E.g .: a page of small font text, brick wall, vegetation. Large low frequency components then the large scale features of the picture are more important. E.g. a single fairly simple object which occupies most of the image.

The Road to Compression

How do we achieve compression? Low pass filter — ignore high frequency noise components Only store lower frequency components High pass filter — spot gradual changes If changes are too low/slow — eye does not respond so ignore?

The Discrete Cosine Transform (DCT)

Relationship between DCT and FFT DCT (Discrete Cosine Transform) is similar to the DFT since it decomposes a signal into a series of harmonic cosine functions. DCT is actually a cut-down version of the Fourier Transform or the Fast Fourier Transform (FFT): Only the real part of FFT (less data overheads). Computationally simpler than FFT. DCT— effective for multimedia compression (energy compaction). DCT much more commonly used (than FFT) in multimedia image/vi deo compression — more later. Cheap MPEG Audio variant — more later. FT captures more frequency “fidelity” ( e.g. phase).

DCT vs FT

(a) Fourier transform, (b) Sine transform, (c) Cosine transform.

1D DCT

For N data items 1D DCT is defined by: and the corresponding inverse 1D DCT transform is simply F

  • (u), i.e.: where F ( u )=(
N

1

i = 0 N − 1 Λ ( u ) cos[ π u 2N (2i+ 1 ) ] f ( i ) f ( i ) = F − 1 ( u ) = (

N

1 2

u = 0 N − 1 Λ ( u ) cos[ π u 2N ( 2i+ 1 )] f ( u ) Λ (ξ)=

1 √ 2 for ξ= 0

1 otherwise }

Plots of f(I) and F(U)

(^01 2 3 4 5 6 7 ) 10 20 30 40 50 60 70 80 90 100 (^01 2 3 4 5 6 7 ) 50 100 150 200 250 300 f(i) = 100 for i=0.. .7 F(u): F( 0 ) ≈ 283, F(1...7)= 0

F( 0 ) Basis Function Plot

 - 01 2 3 4 5 6 7 

DCT Example: F(1.. .7)

So for u = 1: Note: Λ( 1 ) = 1 and we have cos to work out: so F( 1 ) is computed as: (since etc. ) Here the values form the basis function F(2...7) similarly = 0 cos ( π 16 )=−cos( 15 π 16 ) , cos( 3 π 16 )=−cos( 13 π 16 ) F (^) i ( 1 )={^1 2 cos ( π 16 ) ,^1 2 cos ( 3 π 16 ) ,^1 2 cos ( 5 π 16 ) , ... ,^1 2 cos( 11 π 16 ) ,^1 2 cos( 13 π 16 ) ,^1 2 cos ( 15 π 16 )} F ( 1 ) = 1 2 ( cos π 16 ⋅ 100 + cos 3 π 16 ⋅ 100 + cos 5 π 16 ⋅ 100 +cos 7 π 16 ⋅ 100

  • cos 9 π 16 ⋅ 100 +cos 11 π 16 ⋅ 100 +cos 13 π 16 ⋅ 100 +cos 15 π 16 ⋅100 ) = 0

DCT Matlab Example

DCT1Deg.m explained: i = 1 : 8 % dimension of vector f(i) = 100 % set function figure( 1 ) % plotf stem(f); %compute DCT D =dct(f); figure( 2 ) % plotD stem(D); Create our function f, and plot it. Use MATLAB 1D dct function to compute DCT of f and plot it. 17

DCT Matlab Example

% Illustrate DCT bases compute DCT bases % with dctmtx bases =dctmtx( 8 ); % Plot bases:each row(j) of bases is the jth %DCT Basis Function for j= 1 : 8 figure %increment figure stem(bases(j,:)); %plot rows end MATLAB dctmtx function computes DCT basis functions. Each row j of bases is the basis function F(j). Plot each row. 18

2D DCT For a 2D N by M image 2D DCT is defined: and the corresponding inverse 2D DCT transform is simply F

  • (u,v), i.e.: F ( u , v ) = (

N ) 1 (^2) ⋅ (

M ) 1 2

i = 0 N − 1

j = 0 M − 1 Λ ( u )⋅Λ ( v )× cos π u 2N (2i+ 1 )cos π v 2M (2j+ 1 )⋅ f ( i , j ) f ( i , j ) = F − 1 ( u , v ) = (

N ) 1 (^2) ⋅ (

M ) 1

i = 0 N − 1

j = 0 M − 1 Λ ( u )⋅Λ( v )× cos π u 2N ( 2i+ 1 )cos π v 2M ( 2j+ 1 )⋅ F ( u , v )

Applying The DCT

Similar to the discrete Fourier transform: It transforms a signal or image from the spatial domain to the frequency domain. DCT can approximate lines well with fewer coefficients. Helps separate the image into parts (or spectral sub-bands) of differing importance (with respect to the image’s visual quality).