function  Image_Denoising(nSig, Out_dir, In_dir)
pre           =   'CSR_de_';
par.nSig      =   nSig;
par.iters     =   1;
par.eps       =   1e-8;

par.c1        =   0.1;  %  You may adjust these parameters for better performance
par.c2        =   0.7;  
par.lamada    =   0.23;

if nSig <= 30
    par.sigma     =   1.7;
    par.win       =   7;
    par.nblk      =   16;        
else
    par.sigma     =   2.4;
    par.win       =   9;
    par.nblk      =   20;
end

fpath         =   fullfile(In_dir, '*.tif');
im_dir        =   dir(fpath);
im_num        =   length(im_dir);
cnt           =   0;
sum_psnr      =   0;
sum_ssim      =   0;
randn('seed', 0);

time0         =   clock;
fn_txt        =   strcat( pre, 'PSNR_SSIM.txt' ); 
fd_txt        =   fopen( fullfile(Out_dir, fn_txt), 'wt');

for i = 1:im_num
    
    par.I        =   double( imread(fullfile(In_dir, im_dir(i).name)) );
    par.nim      =   par.I + nSig*randn(size(par.I));
    
    [im PSNR SSIM]   =   CSR_Denoising( par );      
    sum_psnr   =   sum_psnr + PSNR;
    sum_ssim   =   sum_ssim + SSIM;    
    
    fname            =   strcat(pre, im_dir(i).name);    
    imwrite(im./255, fullfile(Out_dir, fname));
    disp( sprintf('%s: PSNR = %3.2f  SSIM = %f\n', im_dir(i).name, PSNR, SSIM) );
    fprintf(fd_txt, '%s :  PSNR = %2.2f  SSIM = %2.4f\n', im_dir(i).name, PSNR, SSIM);
    cnt   =  cnt + 1;
end
fprintf(fd_txt, '\n\nAverage :  PSNR = %2.2f  SSIM = %2.4f\n', sum_psnr/cnt, sum_ssim/cnt);
fclose(fd_txt);
disp(sprintf('Total elapsed time = %f min\n', (etime(clock,time0)/60) ));

