0001 
0002 
0003 
0004 
0005 
0006 
0007 clc;
0008 clear;
0009 
0010 
0011 addpath misc/
0012 addpath prox_operators/
0013 
0014 
0015 N = 64;
0016 input_snr = 30; 
0017 randn('seed', 1); rand('seed', 1);
0018 
0019 
0020 im = zeros(N); ind = randperm(N^2); im(ind(1:100)) = 1;
0021 
0022 figure(1);
0023 subplot(221), imagesc(im); axis image; axis off;
0024 colormap gray; title('Original image'); drawnow;
0025 
0026 
0027 
0028 mask = rand(size(im)) < 0.095; ind = find(mask==1);
0029 
0030 Ma = sparse(1:numel(ind), ind, ones(numel(ind), 1), numel(ind), numel(im));
0031 
0032 A = @(x) Ma*x(:);
0033 At = @(x) reshape(Ma'*x(:), size(im));
0034 
0035 
0036 
0037 
0038 A = @(x) Ma*reshape(fft2(x)/sqrt(numel(im)), numel(x), 1);
0039 At = @(x) ifft2(reshape(Ma'*x(:), size(im))*sqrt(numel(im)));
0040 
0041 
0042 Psit = @(x) x; Psi = Psit;
0043 
0044 
0045 y = A(im);
0046 
0047 
0048 sigma_noise = 10^(-input_snr/20)*std(im(:));
0049 y = y + (randn(size(y)) + 1i*randn(size(y)))*sigma_noise/sqrt(2);
0050 
0051 
0052 figure(1);
0053 subplot(222); imagesc(real(At(y))); axis image; axis off;
0054 colormap gray; title('Measured image'); drawnow;
0055 
0056 
0057 epsilon = sqrt(chi2inv(0.99, 2*numel(ind))/2)*sigma_noise;
0058 
0059 
0060 param.verbose = 1; 
0061 param.gamma = 1e-1; 
0062 param.rel_obj = 1e-4; 
0063 param.max_iter = 300; 
0064 param.nu_B2 = 1; 
0065 param.tol_B2 = 1e-4; 
0066 param.tight_B2 = 1; 
0067 param.tight_L1 = 1; 
0068 param.pos_l1 = 1; 
0069 
0070 
0071 sol = sopt_mltb_solve_BPDN(y, epsilon, A, At, Psi, Psit, param);
0072 
0073 
0074 figure(1);
0075 subplot(223); imagesc(real(sol)); axis image; axis off;
0076 colormap gray; title(['First estimate - ', ...
0077     num2str(sopt_mltb_SNR(im, real(sol))), 'dB']); drawnow;
0078 
0079 
0080 param.weights = 1./(abs(sol)+1e-5);
0081 sol = sopt_mltb_solve_BPDN(y, epsilon, A, At, Psi, Psit, param);
0082 
0083 
0084 figure(1);
0085 subplot(224); imagesc(real(sol)); axis image; axis off;
0086 colormap gray; title(['Second estimate - ', ...
0087     num2str(sopt_mltb_SNR(im, real(sol))), 'dB']); drawnow;