ELEC5306-无代写
时间:2024-03-20
Video Intelligence and Compression 1
run length coding
ELEC5306 Video Intelligence and Compression
Project #1: JPEG Compression
Due: 31 March 2024 11:59PM
1 Objectives
• 2D discrete cosine transform
• Explanation for run-length coding
• Arithmetic coding
• Explanation for quantization table
• Evaluation in PSNR
2 Questions
2.1 2D discrete cosine transform
• Write a function,
form. The function should be exactly the same as
, to perform 2D discrete cosine trans-
scipy.fftpack.dct(x, type=2, n=None, axis=−1, norm='ortho', overwrite x=False).
Hint:
The equation for this transform is at https://docs.scipy.org/doc/scipy/reference/
generated/scipy.fftpack.dct.html. More specifically, Type II, with norm =I orthoI.
2.2 Explanation for run-length coding
The function takes a 1D array as input, output symbols and values. Symbol
is a list of pairs in the format of (A, B). Value is a list of char.
• Explain the meaning of A, B, and char.
• Given a pair of ‘symbols‘ and ‘values‘, get the original array from it.
Hint:
Besides reading the code, a more straightforward way is to input an actual array to the
function
recovered original array.
and print the output. This is also useful to double check the
dct 2d type 2 norm ortho(img)
run length coding
Project #1: JPEG Compression
ELEC5306 Video Intelligence and Compression 2
2.3 Arithmetic Coding
• Given the source alphabet Х = {C, E, L, #} and probability function
P = {P(C), P(E), P(L), P(#)} = {0.5, 0.2, 0.2, 0.1}
Encode the sequence “ELEC#” with Arithmetic coding. Calculate the encoding output
in binary form (i.e. 0.1011001...). Provide the result with your full calculation process.
Please refer to the following link and use the demonstrated approach:
https://www.youtube.com/watch?v=7vfqhoJVwuc
2.4 Quantization table
• Explain the effect of the scalar of values in the quantization table. Discuss the mathematical
and perceptual basis behind the trade-offs involved.
• Explain why values in the top-left corner are lower, and those in the right-bottom
corner are higher.
• Design a quantization table that causes no loss in information in this quantization step
given the coefficients from DCT are all integers.
Hint:
The spatial location of the element is related with the frequency in cosine-transformed map.
2.5 PSNR
• Write a function, , to calculate PSNR for a pair of images.
• Calculate the PSNR for the original image and the compressed image.
Hint:
Use Numpy for tensor calculation. The formulation of PSNR is given in https://en.
wikipedia.org/wiki/Peak_signal-to-noise_ratio.
2.6 Advanced Analysis
• Design a theoretical quantization table that minimizes information loss for text-
heavy images. Provide a justification for your design choices.
• Propose a methodology for empirically evaluating the impact of different quantization
tables on image quality and compression efficiency. This should include both objective
metrics (e.g., PSNR, SSIM) and the protocols to evaluate your compressed image
visually.
• Use the method you proposed in the last question to evaluate your quantization table.
psnr(image1, image2)
Project #1: JPEG Compression
ELEC5306 Video Intelligence and Compression 3
Project #1: JPEG Compression
ELEC5306 Video Intelligence and Compression 4
3 Submission and Grades
You are supposed to finish this project by yourself. Your submission, a Colab notebook, should
include
• the complete code that was well-commented.
• results including numbers, analysis text, and figures.
The file should be named as ‘project1_unikey_ipynb’ with no spaces in the file name and
submitted on Canvas, e.g. ‘project1_abcd0123.ipynb’. Note that your codes need to be well
commented and the written part needs to have clear sections. It is important that the results
must be generated by the source codes you submitted, otherwise your work may be regarded as
plagiarism. More detailed requirements are as follows:
• Your submissions should strictly follow the instructions.
• Your codes are correct, well organized and well commented.
• The written part are well organized and has few typos. The report should contain the
correct formulas when they are necessary.
• The visualization results are clear and well defined.
• You have shown your insights into the results and drawn some reasonable conclusions.
• No copy from your classmates. If you and some of your classmates copied codes from the
same online resource, you will also be penalized if you do not make any modifications or
provide the reference.
• Give references on all the codes and papers you referred to.
Project #1: JPEG Compression
ELEC5306 Video Intelligence and Compression 5
Appendix: Marking Scheme
The total marks f or Project 1 i s 20 i n your final score, and Question 2.1, 2.2, 2.3, 2.4, 2.5, 2.6
accounts for 10%, 10%, 20%, 20%, 10% and 20%, respectively, the format accounts for 10%. The
numbers in the following chart are in percentages.
Q2.1
the code runs successfully and gets the same result of the built-in function 5
the code is well-annotated 5
Q2.2
correct explanation 8
correct array 2
Q2.3
correct result 5
clear explanation of the calculating process 15
Q2.4
reasonable explanation of the scalar 10
reasonable explanation of the pattern 5
right quantization table 5
Q2.5
correct PSNR function 2
get the PSNR of two images required 5
well commented codes 3
Q2.6
reasonable quantization table and explanation 10
reasonable method description 5
the proposed table is properly evaluated 5
format format of the submitted Colab file 10
punishment
cheating -100
late submission per day -5
messy file -20