| CS225 | October 11, 2011 |
| Youssef |
Problem 1: (25 points)
Let X=[0,0.5, 0.5, 0.7, 0.8, 0.8, 0.8, 1, 1.2, 1.2, 1.2, 1.3, 1.6, 1.74, 1.75, 1.8, 1.8, 1.95, 2.0, 2.2, 2.3, 2.3, 2.4, 2.45, 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 color Desert image from the course Website
(Desert) and convert it to grayscale.
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.
Remedy: To resolve this problem, and convert the image to grayscale in the process, do the following:
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.
Now the image in X is in the "right" representation. That is, you can run
on X all the compression-related algorithms you have studied, and you will
get the expected outcome. In this problem, use the matrix X whenever "Desert"
is referenced. (Note: To display the image in Matlab, do: imagesc(X);colormap(gray);)
a) Compute the entropy of the Desert image.
b) Referring back to DPCM with parameters
,
compute the residual image
of Desert for each of the following
cases of
: (1,0,0), (1/3,1/3,1/3), (.5,0,.5), (1,-1,1), (.75,-.5,.75).
(Note:
. However,
for elements of the first row and first column the following
rules apply:
R(1,1)=floor(X(1,1)),
R(1,j)=floor(X(1,j)-X(1,j-1)),
R(i,1)=floor(X(i,1)-X(i-1,1))
c) Compute the entropy of each of the residual images
obtained in part (b).
Call
the residual image of minimum entropy; display and print the
image
. ( The image
will be processed in the next problem.)
Problem 3: (25 points)
a) Quantize
(of Problem 2-c) into
with an 8-level uniform quantizer,
then apply RLE on the row-wise flattened
yielding a sequence
, and finally compute the entropy of
. You need to give the entropy only
(i.e., do not give
or
).
b) Dequantize
into
and reconstruct from
an approximation
.
Display and print
, and compute
the signal-to-noise ratio (SNR) of
.
(Note:
,
,
,
)
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 Desert image
using
block-oriented DCT.
First apply dct2 on each of the contiguous
blocks
of
. 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
16-level quantizer. Afterwards, quantize the
9 elements in the 2nd, 3rd, and 4th counterdiagonals of each block
with a separate 8-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
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 32-level uniforn quantizer, while the remaining 63 terms of each block are zeroed out.