partie 1 : Compression :

 

Traitement RLE pour un bloc de pixels en RVB

function [codey,codecb,codecr]=traitement_rle(matrice3,qualite)

%Générer le code RLE pour un bloc 8x8 RVB

%Récuper les matrices rouge,vert et blue

R=matrice3(:,:,1);V=matrice3(:,:,2);B=matrice3(:,:,3);

%Transformation des couleurs YCBCR

[Y,CB,CR]=toycbcr (R,V,B);

%DCT

Y=double(Y)-128; CB=double(CB)-128; CR=double(CR)-128;

Ydct=dct2dim (Y);CBdct=dct2dim (CB);CRdct=dct2dim (CR);

%Quantification

Yquantifie=quantification (Ydct,qualite,0);

CBquantifie=quantification (CBdct,qualite,1);

CRquantifie=quantification (CRdct,qualite,1);

%Zigzag

Yzig=zigzag (Yquantifie);

CBzig=zigzag (CBquantifie);

CRzig=zigzag (CRquantifie); 

%Encodage rle

yrle=encodage_rle (Yzig);

CBrle=encodage_rle (CBzig);

CRrle=encodage_rle (CRzig);

%Ajouter le 'e' qui marque la fin du code du bloc

for i=1:length(yrle)

    yyrle{i}= yrle(i);

end

for i=1:length(CBrle)

    CCBrle{i}= CBrle(i);

end 

for i=1:length(CRrle)

    CCRrle{i}= CRrle(i);

end

codey=[yyrle 'e'];codecb=[CCBrle 'e'];codecr=[CCRrle 'e'];