In this problem we are going to implement and test a rough DCT-based compressor-
ID: 3760329 • Letter: I
Question
In this problem we are going to implement and test a rough DCT-based compressor- Write a MATLAB script named DCT_cmp . m to do the following: 1) Read grayscale image ''boat.tiff'' 2) Apply DCT transform to the image using dct2 (), and store the DCT coefficient in 2-D matrix coeff. 3) Set quantization step=8. 4) Apply scalar quantization to coeff, that is, use coeff to divide the quantization step, and round the quotient to the closet integer (use round O). 5) Apply de-qauntization. Multiply the quantized coefficient by the quantization step. 6) Apply inverse DCT transform to the de-quantized coefficients. you will get reconstructed image. 7) Display the reconstructed image using imshow (). After completing the script, you can play with it. It is actually a rough compressor (just without the coding part). Please change the quantization step to 16 and 64, and compare the qualities of the reconstructed images. Include the reconstructed images and their PSNRs with quantization steps 8, 16, and 64 in your submission. and explain the relationship between the quantization step and the quality of the reconstructed image.Explanation / Answer
I = imread('boat.tif');
I = im2double(I);
T = dctmtx(8);
dct = @(x)T * x * T';
B = blkproc(I,[8 8],dct);
mask = [1 1 1 1 0 0 0 0
1 1 1 0 0 0 0 0
1 1 0 0 0 0 0 0
1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0];
B2 = blkproc(B,[8 8],@(x)mask.* x);
invdct = @(x)T' * x * T;
I2 = blkproc(B2,[8 8],invdct);
imshow(I), figure, imshow(I2)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.