You are on page 1of 6

1- Afficher la matrice a :

clear all; close all;


all clc
a= [43 42 41 40 39 38 37 64;
44 21 20 19 18 17 36 63;
45 22 7 6 5 16 35 62;
46 23 8 1 4 15 34 61;
47 24 9 2 3 14 33 60;
48 25 10 11 12 13 32 59;
49 26 27 28 29 30 31 58;
50 51 52 53 54 55 56 57];
figure(1);
imagesc(a);

2- En afficher l’image au niveau de gris (noir et blanc) :


figure(2);
colormap(gray);
imagesc(a);
3- En afficher la matrice « a » , « d » et « d’» dans même fenêtre :
figure(3);
subplot(2,2,1)
imagesc(a)
colormap(gray);

d= d=[(1/sqrt(8)) (1/2)*(cos(pi/16)) (1/2)*(cos(2*pi/16))


(1/2)*(cos(3*pi/16)) (1/2)*(cos(4*pi/16)) (1/2)*(cos(5*pi/16))
(1/2)*(cos(6*pi/16)) (1/2)*(cos(7*pi/16));

(1/sqrt(8)) (1/2)*(cos(3*pi/16))
(1/2)*(cos(3*pi/16) (1/2)*(cos(6*pi/16))
(1/2)*(cos(9*pi/16)) (1/2)*(cos(12*pi/16)) (1/2)*(cos(15*pi/16))
(1/2)*(cos(18*pi/16)) (1/2)*(cos(21*pi/16));

(1/sqrt(8)) (1/2)*(cos(5*pi/16)) (1/2)*(cos(10*pi/16))


(1/2)*(cos(15*pi/16)) (1/2)*(cos(20*pi/16)) (1/2)*(cos(25*pi/16
(1/2)*(cos(25*pi/16))
(1/2)*(cos(30*pi/16)) (1/2)*(cos(35*pi/16));

(1/sqrt(8)) (1/2)*(cos(7*pi/16)) (1/2)*(cos(14*pi/16))


(1/2)*(cos(21*pi/16)) (1/2)*(cos(28*pi/16)) (1/2)*(cos(35*pi/16))
(1/2)*(cos(42*pi/16)) (1/2)*(cos(49*pi/16));

(1/sqrt(8)) (1/2)*(cos(9*pi/16)) (1/2)*(cos(18*pi/16))


(1/2)*(cos(27*pi/16)) (1/2)*(cos(36*pi/16)) (1/2)*(cos(45*pi/16))
(1/2)*(cos(54*pi/16)) (1/2)*(cos(63*pi/16));

(1/sqrt(8)) (1/2)*(cos(11*pi/16)) (1/2)*(cos(22*pi/16))


(1/2)*(cos(33*pi/16)) (1/2)*(cos(44*pi/16)) (1/2)*(cos(55*pi/
(1/2)*(cos(55*pi/16))
(1/2)*(cos(66*pi/16)) (1/2)*(cos(77*pi/16));

(1/sqrt(8)) (1/2)*(cos(13*pi/16)) (1/2)*(cos(26*pi/16))


(1/2)*(cos(39*pi/16)) (1/2)*(cos(52*pi/16)) (1/2)*(cos(65*pi/16))
(1/2)*(cos(78*pi/16)) (1/2)*(cos(92*pi/16));

(1/sqrt(8)) (1/2)*(cos(15*pi/16))
(1/2)*(cos(15*pi/16)) (1/2)*(cos(30*pi/16))
(1/2)*(cos(45*pi/16)) (1/2)*(cos(60*pi/16)) (1/2)*(cos(75*pi/16))
(1/2)*(cos(90*pi/16)) (1/2)*(cos(105*pi/16))];

subplot(2,2,2)
imagesc(d)
colormap(gray);

dt=d'; %dt : si matrice


transposée de d

subplot(2,2,3)
imagesc(dt)
4- En calculer et afficher le DCT :
C= d*a*dt
DCT= round( C );
Les coefficient de « dct » :
dct =

180 -53 134 -43 79 -10


10 53 15
-53 12 -37 4 -20
20 0 -14 -5
108 -34 -3 -10 12 -55 11 3
-35 15 -7 0 0 -22 -3 -1
68 -20 5 -5 -2 -55 3 -1
-8 4 -5 1 2 -55 4 -1
46 -13 8 -3 3 -33 -1 -4
13 -3 2 0 0 -33 4 -3
Affichage de matrice « dct » avec « a » , « d » et « d’» dans même fenêtre :

a
d

D’ DCT
5- Quantification :
a- Représentent la matrice Q de quantification :
Q=[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];
figure(4);
imagesc(Q);

b- Calculer la DCTQ et afficher :


dctq=round(dct./Q)
figure(5);
imagesc(dctq);
Les coefficients de la « dctq » :
dctq =

11 -5 13 -33 3 0 1 0
-4 1 -3 0 -11 0 0 0
8 -33 0 0 0 0 0 0
-33 1 0 0 0 0 0 0
4 -11 0 0 0 0 0 0
0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0

6- Utilisation de la méthode zigzag pour transformer la matrice en vecteur :


Programme qui converti en vecteur avec zigzag :
t=0;

for d=2:64

c=rem(d,2); %checking whether even or odd

for i=1:8

for j=1:8

if((i+j)==d)
t=t+1;
t;
if(c==0)
new(t)=dctq(j,d
new(t)=dctq(j,d-j);
else
new(t)=dctq(d
new(t)=dctq(d-j,j);
end
end
end
end
end
dctq
new
Résultats:
new =
[ 11 -5 -4 8 1 13 -3
- -3 -3 -3 4 1 0 0 3 0 -11 0 0 -1 0
1 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 00]
La valeur du coefficient DC de la DCT si (1er valeur) :
DC= 11
Les suite des coefficients AC de la DCT si (63 derniers valeurs) :
AC = -5 -4 8 1 13 -3 -3 -3 -3 4 1 0 0 3 0 -1 0 0 -1 0
1 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
Codage RLC :
La Suite est [ 11 -5 -4 8 1 13 -3 -3 -3 -3 4 1 0 0 3 0 -1 0
0 -1 0 1 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]
1)
Code RLC =(11,0)(-5,0)(-4,0)(8,0)(1,0)(13,0)(-3,0)(-3,0)(-3,0)(-3,0)(4,0)(1,0)(3,2)(-1,1)
(-1,2)(1,1) (1,5)
Codage Huffman :

You might also like