TP-compression-streaming-in.../Exercice_2.m
2023-06-25 16:32:14 +02:00

43 lines
1.4 KiB
Matlab

% TP Codages JPEG et MPEG-2 - 3SN-M - 2022
%--------------------------------------------------------------------------
% Exercie_2 : Test de la DCT 2D par blocs
%--------------------------------------------------------------------------
% Fonction a coder/utiliser : DCT2DParBlocs.m
%--------------------------------------------------------------------------
clear
close all
clc
taille_ecran = get(0,'ScreenSize');
L = taille_ecran(3);
H = taille_ecran(4);
figure('Name','Test de la DCT 2D par blocs',...
'Position',[0.2*L,0.05*H,0.6*L,0.7*H]);
%--------------------------------------------------------------------------
% Chargement de l'image de test
I_for_DCT = load('Donnees_TP_MPEG-2.mat').I_for_DCT;
% Traitement de la DCT 2D par blocs
taille_bloc = 8;
% Calcul de la DCT 2D par blocs
I_DCT = uint8(DCT2DParBlocs('Direct',I_for_DCT,'Rapide',taille_bloc));
% Affichage de l'image avant DCT (DCT inverse effectuee)
subplot 121
imagesc(abs(I_for_DCT))
colormap gray
axis image off
title('Image avant la DCT (DCT inverse effectuee, valeur absolue)')
% Affichage de l'image apres DCT
subplot 122
imagesc(I_DCT)
colormap gray
axis image off
if (round(sum(I_DCT(:))/length(I_DCT(:))) == 178)
title('Image apres la DCT : bonne transformation')
else
title('Image apres la DCT : mauvaise transformation')
end