联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codehelp

您当前位置:首页 >> C/C++程序C/C++程序

日期:2023-11-12 07:54

EBU6018 Advanced Transform Methods
EBU5303 Multimedia Fundamentals

Lab 2 – November 2023

Introduction

This lab is common to EBU6018 and EBU5303.

In Part 1 of the lab you will:
Investigate the Wavelet transform and its filter bank implementation for discrete-time signals
Apply the Haar Discrete Wavelet Transform to compress signals.

Marks will go towards the assessment of EBU6018.

In Part 2 of the lab you will implement a simple JPEG encoder / decoder. Marks will go towards the assessment of EBU5303.

The MATLAB programming outcomes from the lab (i.e., MATLAB .m function files and plot figures) are to be handed in as a “folder” of results, showing that you have completed the steps of the lab successfully.


You must also answer some questions directly within this document, which must be saved and submitted with other outcomes in your folder of results.

You must submit your combined report to BOTH EBU6018 AND EBU5303 QM+ course areas.


Part 1 (EBU6018)

1 The Wavelet Transform: Introduction
In EBU6018 lectures, we introduced the wavelet transform, defined in terms of the wavelet’s scaling function wavelet function. In those lectures we used Haar Functions as the wavelet function to perform a Discrete Wavelet Transform (DWT).

We also saw that for a discrete-time signal, the Discrete Wavelet Transform (DWT) can be
implemented as a sequence of filtering followed by downsampling. Using this filterbank we do not need to calculate the mother wavelet ?(t) , we only need the coefficients of the low-pass and high-pass filters ?and

Various files are provided for this lab.

2 DWT of an input vector s[n].
2.1 Discrete Wavelet Transform Filter Bank

Download the file dwt_haar.m. This implements a Haar Discrete Wavelet Transform using
filtering (convolution) and subsampling.
Explain how this Matlab function works in the text box provided, and check that it implements a normalised Haar DWT using the recursion formulas given in the lecture notes and used in tutorial examples.
Test this function by taking the Haar DWT of the following signal, to 2 steps:
s = [-2, 5, 3, -1, 4, -3, 1, 2]
Check the following (and record the values in the text box and save the plots obtained ):
(a) The “length” (Matlab: norm) of the DWT of s, and check it is the same as for s itself.
(b) The first half of the DWT of s contains (scaled) sums of pairs of elements of s, while the
second half contains scaled differences of pairs of elements of s.
(c) The one-step DWT of s is the same as multiplying s (actually the column vector s’) by the following matrix:

Hints: Make sure you always give row vectors to this simple dwt_haar() function.
We are using dyadic scaling so the number of elements in the input vector is a power of 2.

2.2 Inverse DWT Filter Bank
Download the file idwt_haar.m , which implements the inverse DWT.
Apply this to the sequencies you transformed in the previous section. Explain what happens in the text box provided.
Explain how this Matlab function works, and check that it implements a recursion formula similar to the synthesis equation given in the lecture slide on the signal recovery filterbank.
Put your explanations in the text box provided and save your plots to confirm that the original sequence is obtained by applying the function idwt_haar.m.  


3 Signal Compression using the DWT
This exercise is to generate a test signal, plot its DWT, then compress the signal by discarding small values. By reducing the number of non-zero values the result is that fewer bits are needed to represent it. However, the result is some distortion of the original signal.
Download the files: testsig.m, compress.m, uncompress.m, comp_ratio.n.

The file testsig.m generates the following signal:

Modify the file testsig.m so that the first part is now

3.1 Plot this signal and its DWT for 4 levels.
Plot the signal from the modified testsig.m and then its DWT after 1, 2, 3 and then 4 steps of decomposition
3.2 Compress the signal
Applying the file compress.m will compress this signal by transforming it and setting all values below a threshold to zero.
The file uncompress.m inverts the transform carried out by compress.m.
Modify the files compress.m and uncompress.m to include your transform of the signal where indicated.
Plot the original modified signal, the 4-step DWT, the 4-step DWT after thresholding , the reconstructed signal from the inverse DWT and also the error introduced by the DWT thresholding (the difference between the original signal and the reconstructed one). Save the plots obtained.

Part 2 (EBU5303)

4. Image preparation
a.Create a MATLAB function in the file “myJPEG.m”. Read the RGB image file
Monkey.png using the imread MATLAB function and display it with the imshow function.

b.Add code to myJPEG.m to retrieve the pixel dimensions of the image (width x height) and calculate the number of 8x8 blocks of pixels contained in each of the R, G, and B channel (eliminating any remaining pixels).

