0001
0002
0003
0004
0005
0006
0007 clc;
0008 clear;
0009
0010
0011 addpath misc/
0012 addpath prox_operators/
0013
0014
0015 input_snr = 30;
0016
0017
0018 im = im2double(imread('cameraman.tif'));
0019
0020 figure(1);
0021 imagesc(im); axis image; axis off;
0022 colormap gray; title('Original image'); drawnow;
0023
0024
0025
0026 mask = rand(size(im)) < 0.33; ind = find(mask==1);
0027
0028 Ma = sparse(1:numel(ind), ind, ones(numel(ind), 1), numel(ind), numel(im));
0029
0030 A = @(x) Ma*x(:);
0031 At = @(x) reshape(Ma'*x(:), size(im));
0032
0033
0034
0035 y = A(im);
0036
0037 sigma_noise = 10^(-input_snr/20)*std(im(:));
0038 y = y + randn(size(y))*sigma_noise;
0039
0040 figure(2); clf;
0041 subplot(121); imagesc(At(y)); axis image; axis off;
0042 colormap gray; title('Measured image'); drawnow;
0043
0044 param.verbose = 1;
0045 param.gamma = 1e-1;
0046 param.rel_obj = 1e-4;
0047 param.max_iter = 200;
0048 param_TV.max_iter_TV = 100;
0049 param.nu_B2 = 1;
0050 param.tol_B2 = 1e-4;
0051 param.tight_B2 = 0;
0052 param.max_iter_B2 = 500;
0053
0054 epsilon = sqrt(chi2inv(0.99, numel(ind)))*sigma_noise;
0055
0056 sol = sopt_mltb_solve_TVDN(y, epsilon, A, At, param);
0057
0058 figure(2);
0059 subplot(122); imagesc(sol); axis image; axis off;
0060 colormap gray; title('Reconstructed image'); drawnow;
0061
0062
0063
0064 A = @(x) Ma*reshape(fft2(x)/sqrt(numel(im)), numel(x), 1);
0065 At = @(x) ifft2(reshape(Ma'*x(:), size(im))*sqrt(numel(im)));
0066
0067 y = A(im);
0068
0069 sigma_noise = 10^(-input_snr/20)*std(im(:));
0070 y = y + (randn(size(y)) + 1i*randn(size(y)))*sigma_noise/sqrt(2);
0071
0072 figure(3); clf;
0073 subplot(121); imagesc(real(At(y))); axis image; axis off;
0074 colormap gray; title('Measured image'); drawnow;
0075
0076 epsilon = sqrt(chi2inv(0.99, 2*numel(ind))/2)*sigma_noise;
0077
0078 sol = sopt_mltb_solve_TVDN(y, epsilon, A, At, param);
0079
0080 figure(3);
0081 subplot(122); imagesc(real(sol)); axis image; axis off;
0082 colormap gray; title('Reconstructed image'); drawnow;