Source Code DCT
Source Code DCT
(8x8) %
51 61
60 55
69 56
80 62
103 77
113 92
120 101
103 99
];
% Chrominance Quantization
Qc_Table = [
17 18 24 47 99
18 21 26 66 99
24 26 56 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
];
Tables (8x8) %
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
By = zeros(8,8,MM*NN);
Bu = By;
Bv = By;
for i=1:MM*NN
By(:,:,i) = round(Gy(:,:,i)./Ql_Table);
Bu(:,:,i) = round(Gu(:,:,i)./Qc_Table);
Bv(:,:,i) = round(Gv(:,:,i)./Qc_Table);
end;
% Proses Decoding %
%6. Dequantization
Dy = zeros(8,8,MM*NN);
Du = Dy;
Dv = Dy;
for i=1:MM*NN
Dy(:,:,i) = round(By(:,:,i).*Ql_Table);
Du(:,:,i) = round(Bu(:,:,i).*Qc_Table);
Dv(:,:,i) = round(Bv(:,:,i).*Qc_Table);
end;
%7. Invers Discrete Cosine Transform (IDCT)
Iy =
Iu =
Iv =
for
zeros(8,8,MM*NN);
Iy;
Iy;
i=1:MM*NN
Iy(:,:,i) = idct2(Dy(:,:,i));
Iu(:,:,i) = idct2(Du(:,:,i));
Iv(:,:,i) = idct2(Dv(:,:,i));
end;
Keterangan :
Hasil DCT & IDCT hanya bisa dilihat dalam bentuk desimal. Belum
mengetahui bagaimana cara menampilkan dalam bentuk image (foto).
Untuk rumus DCT & IDCT mengambil langsung dari fungsi Matlab yaitu dct2
& idct2.