CS225 October 14, 2008
Youssef
Homework 3
Due Date: November 11, 2008


Problem 1: (25 points)

Let X=[0,0.6, 0.75, 0.8, 0.8, 0.8, 0.9, 1, 1, 1.3, 1.6, 1.6, 1.8, 1.85, 1.86, 1.9, 1.93, 1.95, 2.2, 2.3, 2.3, 2.35, 2.37, 2.6, 2.9].

a)     Find the decision levels (d's) and reconstruction values (r's) of the 3-level optimal Max-Lloyd quantizer for X. (3-level means the quantizer has three intervals. Assume that d0=0 and d3=3.)

b)     Quantize X with the optimal quantizer of part (a), then dequantize it. Show the quantized values as an array, and also the dequantized values as an array. Compute the MSE.

c)     Do the same as in (b) except this time the quantizer is a 3-level uniform quantizer, where again d0=0 and d3=3.


Problem 2: (25 points)

This problem will require you to download the Lena image from the course Website (Lena).

Remarks: Most images, which are in gif or other standard formats, are represented as an index matrix "I" coupled with a colormap (call it "map"). The color map is a 3-column table: every row consists of three components, representing one color. Thus, if I(i,j)=k, then the actual pixel value at (i,j) is the color represented in row k of map. This is true even if the image is a grayscale image.
The arrangement of the rows (i.e., colors) in the map is random, that is, two very close colors are not necessarily near each other in the map; in fact, they could be far apart.
The implication of this image representation scheme is that none of the image compression processes (e.g., transforms, quantization, etc.) would give the expected results.

Remedy: To resolve this problem, do the following:

Now the image in G is in the "right" representation. That is, you can run on G all the compression-related algorithms you have studied, and you will get the expected outcome.

a)     Compute the entropy of the Lena image.

b)     Referring back to DPCM with parameters $(a,b,c)$, compute the residual image $R$ of Lena for each of the following cases of $(a,b,c)$: (1,0,0) , (0,0,1), (.5,0,.5) , (1,-1,1), (.75,-.5,.75). (Note: $R(i,j)=floor(X(i,j)-(a*X(i,j-1)+b*X(i-1,j-1)+c*X(i-1,j))$. However, for elements of the first row and first column the following rules apply: R(1,1)=X(1,1), R(1,j)=X(1,j)-X(1,j-1), R(i,1)=X(i,1)-X(i-1,1)

c) Compute the entropy of each of the residual images obtained in part (b). Call $E$ the residual image of minimum entropy; display and print the image $E$. ( The image $E$ will be processed in the next problem.)


Problem 3: (25 points)

a)     Quantize $E$ into $E'$ with an 8-level uniform quantizer, then apply RLE on the row-wise flattened $E'$ yielding a sequence $e$, and finally compute the entropy of $e$. You need to give the entropy only (i.e., do not give $E'$ or $e$).

b)     Dequantize $E'$ into $\hat{E}$ and reconstruct from $\hat{E}$ an approximation $\hat{X}$. Display and print $\hat{X}$, and compute the signal-to-noise ratio (SNR) of $(X,\hat{X})$. (Note: $\hat{X}(1,1)=\hat{E}(1,1)$, $\hat{X}(1,j)=\hat{X}(1,j-1)+\hat{E}(1,j)$, $\hat{X}(i,1)=\hat{X}(i-1,1)+\hat{E}(i,1)$, $\hat{X}(i,j)=a*\hat{X}(i,j-1)+b*\hat{X}(i-1,j-1)+c*\hat{X}(i-1,j)+
\hat{E}(i,j)$)

c)     Repeat (a) and (b) except now you should use a 8-level optimal reconstruction quantizer where all the bins (i.e., intervals) are of equal size.

d)     Repeat (a) and (b) except now you should use a 8-level Max-LLoyd optimal quantizer.


Problem 4: (25 points)

In this problem you will compress the Lena image $X$ using $8\times 8$ block-oriented DCT. First apply dct2 on each of the contiguous $8\times 8$ blocks of $X$. The top leftmost term of each transformed block is called the DC term. Quantize all the DC terms of all the blocks as one data set, using a uniform 64-level quantizer. Afterwards, quantize the 9 elements in the 2nd, 3rd, and 4th counterdiagonals of each block with a separate 16-level uniform quantizer, while the remaining 54 elements of each block are zeroed out.

a)     Compute the resulting bit rate and the compression ratio.

b)     Reconstruct $\hat{X}$ by dequantizing and applying the inverse DCT on each separate block. Print the reconstructed image, and compute its SNR.

c)     Repeat (a) and (b) except that this time only the DC terms are quantized with a 64-level uniforn quantizer, while the remaining 63 terms of each block are zeroed out.