A Project:
In this assignment, you will implement a few parts of a simplified Baseline JPEG. Specifically, you will implement the quantizer/dequantizer, and use the built-in dct transform and its inverse. Although for the calculations requested below you need to know the size of the coded bitstreams, you should note that the actual coded bitsreams need not be computed, and therefore, you should not implement the entropy coder/decoder stage of JPEG.
Your implementation should take as input the original image and a scalar for the quantization matrix. Conceptually, the output of the compression is a bit stream consisting of a header and the data; the header contains information that specifies the two Huffman tables (one for the DC terms, and one for the AC terms); the data consist of two parts: the first part is the bit stream for the DC terms, and the second part is the bit stream for the AC terms. Note that your implementation is for gray-scale images only, and that you should use one specific quantization matrix (the one given in the lecture notes). In particular, since the quantization matrix is fixed, you need not store it in the output of the coder.
To simplify matters, we remove the restriction that the Huffman codewords must be at most 16 bits long. Rather, you can allow them to be of any length.
a)
Apply your algorithm on the Lena image with different scalars, and identify
which scalars give compression ratios 10, 15, and 30.
b)
For each compression ratio indicated above, compute the SNR.
c)
Plot the compression ratios indicated above against the corresponding
scalars (the x-axis is the scalars, the y-axis is the compression ratios).
Also, plot the SNR's against the same scalars.
d)
Repeat a-c on another image of your choice. Make sure you show the original
image.