clear; np = 8; I = double(checkerboard(np)); m = size(I,1); H = fspecial('gaussian',50,2); B = imfilter(I,H,'replicate'); subplot(131);imshow(I,[]); title('Original'); subplot(132);imshow(B,[]); title('Blurred'); tol = 1.e-2; maxit = 1000; u0 = B(:); t = 2.e+3; t0 = cputime; [u,iter,nf] = zGD(@TVL2B,u0,tol,maxit,u0,t,m,H); tcpu = cputime - t0; [f,g] = TVL2B(u,u0,t,m,H); fprintf(' zGD: iter %3i, nf = %4i, tcpu = %6.2e\n',iter,nf,tcpu) fprintf(' zGD: f = %12.6e, norm(g) = %9.3e \n\n',f,norm(g)) if exist('myGD'); t0 = cputime; [u,iter,nf] = myGD(@TVL2B,u0,tol,maxit,u0,t,m,H); tcpu = cputime - t0; [f,g] = TVL2B(u,u0,t,m,H); fprintf('myGD: iter %3i, nf = %4i, tcpu = %6.2e\n',iter,nf,tcpu) fprintf('myGD: f = %12.6e, norm(g) = %9.3e \n\n',f,norm(g)) end U = reshape(u,m,m); subplot(133);imshow(U,[]); title('Restored');