%%-------------------- parameters 
band= 13;
sigma=0.75;
N=20;
%% blurring matrix.. 
%% from regul. tools [P.C. Hansen]  

colormap('gray') 
[A,b,mire]=blur(N,band,sigma);
size(A)

%%-------------------- initial image 
figure (1); 
colormap('gray') 
imagesc(reshape(mire,N,N));

title('  -- original  image   -- ','FontSize',16) 
pause; 

%%-------------------- add noise to blurred image 

noiselev = 0.001*max(abs(b));  
c = b + noiselev*abs(randn(size(b))) ; 

figure (2) ; 
colormap('gray') 
imagesc(reshape(c,N,N));
title('- blurred with noise - ','FontSize',16) 
pause;
%%-------------------- direct image recovery
d = A \ c; 

figure (3) ; 
colormap('gray') 
imagesc(reshape(d,N,N));

title('- Direct recovery -','FontSize',16)  
pause;

%%-------------------- TSVD solution 
disp('.computing the T-SVD solution --- wait....');
%% xk = pinv(full(A),noiselev)*c; 
 xk = pinv(full(A),0.005)*c; 
disp(' done. ');
%%  xk = X * c;
 figure (4) ; 
 %% showimg (xk) ;
colormap('gray') 
imagesc(reshape(xk,N,N));
title('- TSVD  recovery - ','FontSize',16)  

