salim.alam2
Junior Member level 3
I hope you are doing well.
I am a beginner, I was working on a project in matlab and what I have to do is:
1. Read in BMP image.
2. Convert image from RGB to YCbCr.
3. Subsample image using formats 4:4:4 (no subsampling), 4:2:2 or 4:1:1.
4. Partition each plane (Y, Cb and Cr) into 8 × 8 blocks.
5. DCT transform each block.
6. Quantise the DCT coefficients for each block.
and after that:
7. De-quantise the DCT coefficients for each block.
8. Invert the DCT coefficients to go back to the spatial domain.
9. Re-form the complete image from the blocks.
10. Interpolate the chrominance channel if subsampling had been applied.
11. Convert the reconstructed YCbCr image to an RGB image.
This is my code, it is not finished yet, but I think it is not working, I reached step 7 but I think that I have errors in steps 5,6,7:
Thanks a lot
I really appreciate your help.
I am a beginner, I was working on a project in matlab and what I have to do is:
1. Read in BMP image.
2. Convert image from RGB to YCbCr.
3. Subsample image using formats 4:4:4 (no subsampling), 4:2:2 or 4:1:1.
4. Partition each plane (Y, Cb and Cr) into 8 × 8 blocks.
5. DCT transform each block.
6. Quantise the DCT coefficients for each block.
and after that:
7. De-quantise the DCT coefficients for each block.
8. Invert the DCT coefficients to go back to the spatial domain.
9. Re-form the complete image from the blocks.
10. Interpolate the chrominance channel if subsampling had been applied.
11. Convert the reconstructed YCbCr image to an RGB image.
This is my code, it is not finished yet, but I think it is not working, I reached step 7 but I think that I have errors in steps 5,6,7:
Code:
% first step to read an BMP image
A = imread ('sample2.bmp');
%second to Convert image from RGB to YCbCr
U = rgb2ycbcr (A);
% then Subsample image using formats 4:4:4 (no subsampling), 4:2:2 or 4:1:1,
% and actually in this step i will chose format 4:4:4 (no subsampling)
Udown = U(1:1:end,1:1:end,:);
% Partition each plane (Y, Cb and Cr) into 8 × 8 blocks
Y = Udown (:,:,1);
Cb = Udown (:,:,2);
Cr = Udown (:,:,3);
% Performing DCT transform each block
y = dct2(Y);
cb = dct2(Cb);
cr = dct2(Cr);
% Quantise the DCT coefficients for each block.
lumMat = [
16 11 10 16 24 40 51 61;
12 12 14 19 26 58 60 55;
14 13 16 24 40 57 69 56;
14 17 22 29 51 87 80 62;
18 22 37 56 68 109 103 77;
24 35 55 64 81 104 113 92;
49 64 78 87 103 121 120 101;
72 92 95 98 112 100 103 99];
chromMat = [
17 18 24 47 99 99 99 99;
18 21 26 66 99 99 99 99;
24 26 56 99 99 99 99 99;
47 66 99 99 99 99 99 99;
99 99 99 99 99 99 99 99;
99 99 99 99 99 99 99 99;
99 99 99 99 99 99 99 99;
99 99 99 99 99 99 99 99];
Qy = blockproc(y,[8 8],@(block_struct) round(round(block_struct.data)./lumMat));
Qcb = blockproc(cb,[8 8],@(block_struct) round(round(block_struct.data)./chromMat));
Qcr = blockproc(cr,[8 8],@(block_struct) round(round(block_struct.data)./chromMat));
%%
%De-quantise the DCT coefficients for each block.
DQy = idct (Qy);
DQcb = idct (cb);
DQcr = idct (cr);
Thanks a lot
I really appreciate your help.