c.In myJPEG.m, extract the three colour channels (R, G, B) from the original image. Save the three channels as three separate jpeg images in your folder of results.

d.In myJPEG.m, convert the RGB image into Ycbcr. Extract the three channels (Y, cb, cr) and save everything (Ycbcr_image, Y_channel, cb_channel, cr_channel) as separate jpeg images in your folder of results.

e.In myJPEG.m, for each of the R, G, B, Y, cb, and cr channel, and working from left to right, top to bottom, split the matrix of pixels into 8x8 blocks of pixels. Comment your code.

f.Print (disp) the first 8x8 matrix of pixel values for each of the 6 channels (R, G, B, Y, cb, and cr).

g.In myJPEG.m, subtract 128 from each pixel values so they range from -128 to 127.

5. Applying 2D DCT to each block
a.In myJPEG.m, working from left to right, top to bottom, apply the 2D DCT MATLAB function (dct2) to each block of pixel values (for the R, G, B, cb, and cr channels). Save the results in 8x8 matrices of DCT coefficients values. Comment your code.

b.Print (disp) the first 8x8 matrix of DCT coefficients values for the R, G, and B channels.

6. Quantisation (RGB image)
a.In myJPEG.m, declare a standard quantisation matrix named Qstd using the values of the matrix shown below.
= Qstd
b.In myJPEG.m, apply standard quantisation to the 8x8 matrices of DCT coefficients for the R, G, and B channels, using Qstd. Comment your code.
Hint: quantisation is achieved by dividing each DCT coefficient by the corresponding element in the quantisation matrix, and then rounding to the nearest integer value.

c.Print (disp) the first 8x8 matrix of quantised DCT coefficients for each of the R, G, and B channels.

d.In myJPEG.m, create one more quantisation matrix for high quantisation (Qhigh). Comment your code.

Hint: use a quantisation factor to multiply Qstd. The scaled matrix must then be rounded and clipped to have positive integer values ranging from 1 to 255.

e. Print (disp) Qhigh and explain how you created the high quantisation matrix (i.e., what quantisation factor you chose and why).

f.In myJPEG.m, apply high quantisation to the 8x8 matrices of DCT coefficients for the R, G, and B channels, using Qhigh.

g.Print (disp) the 8x8 matrix of quantised DCT coefficients (high quantisation) or each channel (R, G, and B).

h.Compare the 6 matrices obtained in part c. (standard quantisation) and g. (high quantisation) and comment. Discuss how the choice of quantisation matrix might affect the compression rate.

7. Quantisation (Ycbcr image)
a.In myJPEG.m, apply (1) standard, then (2) high quantisation to the DCT coefficients of the cb and cr channels only, using Qstd and Qhigh respectively. Do not quantise the matrices of the Y (luminance) channel.

b.Print (disp) side by side the first 8x8 matrix of quantised DCT coefficients (standard quantisation on the left, high quantisation on the right) for each of the cb and cr channels.

8. Decompression
a.In myJPEG.m, multiply the quantised DCT values of all compressed channels (R, G, B, cb, and cr) by the quantisation matrix you used for quantisation (standard or high). Comment your code.

b.Print (disp) side by side the first 8x8 matrix of restored DCT coefficients for the R, G, B channels (standard quantisation on the left and high quantisation on the right).


c.Compare the six matrices above with the matrices of Question Q5b. (coefficients before quantisation). Comment and explain.


d.In myJPEG.m, apply the inverse DCT (idct2) to all 8x8 matrices of DCT coefficients for all channels (standard and high quantisation, R, G, B, Y, cb, cr). Don’t forget to add 128 to each matrix element and to round the values. Comment your code.

e.Print (disp) the first 8x8 matrix of reconstructed pixel values for the three R, G, B channels, (standard quantisation on the left and high quantisation on the right).

f.Compare the six matrices above with the matrices of Question Q4f. (original pixel values). Comment and explain.

9. Image reconstruction
a.In myJPEG.m, reconstruct the RGB image from the 8x8 blocks of pixel values you obtained in question 8 with standard quantisation of all three R, G, and B channels. Comment your code.

b.Save the image (RGB_standard) as a jpeg image in your folder of results.

c.In myJPEG.m, reconstruct the RGB image from the 8x8 blocks of pixel values you obtained in question 8 with high quantisation of all three R, G, and B channels.

d.Save the image (RGB_high) as a jpeg image in your folder of results.

e.Display the two reconstructed images alongside the original one.

Hint: You may have to cast your pixel values to uint8 to display the images

