HW8_solution - Department of Electrical & Computer Engineering

advertisement
Polytechnic University, Dept. Electrical and Computer Engineering
EE3414 Multimedia Communication System I
Spring 2004, Yao Wang
___________________________________________________________________________________
Homework 8 (DCT)
(solution)
1. For the 2x2 image S given below, compute its 2D DCT, reconstruct it by retaining different
number of coefficients to evaluate the effect of different basis images.
a. Determine the four DCT basis images.
b. Determine the 2D-DCT coefficients for S, Tk,l, k=0,1;l=0,1.
c. Show that the reconstructed image from the original DFT coefficients equal to the
original image.
d. Modify the DCT coefficients using the given window masks (W1 to W5) and reconstruct
the image using the modified DCT coefficients. (for a given mask, “1” indicates to retain
that coefficient, “0” means to set the corresponding coefficient to zero) What effect do
you see with each mask and why?
9 1
1 0
0 1
0 0
0 0
1 0
S
, W1  0 0, W2  0 0, W3  1 0, W4  0 1, W5  0 1
1
9












Solution:
a) The 1D DCT basis vectors are defined as:
 k

uk , n   (k ) cos
(2n  1) , (0)  1 , (k )  2 , k  0,
N
N
 2N

Letting N=2, k=0,1 and n=0,1, we obtain the following two basis vectors:
u0,0  1 1
u1,0   cos( 4)  1  1 
u0    
, u1     



 
2 1
2  1
 u0,1 
u1,1  cos(3 4)
The 2x2-point 2D DCT basis vectors are:
U 0,0  u 0uT0 
1 1 1
1 1  1
11 1 
1  1  1
,U 0,1  u 0u1T  
,U1,0  u1u T0  
,U1,1  u1u1T  




2 1 1
2 1  1
2  1  1
2  1 1 
b) Using the inner product of S with the basis vectors, we obtain
T0,0  (S, U0,0 )  (9  1  1  9) / 2  10, T0,1  (S, U0,1 )  (9  1  1  9) / 2  0,
T1,0  (S, U1,0 )  (9  1  1  9) / 2  0, T1,1  (S, U1,1 )  (9  1  1  9) / 2  8.
c) The reconstructed image using all the coefficients is
10 1 1 8  1  1 9 1
T0,0 U 0,0  T0,1U 0,1  T1,0 U1,0  T1,1U1,1  


2 1 1 2  1 1  1 9
which is exactly the same as the original S.
d) The reconstructed image using the 5 masks are respectively
0 0 
0 0 
10 1 1 5 5

, S 2  T0,1U 0,1  0  
, S3  T1,0 U1,0  0  




,
2 1 1 5 5
0 0 
0 0 
9 1
8  1  1  4  4
S 4  T1,1U1,1  

, S5  T0,0 U 0,0  T1,1U1,1  S1  S 4  


  S.
2  1 1   4 4 
1 9
The image S is composed of a diagonal pattern with non-zero mean, and thus only the constant
basis image ( U 0 , 0 ) and the diagonal basis image ( U1,1 ) have non-zero coefficients.
S1  T0,0 U 0,0 
2. For the same image S as given in Prob. 1, quantize its DCT coefficients using the quantization
matrix Q. Determine the quantized coefficient indices and quantized values. Also, determine the
reconstructed image from the quantized coefficients.
3 3
Q

3 5
Solution: for a given coefficient with value f and quantization step size Q, it is quantized index
is Qindex(f)=floor((f+Q/2)/Q), and the quantized value is Q(f)=Qindex(f)*Q.
For coefficient f= T0, 0 =10, Q=3, Qindex(f)=floor((10+1.5)/3)=3, T̂0,0 =Q(f)= 3*3=9
For coefficient f= T1,1 =8, Q=5, Qindex(f)=floor((8+2.5)/5)=2, T̂1,1 =Q(f)=2*5=10
For T0,1  T1,0  0, Tˆ0,1  Tˆ1,0  0 . The reconstructed image from the quantized coefficients is
9 1 1 10  1  1  9.5  0.5
Sˆ  Tˆ0,0 U 0,0  Tˆ0,1U 0,1  Tˆ1,0 U1,0  Tˆ1,1U1,1  


2 1 1 2  1 1   0.5 9.5 
Download