Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

1    Huffman Coding (30 marks)

(a) What is the entropy η of the image below, where numbers (0, 20, 50, 99) denote the gray-level intensities?  (10 marks)

(b) Show step by step how to construct the Huffman tree to encode the above four intensity values in the image. Show the resulting code for each intensity.  (10 marks)

(c) What is the average number of bits needed for each pixel, using your Huffman code? (10 marks) 

2    DCT (30 marks)

When the block size is 8×8, the definition of the 2D-DCT is given below:

where i,u = 0, 1, 2, ··· , 8;    j,v = 0, 1, 2, ··· , 8;

(a) For an 8×8 grayscale image, each pixel is in the range [0, 255], after applying the above 2D-DCT, we obtain a new 8×8 matrix, what is the largest value an element of that matrix could be?  and for what input image?  and show all elements of the matrix for that image. (8+8+8 = 24 marks)

(b) For that image in (a), if we first subtract the value 128 from each pixel of the whole image and then carry out the 2D-DCT, what is the effect on the DCT value F[2,3]? (6 marks)

3    Implementation of LZW (40 marks)

To compress the following string of zeros/ones, we consider the dictionary-based LZW com- pression algorithm.   Suppose the initial dictionary is  {‘0’:0,  ‘1’:1}.   Implement the LZW compression and decompression algorithms using two separate functions.

011001100111000

(a) Show the constructed dictionaries for both compression and decompression stages.  (10 marks)

(b) Calculate the compression rate.  (5 marks)

(c) Show the full and correct python code in a separate .py file.  (25 marks)

Note:  For questions in Sections 1/2, detailed steps need to be provided.  If you only show the final numbers/results, the majority of marks will be deducted. For Section 3, you need to submit python code as well.

What you need to submit:

1. The full answer sheet (a single PDF file) for the above questions in Sections 1/2/3.

2. A single but complete .py file for Section 3.