f.In myJPEG.m, reconstruct the RGB image from the 8x8 blocks of pixel values you obtained in question 8 with standard quantisation of the cb and cr channels. Don’t forget to convert back to RGB. Comment your code.

g.Save the image (cbcr_standard) as a jpeg image in your folder of results.

h.In myJPEG.m, reconstruct the RGB image from the 8x8 blocks of pixel values you obtained in question 8 with high quantisation of the cb and cr channels. Don’t forget to convert back to RGB.

i.Save the image (cbcr_high) as a jpeg image in your folder of results.

j.Display the two reconstructed images alongside the original one.

k.Compare all the images above (standard compression, high compression, RGB, cbcr) and comment. You should clearly see blocky artefacts in the RGB high compression image. If not, go back to Question Q6 e. and modify the Qhigh matrix.

Handing In
Compile the answers to the exercises, including the answers to specific questions, program listings (including comments), and plots from experiments, into a “folder” of results showing that you have completed the lab.
Name the folder: EBU6018_5303_Lab2
Rename this document ‘Lab2_xxxxxxxx’ where xxxxxxxx is your QM student number and save it in your result folder together with your MATLAB files and plot images.

For Part 1: your folder should contain (1) this document; (2) Plots obtained from the implementation of dwt_haar.m: (3) Plots obtained from the implementation of idwt_haar.m;
(4) Your Matlab code for the modified file testsig.m; (5) Plots of DWT of your modified testsig.m; (6) Modified files compress.m and uncompress.m that include the transform of the signal; (7) Plots of the modified test signal, 4-step DWT, 4-step DWT after thresholding, reconstructed signal from IDWT and plot of the error obtained.

For Part 2: your folder should contain (1) this document; (2) your MATLAB code (myJPEG.m); (3) and 12 jpg images (Monkey.jpg, red_channel.jpg, green-channel.jpg, blue_channel.jpg, Ycbcr_image.jpg, Y_channel.jpg, cb_channel.jpg, cr_channel.jpg, RGB_standard.jpg, RGB_high.jpg, cbcr_standard.jpg, cbcr_high.jpg).

Submit the folder as a zip archive on QMplus in BOTH the EBU6018 and EBU5303 course areas before the deadline (i.e., submit twice the same zip archive).
IMPORTANT: Plagiarism (copying from other students or copying the work of others without proper referencing) is cheating, and will not be tolerated.
IF TWO “FOLDERS” ARE FOUND TO CONTAIN IDENTICAL MATERIAL, BOTH WILL BE GIVEN A MARK OF ZERO.
Marking scheme
Part 1 EBU6018 (max 50 marks):
Q2.1 : up to 16 marks
Explanations up to 5 marks
Plots up to 6 marks
Calculations up to 5 marks
Q2.2 : up to 9 marks
Plots up to 6 marks
Explanations up to 3 marks
Q3.1 : up to 2 marks for explanation
up to 10 marks for plots.
Q3.2 : up to 3 marks for explanations
up to 10 marks for plots

Part 2 EBU5303 (max 80 marks):

Q4. Image Preparation: up to 11 marks
Q4.b up to 2 marks
Q4.c up to 3 marks
Q4.d up to 2 marks
Q4.f up to 3 marks (0.5 per correct matrix)
Q4.g up to 1 mark (code)

Q5. 2D DCT: up to 6 marks
Q5.b up to 6 marks (2 per matrix)

Q6. Quantisation (RGB): up to 15 marks
Q6.b up to 2 marks (correct code)
Q6.c up to 3 marks (1 per matrix)
Q6.e up to 4 marks (matrix (2) and explanations (2))
Q6.g up to 3 marks (1 per matrix)
Q6.h up to 3 marks

Q7. Quantisation (Ycbcr): up to 4 marks
Q7.b up to 4 marks (1 per matrix)

Q8. Decompression: up to 21 marks
Q8.a up to 2 marks (correct code)
Q8.b up to 6 marks (1 per matrix)
Q8.c up to 3 marks
Q8.d up to 2 marks (correct code)
Q8.e up to 6 marks (1 per matrix)
Q8.f up to 2 marks

Q9. Reconstruction: up to 23 marks
Q9.a up to 3 marks (correct code)
Q9.b up to 3 marks
Q9.d up to 3 marks
Q9.f up to 3 marks (correct code)
Q9.g up to 3 marks
Q9.i up to 3 marks
Q9.k up to 5 marks

Updated by MPD, MEPD
Modified ARW for EBU6018.
Modified MLB for EBU5303.

相关文章

版权所有:留学生编程辅导网 2021,All Rights Reserved 联系方式:QQ:99515681 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。