0001
0002
0003
0004
0005
0006
0007
0008
0009 clc
0010 clear;
0011
0012
0013
0014
0015 addpath misc/
0016 addpath prox_operators/
0017
0018
0019
0020
0021
0022 p = [0.50];
0023
0024
0025 input_snr = 30;
0026
0027
0028
0029
0030
0031 im = im2double(imread('cameraman.tif'));
0032
0033
0034 im = im/max(max(im));
0035
0036
0037 im(im<0) = 0;
0038
0039
0040
0041
0042 dwtmode('per');
0043
0044
0045 nlevel = 4;
0046
0047
0048 [C,S] = wavedec2(im,nlevel,'db8');
0049
0050 Psit = @(x) wavedec2(x, nlevel, 'db8');
0051 Psi = @(x) waverec2(x, S, 'db8');
0052
0053
0054
0055
0056
0057
0058
0059 mask = rand(size(im)) < p;
0060 mask(:,1:floor(size(im,2)/2))=0;
0061 mask = ifftshift(mask);
0062 mask(1,1)=0;
0063 mask(floor(size(im,1)/2):end,1)=0;
0064
0065 ind = find(mask==1);
0066 Ma = sparse(1:numel(ind), ind, ...
0067 ones(numel(ind), 1), numel(ind), numel(im));
0068
0069
0070 A = @(x) Ma*reshape(fft2(x)/sqrt(numel(ind)), numel(x), 1);
0071 At = @(x) (ifft2(reshape(Ma'*x(:), size(im))*sqrt(numel(ind))));
0072
0073
0074 y = A(im);
0075
0076
0077 sigma_noise = 10^(-input_snr/20)*std(im(:));
0078 noise = (randn(size(y)) + 1i*randn(size(y)))*sigma_noise/sqrt(2);
0079 y = y + noise;
0080
0081
0082 epsilon = sqrt(numel(y) + 2*sqrt(numel(y)))*sigma_noise;
0083 epsilon_up = sqrt(numel(y) + 2.1*sqrt(numel(y)))*sigma_noise;
0084 tol_B2 = (epsilon_up/epsilon)-1;
0085
0086
0087
0088
0089 param.verbose = 1;
0090 param.gamma = 1e-1;
0091 param.rel_obj = 5e-4;
0092 param.max_iter = 200;
0093 param.nu_B2 = 1;
0094 param.tight_B2 = 0;
0095 param.max_iter_B2 = 200;
0096 param.pos_B2 = 1;
0097 param.tol_B2 = tol_B2;
0098 param.tight_L1 = 1;
0099
0100
0101
0102
0103
0104
0105 sol1 = sopt_mltb_solve_BPDN(y, epsilon, A, At, Psi, Psit, param);
0106
0107
0108 RSNR1 = 20*log10(norm(im,'fro') ...
0109 / norm(im-sol1,'fro'));
0110
0111
0112 param.pos_B2 = 0;
0113 param.real_B2 = 1;
0114
0115
0116 sol2 = sopt_mltb_solve_BPDN(y, epsilon, A, At, Psi, Psit, param);
0117
0118
0119 RSNR2 = 20*log10(norm(im,'fro') ...
0120 / norm(im-sol2,'fro'));
0121
0122
0123
0124
0125 figure
0126 imagesc(sol1), axis off, axis image, colorbar
0127 title(['Rec. with positivity const. SNR=',num2str(RSNR1), 'dB'])
0128 colormap gray
0129
0130 figure
0131 imagesc(sol2), axis off, axis image, colorbar
0132 title(['Rec. with reality const. SNR=',num2str(RSNR2), 'dB'])
0133 colormap gray