partie 2 :DeCompression :
Décodage Huffman2 pour une image en RVB
function Matrice3=decodhuff2_rvb(code_huffman,Y_dico,CB_dico,CR_dico)
%Décodage HUFFMAN2 pour RVB
%Récupérer la qualité
qualite=CR_dico{end}; x=1;
%Récupérer Y, CB et CR
for i=1:length(code_huffman)
if strcmp(code_huffman{i},'y')==1
Y=code_huffman(1:i);
x=1+i;
end % end if
if strcmp(code_huffman{i},'c')==1
CB=code_huffman(x:i);
x=1+i;
end % end if
if strcmp(code_huffman{i},'r')==1
CR=code_huffman(x:i);
end % end if
end % end for
Y=Y(1:end-1);CB=CB(1:end-1);CR=CR(1:end-1);
% Récupérer les codes
x=1;t=1;
for i=1:length(Y)
if strcmp(Y{i},'e')==1
eval([ 'y' num2str(x) '=Y(t:i);']);
t=i+1; x=x+1;
end % end if
end % end for
x=1;t=1;
for i=1:length(CB)
if strcmp(CB{i},'e')==1
eval([ 'cb' num2str(x) '=CB(t:i);']);
t=i+1; x=x+1;
end % end if
end % end for
x=1;t=1;
for i=1:length(CR)
if strcmp(CR{i},'e')==1
eval([ 'cr' num2str(x) '=CR(t:i);']);
t=i+1; x=x+1;
end % end if
end % end for
x=1;t=1;f=1;oo=1;
for i=1:length(Y_dico)
if strcmp(Y_dico{1,i},'#')==1
for f=t:i
variable{1,f}=Y_dico{1,f};
variable{2,f}=Y_dico{2,f};
end % end for
variable=enlever_vide (variable);
eval([ 'w' num2str(x) '=variable;']);
t=i+1; x=x+1; clear variable;
end % end if
end % end for
x=1;t=1;f=1;oo=1;
for i=1:length(CB_dico)
if strcmp(CB_dico{1,i},'#')==1
for f=t:i
variable{1,f}=CB_dico{1,f};
variable{2,f}=CB_dico{2,f};
end % end for
variable=enlever_vide (variable);
eval([ 'q' num2str(x) '=variable;']);
t=i+1; x=x+1; clear variable;
end % end if
end % end for
x=1;t=1;f=1;oo=1;
for i=1:length(CR_dico)
if strcmp(CR_dico{1,i},'#')==1
for f=t:i
variable{1,f}=CR_dico{1,f};
variable{2,f}=CR_dico{2,f};
end % end for
variable=enlever_vide (variable);
eval([ 's' num2str(x) '=variable;']);
t=i+1; x=x+1; clear variable;
end % end if
end % end for
save fichiers_mat/vect;
%Récupérer les blocs
x=x-1; load fichiers_mat/vect; i=1;
while i<x
code_huff_y=eval([ 'y' num2str(i)]); %code Y
code_huff_cb=eval([ 'cb' num2str(i)]); %code CB
code_huff_cr=eval([ 'cr' num2str(i)]); %code CR
dico_y=eval([ 'w' num2str(i)]); %dico Y
dico_cb=eval([ 'q' num2str(i)]); %dico CB
dico_cr=eval([ 's' num2str(i)]); %dico CR
[r,v,b]=traitement_huff2_rvb_inverse(code_huff_y,code_huff_cb,code_huff_cr,dico_y,dico_cb,dico_cr,qualite);
eval([ 'r' num2str(i) '=r;']); %Rouge
eval([ 'v' num2str(i) '=v;']); %Vert
eval([ 'b' num2str(i) '=b;']); %Bleu
i=i+1;
end
%Recoller les blocs
load fichiers_mat/dim;load fichiers_mat/matrices;
G=xx;P=nn/8;
RR=ret_bloc ('r',G,P);
VV=ret_bloc ('v',G,P);
BB=ret_bloc ('b',G,P);
R=eval(['[' RR ']']);
V=eval(['[' VV ']']);
B=eval(['[' BB ']']);
%Redimenssionner l'image
load fichiers_mat/indices;
R=decomp_block (R,indL,indC);
V=decomp_block (V,indL,indC);
B=decomp_block (B,indL,indC);
Matrice3(:,:,1)=R; Matrice3(:,:,2)=V; Matrice3(:,:,3)=B;