function Iequal = egalisation(I,Nc,N); 
[m,n]  = size(I); L = m*n;   
Iliste = reshape(I,[1,L]);
cases  = [0:N-1]/(N-1); 
[histo,indice] = histc(Iliste,cases); histo=histo/L; 
histo_cum = histo(1); 
for k=2:N
   histo_cum = [histo_cum, histo_cum(k-1)+histo(k)]; 
end
J      = floor((N-1)*I);
Iequal = zeros(m,n);   
for j=1:m 
   for k=1:n    
      Iequal(j,k) = floor((Nc-1)*histo_cum(J(j,k)+1))/(Nc-1);  
   end     
end 
end

