EE3414 Multimedia Communication System I Spring 2003, Yao Wang __________________________________________________________________________________________________ Homework 9 Solution Written Assignment: 1. For the 2x2 image S 4 2 , 2 1 a. Determine its 2D-DFT coefficients, T0,0, T0,1, T1,0, T1,1. Show that the reconstructed image from the original DFT coefficients equal to the original image. U k ,l U k (Ul )T U 0, 0 1 1 1 1 1 1 1 1 1 1 1 1 , U 0,1 , U1,0 , U1,1 2 1 1 2 1 1 2 1 1 2 1 1 M 1 N 1 Tk ,l (U k ,l , S ) U k*,l ,m ,n Sm ,n m 0 n 0 T0,0 = ½(4+2+2+1)=4.5 T0,1 = ½(4-2+2-1)=1.5 T1,0 = ½(4+2-2-1)=1.5 T1,1 = ½(4-2-2+1)=0.5 Verify: b. T0,0U 0,0 T0,1U 0,1 T1,0U1,0 T1,1U1,1 S Set all coefficients except T0,0 to zero and then reconstruct the image. What effect do you see? 4.5 4.5 S ' T0,0U 0,0 4.5 4.5 When the reconstruction uses only the basis corresponding to T0,0, only the zero-frequency (or DC) component of the original image is retained, and the reconstructed image has a constant gray level at every pixel. The constant is a scaled version of the mean value of the original image. c. Set all coefficients except T0,1 to zero and then reconstruct the image. What effect do you see? 0.75 0.75 S ' T0,1U 0,1 0.75 0.75 The basis corresponding to coefficient T0,1 is U0,1, which is constant vertically (i.e., zero frequency in the vertical direction), and has a sharp transition (i.e. high frequency) in the horizontal direction. The image reconstructed using T0,1 only is a scaled version of U0,1, and hence shows a vertical edge. d. Set all coefficients except T1,0 to zero and then reconstruct the image. What effect do you see? 0.75 0.75 S ' T1,0U1,0 0.75 0.75 The basis corresponding to coefficient T1,0 is U1,0 , which is constant horizontally (i.e., zero frequency in the horizontal direction), and has a sharp transition (i.e. high frequency) in the vertical direction. The image reconstructed using T1,0 only is a scaled version of U1,0 , and hence shows a horizontal edge. e. Set all coefficients except T1,1 to zero and then reconstruct the image. What effect do you see? 0.25 0.25 S ' T1,1U1,1 0.25 0.25 The basis corresponding to coefficient T1,1 is U1,1 , which varies both horizontally and vertically. The image reconstructed using T1,1 only is a scaled version of U1,1 , and hence shows a diagonal edge. 2. For the 4x4 image S given below, compute its 2D DFT, reconstruct it using different DFT windows to evaluate the effect of different types of filters. a. Determine the 2D-DFT coefficients, Tk,l, k=0,1,2,3;l=0,1,2,3. Tk ,l (U k ,l , S ) T0,0 1 1 1 (U 0,0 , S ) 4 1 1 1 1 1 9 1 1 1 1 , 1 1 1 9 1 1 1 1 1 9 1 9 1 9 1 (9 1 9 1 1 9 1 9 9 1 9 1 1 9 1 9) 20 1 9 1 4 9 1 9 T0,1 (U 0,1 , S ) 0 T0,2 (U 0,2 , S ) 0 T0,3 (U 0,3 , S ) 0 T1,0 (U1,0 , S ) 0 T1,1 (U1,1 , S ) 0 T1,2 (U1,2 , S ) 0 T1,3 (U1,3 , S ) 0 T2,0 (U 2,0 , S ) 0 T2,1 (U 2,1 , S ) 0 T2,2 (U 2,2 , S ) 16 T3,0 (U 3,0 , S ) 0 T3,1 (U 3,1 , S ) 0 T3,2 (U 3,2 , S ) 0 T3,3 (U 3,3 , S ) 0 b. Show that the reconstructed image from the original DFT coefficients equal to the original image. M 1 N 1 S ' Tk ,lU k ,l T0,0U 0,0 T2,2U 2,2 k 0 l 0 5 5 5 5 5 5 5 4 4 4 4 9 5 5 5 4 4 4 4 1 5 5 5 4 4 4 4 9 5 5 5 4 4 4 4 1 c. 1 9 1 9 1 9 S 1 9 1 9 1 9 Modify the DFT coefficients using following two different window masks (W1 and W2) and reconstruct the image using the modified DFT coefficients. What effect do you see with each window? You may use “matlab” to do the calculation. A sample matlab code (DFT_mask.m) that you can use (with modification of the image values and the filter masks) is available at the course website. Feel free to try other image values and different filter masks. 9 1 S 9 1 1 9 1 1 0 9 1 9 , W1 0 1 9 1 9 1 9 0 0 0 0 0 0 0 0 0 , W2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 The mask W1 retains only the T00 coefficient. The reconstructed image from T00 is 5 5 5 5 5 5 5 5 Sˆ T0, 0 U 0, 0 5 5 5 5 5 5 5 5 The mask W2 retains only the T2,2 coefficient. The reconstructed image from T2,2 is 4 4 4 4 4 4 4 4 Sˆ T2, 2 U 2, 2 4 4 4 4 4 4 4 4 Note that if you use the Matlab script to do the calculation, you will get T0,0 =80, T2,2=64. The reconstructed images from T0,0 and T2,2 alone, however, would be the same. The reason the DFT coefficients are different with matlab is because the definition of the forward DFT in matlab differs from the one I introduced in the class by a scaling factor. Correspondingly, the inverse transform also differ by a scaling factor. The transform definitions introduced in class and that in Matlab are given below. The definition given in the class yields a unitary transform, so that you can use the inner product with the basis images to obtain the coefficients, and use the sum of basis images to obtain the reconstructed image. As far as this class is concerned, you should understand how to compute the DFT coefficients and reconstruct an image from original or modified coefficients using the definition and the method introduced in the class. Definition in Class (unitary t ransform) Definition in Matlab (non - unitary tr ansform) Forward transform (2D - DFT) : Forward transform (2D - DFT) : Tk ,l M 1 N 1 1 k l S m,n exp( j 2 ( M m N n)), MN m0 n0 k 0,1,..., M 1, l 0,1,..., N 1 Inverse transform (2D - IDFT) : S m ,n M 1 N 1 1 k l Tk ,l exp( j 2 ( M m N n)), MN k 0 l 0 m 0,1,..., M 1, n 0,1,..., N 1 M 1 N 1 Tk ,l m 0 k l m n)), M N n 0 k 0,1,..., M 1, l 0,1,..., N 1 S m ,n exp( j 2 ( Inverse transform (2D - IDFT) : S m ,n 1 M 1 N 1 k l Tk ,l exp( j 2 ( M m N n)), MN k 0 l 0 m 0,1,..., M 1, n 0,1,..., N 1