0001 
0002 
0003 
0004 
0005 
0006 
0007 
0008 
0009 
0010 
0011 clc
0012 clear;
0013 
0014 
0015 
0016 
0017 addpath misc/
0018 addpath prox_operators/
0019 addpath test_images/
0020 
0021 
0022 
0023 
0024 
0025 imagename = 'lena_256.tiff';
0026 
0027 
0028 im = im2double(imread(imagename));
0029 
0030 
0031 im = im/max(max(im));
0032 
0033 
0034 im(im<0) = 0;
0035 
0036 
0037 
0038 input_snr = 30; 
0039 
0040 
0041 p=0.2;
0042 
0043 
0044 
0045 
0046 
0047 nlevel=4;
0048 
0049 dwtmode('per');
0050 [C,S]=wavedec2(im,nlevel,'db8'); 
0051 ncoef=length(C);
0052 [C1,S1]=wavedec2(im,nlevel,'db1'); 
0053 ncoef1=length(C1);
0054 [C2,S2]=wavedec2(im,nlevel,'db2'); 
0055 ncoef2=length(C2);
0056 [C3,S3]=wavedec2(im,nlevel,'db3'); 
0057 ncoef3=length(C3);
0058 [C4,S4]=wavedec2(im,nlevel,'db4'); 
0059 ncoef4=length(C4);
0060 [C5,S5]=wavedec2(im,nlevel,'db5'); 
0061 ncoef5=length(C5);
0062 [C6,S6]=wavedec2(im,nlevel,'db6'); 
0063 ncoef6=length(C6);
0064 [C7,S7]=wavedec2(im,nlevel,'db7'); 
0065 ncoef7=length(C7);
0066 
0067 
0068 
0069 Psit = @(x) [wavedec2(x,nlevel,'db1')'; wavedec2(x,nlevel,'db2')';wavedec2(x,nlevel,'db3')';...
0070     wavedec2(x,nlevel,'db4')'; wavedec2(x,nlevel,'db5')'; wavedec2(x,nlevel,'db6')';...
0071     wavedec2(x,nlevel,'db7')';wavedec2(x,nlevel,'db8')']/sqrt(8); 
0072 
0073 Psi = @(x) (waverec2(x(1:ncoef1),S1,'db1')+waverec2(x(ncoef1+1:ncoef1+ncoef2),S2,'db2')+...
0074     waverec2(x(ncoef1+ncoef2+1:ncoef1+ncoef2+ncoef3),S3,'db3')+...
0075     waverec2(x(ncoef1+ncoef2+ncoef3+1:ncoef1+ncoef2+ncoef3+ncoef4),S4,'db4')+...
0076     waverec2(x(ncoef1+ncoef2+ncoef3+ncoef4+1:ncoef1+ncoef2+ncoef3+ncoef4+ncoef5),S5,'db5')+...
0077     waverec2(x(ncoef1+ncoef2+ncoef3+ncoef4+ncoef5+1:ncoef1+ncoef2+ncoef3+ncoef4+ncoef5+ncoef6),S6,'db6')+...
0078     waverec2(x(ncoef1+ncoef2+ncoef3+ncoef4+ncoef5+ncoef6+1:ncoef1+ncoef2+ncoef3+ncoef4+ncoef5+ncoef6+ncoef7),S7,'db7')+...
0079     waverec2(x(ncoef1+ncoef2+ncoef3+ncoef4+ncoef5+ncoef6+ncoef7+1:ncoef1+ncoef2+ncoef3+ncoef4+ncoef5+ncoef6+ncoef7+ncoef),S,'db8'))/sqrt(8);
0080 
0081 
0082 Psit2 = @(x) wavedec2(x, nlevel,'db8'); 
0083 Psi2 = @(x) waverec2(x,S,'db8');
0084 
0085 
0086 
0087 realv = 1;
0088 Cv = fdct_usfft(im,realv);
0089 Mod = sopt_mltb_struct2size(Cv);
0090 
0091 Psit3 = @(x) sopt_mltb_fwdcurvelet(x,realv); 
0092 Psi3 = @(x) sopt_mltb_adjcurvelet(x,Mod,realv);
0093 
0094 
0095 
0096 mask = rand(size(im)) < p; 
0097 ind = find(mask==1);
0098 
0099 Ma = sparse(1:numel(ind), ind, ones(numel(ind), 1), numel(ind), numel(im));
0100     
0101 
0102     
0103 ss=rand(size(im));
0104 C=(2*(ss<0.5)-1);
0105 
0106 A = @(x) Ma*reshape(fft2(C.*x)/sqrt(numel(ind)), numel(x), 1);
0107 At = @(x) C.*(ifft2(reshape(Ma'*x(:), size(im))*sqrt(numel(ind))));
0108     
0109 
0110 y = A(im);
0111 
0112 sigma_noise = 10^(-input_snr/20)*std(im(:));
0113 y = y + (randn(size(y)) + 1i*randn(size(y)))*sigma_noise/sqrt(2);
0114     
0115     
0116 
0117 epsilon = sqrt(numel(y)+2*sqrt(numel(y)))*sigma_noise;
0118 epsilon_up = sqrt(numel(y)+2.1*sqrt(numel(y)))*sigma_noise;
0119     
0120     
0121 
0122 param.verbose = 1; 
0123 param.gamma = 1e-1; 
0124 param.rel_obj = 5e-4; 
0125 param.max_iter = 200; 
0126 param.nu_B2 = 1; 
0127 param.tol_B2 = 1-(epsilon/epsilon_up); 
0128 param.tight_B2 = 0; 
0129 param.pos_B2 = 1; 
0130 param.max_iter_B2=300;
0131 param.tight_L1 = 1; 
0132 param.nu_L1 = 1;
0133 param.max_iter_L1 = 20;
0134 param.rel_obj_L1 = 1e-2;
0135     
0136     
0137 
0138     
0139 sol1 = sopt_mltb_solve_BPDN(y, epsilon, A, At, Psi, Psit, param);
0140     
0141 RSNR1=20*log10(norm(im,'fro')/norm(im-sol1,'fro'));
0142     
0143 
0144 
0145 maxiter=10;
0146 sigma=sigma_noise*sqrt(numel(y)/(numel(im)*8));
0147 tol=1e-3;
0148   
0149 sol2 = sopt_mltb_solve_rwBPDN(y, epsilon, A, At, Psi, Psit, param, sigma, tol, maxiter, sol1);
0150 
0151 RSNR2=20*log10(norm(im,'fro')/norm(im-sol2,'fro'));
0152 
0153 
0154     
0155 sol3 = sopt_mltb_solve_BPDN(y, epsilon, A, At, Psi2, Psit2, param);
0156     
0157 RSNR3=20*log10(norm(im,'fro')/norm(im-sol3,'fro'));
0158     
0159 
0160 
0161 maxiter=10;
0162 sigma=sigma_noise*sqrt(numel(y)/(numel(im)));
0163 tol=1e-3;
0164   
0165 sol4 = sopt_mltb_solve_rwBPDN(y, epsilon, A, At, Psi2, Psit2, param, sigma, tol, maxiter, sol3);
0166       
0167 RSNR4=20*log10(norm(im,'fro')/norm(im-sol4,'fro'));
0168 
0169 
0170 
0171 
0172 param3.verbose = 1; 
0173 param3.gamma = 1e-1; 
0174 param3.rel_obj = 5e-4; 
0175 param3.max_iter = 200; 
0176 param3.nu_B2 = 1; 
0177 param3.tol_B2 = 1-(epsilon/epsilon_up); 
0178 param3.tight_B2 = 1; 
0179 param3.pos_B2 = 1; 
0180 param3.tight_L1 = 1; 
0181 
0182     
0183 
0184 
0185 
0186     
0187 sol5 = sopt_mltb_solve_BPDN(y, epsilon, A, At, Psi3, Psit3, param3);
0188     
0189 RSNR5=20*log10(norm(im,'fro')/norm(im-sol5,'fro'));
0190     
0191 
0192 
0193 maxiter=10;
0194 sigma=sigma_noise*sqrt(numel(y)/(numel(im)));
0195 tol=1e-3;
0196   
0197 sol6 = sopt_mltb_solve_rwBPDN(y, epsilon, A, At, Psi3, Psit3, param3, sigma, tol, maxiter, sol5);
0198      
0199 RSNR6=20*log10(norm(im,'fro')/norm(im-sol6,'fro'));
0200 
0201     
0202 
0203 param1.verbose = 1; 
0204 param1.gamma = 1e-1; 
0205 param1.rel_obj = 5e-4; 
0206 param1.max_iter = 200; 
0207 param1.max_iter_TV = 200; 
0208 param1.nu_B2 = 1; 
0209 param1.tol_B2 = 1-(epsilon/epsilon_up); 
0210 param1.tight_B2 = 0; 
0211 param1.max_iter_B2 = 300;
0212 param1.pos_B2 = 1; 
0213     
0214 
0215     
0216 sol7 = sopt_mltb_solve_TVDN(y, epsilon, A, At, param1);
0217     
0218 RSNR7=20*log10(norm(im,'fro')/norm(im-sol7,'fro'));
0219     
0220 
0221 
0222 maxiter=10;
0223 sigma=sigma_noise*sqrt(numel(y)/(numel(im)));
0224 tol=1e-3;
0225   
0226 sol8 = sopt_mltb_solve_rwTVDN(y, epsilon, A, At, param1,sigma, tol, maxiter, sol7);
0227     
0228 RSNR8=20*log10(norm(im,'fro')/norm(im-sol8,'fro'));
0229 
0230 
0231 
0232 
0233 figure, imagesc(sol1,[0 1]); axis image; axis off; colormap gray;
0234 title(['BPSA, SNR=',num2str(RSNR1), 'dB'])
0235 figure, imagesc(sol2,[0 1]); axis image; axis off; colormap gray;
0236 title(['SARA, SNR=',num2str(RSNR2), 'dB'])
0237 
0238 figure, imagesc(sol3,[0 1]); axis image; axis off; colormap gray;
0239 title(['BPDb8, SNR=',num2str(RSNR3), 'dB'])
0240 figure, imagesc(sol4,[0 1]); axis image; axis off; colormap gray;
0241 title(['RW- BPDb8, SNR=',num2str(RSNR4), 'dB'])
0242 
0243 figure, imagesc(sol5,[0 1]); axis image; axis off; colormap gray;
0244 title(['Curvelet, SNR=',num2str(RSNR5), 'dB'])
0245 figure, imagesc(sol6,[0 1]); axis image; axis off; colormap gray;
0246 title(['RW-Curvelet, SNR=',num2str(RSNR6), 'dB'])
0247 
0248 figure, imagesc(sol7,[0 1]); axis image; axis off; colormap gray;
0249 title(['TV, SNR=',num2str(RSNR7), 'dB'])
0250 figure, imagesc(sol8,[0 1]); axis image; axis off; colormap gray;
0251 title(['RW-TV, SNR=',num2str(RSNR8), 'dB'])
0252 
0253 
0254 
0255 
0256 
0257 
0258 
0259 
0260 
0261 
0262