function M = CREATION_STACK_SINO_COR_DARK_BLANC(rect,gain,theta_max,flag_paganin,binning,offset_angle,tilt_axis)
disp('%%%%%%%%%% CREATION STACK SINOGRAM CORRIGE %%%%%%%%%%');

PARAMETERS_LIST_TOMO;

disp('LECTURE DARK ET BLANC')

filename = filename_objet;
dark = IMAGE_REBINNING(MOYENNE_IMAGES(filename_dark),binning);
blanc = IMAGE_REBINNING(MOYENNE_IMAGES(filename_blanc),binning);

nexus_id=hdf5info(filename);
Group_name = nexus_id.GroupHierarchy.Groups.Groups(3).Name;
taille_matrice = nexus_id.GroupHierarchy.Groups.Groups(3).Datasets(1).Dims;
disp('CREATION MATRICE DE ZEROS')
M = uint16(zeros(round(rect(4)),round(rect(3)),round(taille_matrice(3)*theta_max/360)));
disp('CREATION MATRICE CUBE OBJET')
index= 0;
prog = 0;
fprintf(1,'PROCESSING : %3d%%\n',prog);
index_ct = 0;
nb_images = offset_angle*taille_matrice(3)/360+1:round(taille_matrice(3)*theta_max/360+offset_angle*taille_matrice(3)/360);
for i=(offset_angle*taille_matrice(3)/360+1:round(taille_matrice(3)*theta_max/360+offset_angle*taille_matrice(3)/360));
    index_ct=index_ct+1;
    temp= IMAGE_REBINNING(double(h5read(filename,[Group_name,'/Image_image'],[1 1 i],[taille_matrice(1) taille_matrice(2) 1])),binning);
    I = (temp-dark)./(blanc-dark);
    I = imcrop(I,rect);  %on se restreint a la ROI
    I(I<0) = 0;
    
    if flag_paganin == 1;
        I=PAGANIN_FILTER(I);
%     else
%         I= -log(I);
    end;
    
    index = index+1;
    %%%%%
    I=imrotate(I,-tilt_axis,'bilinear','crop');
    %%%%%
    
    M(:,:,index)=uint16(I*gain);
    prog = 100*index_ct/(numel(nb_images));
    fprintf(1,'\b\b\b\b%3.0f%%',prog);
    
end;
fprintf('\n');
M = permute(M,[1 3 2]);  %on regarde un sinogramme par altitude z

return;