0% found this document useful (0 votes)
82 views12 pages

2D Discrete Cosine Transform

The document discusses the discrete cosine transform (DCT), including its 1D and 2D forms. The 1D DCT transforms a signal into its frequency components. The 2D DCT is similarly defined, operating on 2D signals like images. The DCT has real basis functions and good energy compaction properties, making it useful for image and video compression standards like JPEG. Matrix representations of the forward and inverse DCT are also presented.

Uploaded by

akshaya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
82 views12 pages

2D Discrete Cosine Transform

The document discusses the discrete cosine transform (DCT), including its 1D and 2D forms. The 1D DCT transforms a signal into its frequency components. The 2D DCT is similarly defined, operating on 2D signals like images. The DCT has real basis functions and good energy compaction properties, making it useful for image and video compression standards like JPEG. Matrix representations of the forward and inverse DCT are also presented.

Uploaded by

akshaya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 12

EE 7730

2D Discrete Cosine Transform


Discrete Cosine Transform
 1D Discrete Cosine Transform (DCT)
N 1
 (2n  1)k 
F [k ]   f [n] (k ) cos  
n 0  2 N 

 1
 for k  0
 N
where k  0,1,..., N  1 and  (k )  
 2 for k  1, 2,..., N  1
 N

 Inverse DCT
N 1
 (2n  1)k 
f [ n]   F [k ] (k ) cos  
k 0  2N 

Bahadir K. Gunturk EE 7730 - Image Analysis I 2


Discrete Cosine Transform
 2D Discrete Cosine Transform (DCT)
M 1 N 1
 (2m  1)k   (2n  1)l 
F [k .l ]    f [m, n] (k ) (l ) cos   cos  
m0 n 0  2M   2 N 

 1
 for k  0
 N
where k , l  0,1,..., N  1 and  (k )  
 2 for k  1, 2,..., N  1
 N

 Inverse DCT
M 1 N 1
 (2m  1)k   (2n  1)l 
f [m, n]    F [k , l ] (k ) (l ) cos   cos  
k  0 l 0  2M   2N 

Bahadir K. Gunturk EE 7730 - Image Analysis I 3


Discrete Cosine Transform
 The basis functions of DCT are real. (DFT has complex
basis functions.)
 DCT has very good energy compaction properties.
 DCT can be expressed in terms of DFT, therefore, Fast
Fourier Transform implementation can be used.
 In the case of block-based image compression, (e.g.,
JPEG), DCT produces less artifacts along the boundaries
than DFT does.

Bahadir K. Gunturk EE 7730 - Image Analysis I 4


DCT and DFT
 N-point DCT of x[n] can be obtained from 2N-point
DFT of symmetrically extended x[n].

Symmetric extension:  x[n] for n  0,1,..., N  1


x[n]  
 x[2 N  n  1] for n  N , N  1,..., 2 N  1
2 N 1  k 
 j 2  n
DFT of x[n] : X F [k ]   x[n]e  2N 

n 0

N 1
 (2n  1) k 
DCT of x[n] : X C [k ]   (k ) x[ n]cos  
n 0  2 N 

 (k )  j 2Nk 
X C [k ]  e X F [k ]
2

Bahadir K. Gunturk EE 7730 - Image Analysis I 5


Discrete Cosine Transform
a = imread(‘cameraman.tif’);
DCTa = dct2(a);
DFTa = fft2(a); DFTa = fftshift(DFTa);

figure; imshow(log(abs(DCTa)),[ ]);


figure; imshow(log(abs(DFTa)),[ ]);

figure; plot(abs(DCTa(1,:)));
DCT DFT
figure; plot(abs(DFTa(128,:)));

% Also use mesh plots

Bahadir K. Gunturk EE 7730 - Image Analysis I 6


Discrete Cosine Transform
 Matrix Representation of DCT
N 1
 (2n  1) k 
F [k ]   f [n] (k ) cos  
n 0  2N 

  (2*0  1)0   (2*1  1)0   (2*( N  1)  1)0  


  (0) cos    (0) cos     (0) cos   
 2N   2N   2N 
 F [0]     f [0] 
 F [1]    (2*0  1)1 
 (1) cos 
 (2*1  1)1 
 (1) cos  
 (2*( N  1)  1)1 
 (1) cos 
 
       f [1] 
 2N   2N   2N 
     
        
 F [ N  1]    f [ N  1]
 ( N  1) cos  (2*0  1)( N  1)   ( N  1) cos  (2*1  1)( N  1)    ( N  1) cos  (2*( N  1)  1)( N  1) 
      
 2N   2N   2N 
F f
D
F  Df

Bahadir K. Gunturk EE 7730 - Image Analysis I 7


Discrete Cosine Transform
 Matrix Representation of Inverse DCT
N 1
 (2n  1)k 
f [n]   F [k ] (k ) cos  
k 0  2 N 

  (2*0  1)0   (2*0  1)1   (2*0  1)( N  1)  


  (0) cos  2N
  (1) cos 
2N
   ( N  1) cos 
2N
 
     
 f [0]     F [0] 
 f [1]    (0) cos  (2*1  1)0  
 (2*1  1)1 
(1) cos   
 (2*1  1)( N  1) 
( N  1) cos 
 
         F [1] 
 2N   2N   2N 
     
        
 f [ N  1]    F [ N  1]
 (0) cos  (2* ( N  1)  1)0   (1) cos  (2*( N  1)  1)1    ( N  1) cos  (2*( N  1)  1)( N  1) 
      
 2N   2N   2N 
f F

D1
f  D1F

Bahadir K. Gunturk EE 7730 - Image Analysis I 8


Discrete Cosine Transform
 Inverse DCT matrix is equal to the transpose of DCT
matrix!

D1  DT

DDT  DT D  I

Bahadir K. Gunturk EE 7730 - Image Analysis I 9


Discrete Cosine Transform
 2D Discrete Cosine Transform (DCT)
M 1 N 1
 (2m  1)k   (2n  1)l 
F [k .l ]    f [m, n] (k ) (l ) cos   cos  
m0 n 0  2M   2 N 

 1
 for k  0
 N
where k , l  0,1,..., N  1 and  (k )  
 2 for k  1, 2,..., N  1
 N

 Inverse DCT
M 1 N 1
 (2m  1)k   (2n  1)l 
f [m, n]    F [k , l ] (k ) (l ) cos   cos  
k  0 l 0  2M   2N 

Bahadir K. Gunturk EE 7730 - Image Analysis I 10


Discrete Cosine Transform
 For two-dimensional signals:

Β = DΑDT

     T 
=
 Β   D  A  D 
     

Bahadir K. Gunturk EE 7730 - Image Analysis I 11


Discrete Cosine Transform
 Try in MATLAB:
f=[1 2 3];
Df1 = dct(f)

D=dctmtx(3);
Df2=D*f;
f2=D’*f;

g=[1 2 3; 4 5 6; 7 8 9];
Dg1=dct2(g);
Dg2=D*g*D’;

Bahadir K. Gunturk EE 7730 - Image Analysis I 12

You might also like