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 = phantom(N);
0021
0022 figure(1); clf;
0023 subplot(141), imagesc(im); axis image; axis off;
0024 colormap gray; title('Original image'); drawnow;
0025
0026
0027
0028 mask = rand(size(im)) < 0.33; ind = find(mask==1);
0029
0030 Ma = sparse(1:numel(ind), ind, ones(numel(ind), 1), numel(ind), numel(im));
0031
0032
0033
0034
0035 A = @(x) Ma*reshape(fft2(x)/sqrt(numel(im)), numel(x), 1);
0036 At = @(x) ifft2(reshape(Ma'*x(:), size(im))*sqrt(numel(im)));
0037
0038
0039 Psit = @(x) x; Psi = Psit;
0040
0041
0042 y = A(im);
0043
0044
0045 sigma_noise = 10^(-input_snr/20)*std(im(:));
0046 y = y + (randn(size(y)) + 1i*randn(size(y)))*sigma_noise/sqrt(2);
0047
0048
0049 figure(1);
0050 subplot(142); imagesc(real(At(y))); axis image; axis off;
0051 colormap gray; title('Measured image'); drawnow;
0052
0053
0054
0055
0056 epsilon = sqrt(chi2inv(0.99, 2*numel(ind))/2)*sigma_noise;
0057
0058
0059 param.verbose = 1;
0060 param.rel_obj = 1e-4;
0061 param.max_iter = 200;
0062 param.gamma = 1e-1;
0063 param.nu_B2 = 1;
0064 param.tol_B2 = 1e-4;
0065 param.tight_B2 = 1;
0066 param.max_iter_TV = 500;
0067 param.zero_weights_flag_TV = 0;
0068 param.identical_weights_flag_TV = 1;
0069
0070
0071 sol_1 = sopt_mltb_solve_TVDNoA(y, epsilon, A, At, Psi, Psit, param);
0072
0073
0074 figure(1);
0075 subplot(143); imagesc(real(sol_1)); axis image; axis off;
0076 colormap gray;
0077 title(['First estimate: ', ...
0078 num2str(sopt_mltb_SNR(im, real(sol_1))), 'dB']);
0079 drawnow;
0080 clc;
0081
0082
0083
0084 [param.weights_dx_TV param.weights_dy_TV] = sopt_mltb_gradient_op(real(sol_1));
0085 param.weights_dx_TV = 1./(abs(param.weights_dx_TV)+1e-3);
0086 param.weights_dy_TV = 1./(abs(param.weights_dy_TV)+1e-3);
0087 param.identical_weights_flag_TV = 0;
0088 param.gamma = 1e-3;
0089
0090
0091 param.zero_weights_flag_TV = 1;
0092 sol_2 = sopt_mltb_solve_TVDNoA(y, epsilon, A, At, Psi, Psit, param);
0093
0094 figure(1);
0095 subplot(144); imagesc(real(sol_2)); axis image; axis off;
0096 colormap gray;
0097 title(['Second estimate: ', ...
0098 num2str(sopt_mltb_SNR(im, real(sol_2))), 'dB']);
0099 drawnow;