partie 1 :Compression :

Découpage en blocs

function decoupage(file)
%Récupérer les matrices R,V et B et compléter les blocs pour avoir la forme
% 8x8

a=imread(file);[n nn zzz]=size(a);
save fichiers_mat/info_image

if zzz~=3
RR=a; RR=comp_block (RR); %gray mode                       cliquez sur la fonction "comp_block()" pour afficher son contenu  
else
RR=a(:,:,1); RR=comp_block (RR); %rvb mode
VV=a(:,:,2); VV=comp_block (VV);
BB=a(:,:,3); BB=comp_block (BB);
end % end if

[lRR,cRR]=size(RR);
no=n;nno=nn;
n=lRR;nn=cRR;
t=n*nn;
save fichiers_mat/dim;
indice=0; % indice=1 si nuance de gris , =0 si RVB

%%%%%MODE NUANCE DE GRIS
if zzz~=3
indice=1; x=1; nl=0;
while nl<n
nc=0;
while nc<nn && x<=t

 for ligne=1:8
         for colonne=1:8
          Z(ligne,colonne)=RR(ligne+nl,colonne+nc);
         end % end for colonne
      end % for ligne

eval(['G',num2str(x),'=Z;'])
x=x+1;nc=nc+8;
end % end while
xx=x-1;nl=nl+8;
end % end while
end
% end if

%%%%%%% MODE RVB
if indice == 0
%Récupérer les matrices du rouge
x=1; nl=0;
while nl<n
nc=0;
while nc<nn && x<=t
 

 for ligne=1:8
         for colonne=1:8
          Z(ligne,colonne)=RR(ligne+nl,colonne+nc);
         end % end for colonne
      end % for ligne

eval(['R',num2str(x),'=Z;'])
x=x+1;nc=nc+8;
end % end while
xx=x-1;
save fichiers_mat/dim;
nl=nl+8;
end % end while

%Récupérer les matrices du rouge vert
x=1; nl=0;
while nl<n
nc=0;
while nc<nn && x<=t
     

 for ligne=1:8
         for colonne=1:8
          Z(ligne,colonne)=VV(ligne+nl,colonne+nc);
         end % end for colonne
      end % for ligne

eval(['V',num2str(x),'=Z;'])
x=x+1;nc=nc+8;
end % end while
nl=nl+8;
end % end while
%Récupérer les matrices du rouge bleu
x=1; nl=0;
while nl<n
nc=0;
while nc<nn && x<=t

 for ligne=1:8
         for colonne=1:8
          Z(ligne,colonne)=BB(ligne+nl,colonne+nc);
         end % end for colonne
      end % for ligne

eval(['B',num2str(x),'=Z;'])
x=x+1; nc=nc+8;
end % end while
nl=nl+8;
end % end while
end % if indice
save fichiers_mat/matrices;