Home > matlab > Experiment2.m

Experiment2

PURPOSE ^

% Experiment2

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

% Experiment2
 In this experiment we study the performance of SARA with Gaussian random 
 matrices as measurements operators. Due to computational limitations for 
 the use of a dense sensing matrix, for this experiment we use a cropped 
 version of Lena, around the head, of dimension 128x128 as a test image. 
 Number of measurements is M = 0.3N and input SNR is set to 30 dB. These
 parameters can be changed by modifying the variables p (for the
 undersampling ratio) and input_snr (for the input SNR).

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% Experiment2
0002 % In this experiment we study the performance of SARA with Gaussian random
0003 % matrices as measurements operators. Due to computational limitations for
0004 % the use of a dense sensing matrix, for this experiment we use a cropped
0005 % version of Lena, around the head, of dimension 128x128 as a test image.
0006 % Number of measurements is M = 0.3N and input SNR is set to 30 dB. These
0007 % parameters can be changed by modifying the variables p (for the
0008 % undersampling ratio) and input_snr (for the input SNR).
0009 
0010 
0011 %% Clear workspace
0012 
0013 clc
0014 clear;
0015 
0016 
0017 %% Define paths
0018 
0019 addpath misc/
0020 addpath prox_operators/
0021 addpath test_images/
0022 
0023 
0024 %% Read image
0025 
0026 imagename = 'lena_256.tiff';
0027 
0028 % Load image
0029 im1 = im2double(imread(imagename));
0030 
0031 %Crope image
0032 a=70;
0033 b=96;
0034 im=im1(a+1:a+128,b+1:b+128);
0035 
0036 % Enforce positivity
0037 im(im<0) = 0;
0038 
0039 %% Parameters
0040 
0041 input_snr = 30; % Noise level (on the measurements)
0042 
0043 %Undersampling ratio M/N
0044 p=0.3;
0045 
0046 %% Sparsity operators
0047 
0048 %Wavelet decomposition depth
0049 nlevel=4;
0050 
0051 dwtmode('per');
0052 [C,S]=wavedec2(im,nlevel,'db8'); 
0053 ncoef=length(C);
0054 [C1,S1]=wavedec2(im,nlevel,'db1'); 
0055 ncoef1=length(C1);
0056 [C2,S2]=wavedec2(im,nlevel,'db2'); 
0057 ncoef2=length(C2);
0058 [C3,S3]=wavedec2(im,nlevel,'db3'); 
0059 ncoef3=length(C3);
0060 [C4,S4]=wavedec2(im,nlevel,'db4'); 
0061 ncoef4=length(C4);
0062 [C5,S5]=wavedec2(im,nlevel,'db5'); 
0063 ncoef5=length(C5);
0064 [C6,S6]=wavedec2(im,nlevel,'db6'); 
0065 ncoef6=length(C6);
0066 [C7,S7]=wavedec2(im,nlevel,'db7'); 
0067 ncoef7=length(C7);
0068 
0069 %Sparsity averaging operator
0070 
0071 Psit = @(x) [wavedec2(x,nlevel,'db1')'; wavedec2(x,nlevel,'db2')';wavedec2(x,nlevel,'db3')';...
0072     wavedec2(x,nlevel,'db4')'; wavedec2(x,nlevel,'db5')'; wavedec2(x,nlevel,'db6')';...
0073     wavedec2(x,nlevel,'db7')';wavedec2(x,nlevel,'db8')']/sqrt(8); 
0074 
0075 Psi = @(x) (waverec2(x(1:ncoef1),S1,'db1')+waverec2(x(ncoef1+1:ncoef1+ncoef2),S2,'db2')+...
0076     waverec2(x(ncoef1+ncoef2+1:ncoef1+ncoef2+ncoef3),S3,'db3')+...
0077     waverec2(x(ncoef1+ncoef2+ncoef3+1:ncoef1+ncoef2+ncoef3+ncoef4),S4,'db4')+...
0078     waverec2(x(ncoef1+ncoef2+ncoef3+ncoef4+1:ncoef1+ncoef2+ncoef3+ncoef4+ncoef5),S5,'db5')+...
0079     waverec2(x(ncoef1+ncoef2+ncoef3+ncoef4+ncoef5+1:ncoef1+ncoef2+ncoef3+ncoef4+ncoef5+ncoef6),S6,'db6')+...
0080     waverec2(x(ncoef1+ncoef2+ncoef3+ncoef4+ncoef5+ncoef6+1:ncoef1+ncoef2+ncoef3+ncoef4+ncoef5+ncoef6+ncoef7),S7,'db7')+...
0081     waverec2(x(ncoef1+ncoef2+ncoef3+ncoef4+ncoef5+ncoef6+ncoef7+1:ncoef1+ncoef2+ncoef3+ncoef4+ncoef5+ncoef6+ncoef7+ncoef),S,'db8'))/sqrt(8);
0082 
0083 %Db8 wavelet basis
0084 Psit2 = @(x) wavedec2(x, nlevel,'db8'); 
0085 Psi2 = @(x) waverec2(x,S,'db8');
0086 
0087 %Curvelet
0088 %CurveLab needs to be installed to run Curvelet simulations
0089 realv = 1;
0090 Cv = fdct_usfft(im,realv);
0091 Mod = sopt_mltb_struct2size(Cv);
0092 
0093 Psit3 = @(x) sopt_mltb_fwdcurvelet(x,realv); 
0094 Psi3 = @(x) sopt_mltb_adjcurvelet(x,Mod,realv);
0095 
0096 %% Gaussian matrix operator
0097 
0098 num_meas=floor(p*numel(im));
0099 
0100 Phi = randn(num_meas,numel(im))/sqrt(num_meas);
0101         
0102 bound=svds(Phi,1)^2;
0103      
0104 A = @(x) Phi*x(:);
0105     
0106 At = @(x) reshape(Phi'*x(:),size(im));
0107     
0108    
0109 % Sampling
0110 y = A(im);
0111 % Add Gaussian i.i.d. noise
0112 sigma_noise = 10^(-input_snr/20)*std(im(:));
0113 y = y + (randn(size(y)))*sigma_noise;
0114     
0115     
0116 % Tolerance on noise
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 % Parameters for BPDN
0122 param.verbose = 1; % Print log or not
0123 param.gamma = 1e-1; % Converge parameter
0124 param.rel_obj = 5e-4; % Stopping criterion for the L1 problem
0125 param.max_iter = 200; % Max. number of iterations for the L1 problem
0126 param.nu_B2 = bound; % Bound on the norm of the operator A
0127 param.tol_B2 = 1-(epsilon/epsilon_up); % Tolerance for the projection onto the L2-ball
0128 param.tight_B2 = 0; % Indicate if A is a tight frame (1) or not (0)
0129 param.pos_B2 = 1; %Positivity constraint: (1) active, (0) not active
0130 param.max_iter_B2=300;
0131 param.tight_L1 = 1; % Indicate if Psit is a tight frame (1) or not (0)
0132 param.nu_L1 = 1;
0133 param.max_iter_L1 = 20;
0134 param.rel_obj_L1 = 1e-2;
0135     
0136     
0137 % Solve BPSA problem
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 % SARA
0144 % It uses the solution to BPSA as a warm start
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 % Solve BPBb8 problem
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 % RWBPDb8
0160 % It uses the solution to BPDBb8 as a warm start
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 % Parameters for Curvelet
0170 
0171 % Parameters for BPDN
0172 param3.verbose = 1; % Print log or not
0173 param3.gamma = 1e-1; % Converge parameter
0174 param3.rel_obj = 5e-4; % Stopping criterion for the L1 problem
0175 param3.max_iter = 200; % Max. number of iterations for the L1 problem
0176 param3.nu_B2 = bound; % Bound on the norm of the operator A
0177 param3.tol_B2 = 1-(epsilon/epsilon_up); % Tolerance for the projection onto the L2-ball
0178 param3.tight_B2 = 1; % Indicate if A is a tight frame (1) or not (0)
0179 param3.pos_B2 = 1; % Positivity constraint flag. (1) active (0) otherwise
0180 param3.tight_L1 = 1; % Indicate if Psit is a tight frame (1) or not (0)
0181 
0182     
0183 
0184 
0185 % Solve BP Curvelet problem
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 % RW-Curvelet
0192 % It uses the solution to BPDBb8 as a warm start
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 % Parameters for TVDN
0203 param1.verbose = 1; % Print log or not
0204 param1.gamma = 1e-1; % Converge parameter
0205 param1.rel_obj = 5e-4; % Stopping criterion for the TVDN problem
0206 param1.max_iter = 200; % Max. number of iterations for the TVDN problem
0207 param1.max_iter_TV = 200; % Max. nb. of iter. for the sub-problem (proximal TV operator)
0208 param1.nu_B2 = bound; % Bound on the norm of the operator A
0209 param1.tol_B2 = 1-(epsilon/epsilon_up); % Tolerance for the projection onto the L2-ball
0210 param1.tight_B2 = 0; % Indicate if A is a tight frame (1) or not (0)
0211 param1.max_iter_B2 = 300;
0212 param1.pos_B2 = 1;
0213     
0214 % Solve TV problem
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 % RWTV
0221 % It uses the solution to TV as a warm start
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 %Show reconstructed images
0231 
0232 figure, imagesc(sol1,[0 1]); axis image; axis off; colormap gray;
0233 title(['BPSA, SNR=',num2str(RSNR1), 'dB'])
0234 figure, imagesc(sol2,[0 1]); axis image; axis off; colormap gray;
0235 title(['SARA, SNR=',num2str(RSNR2), 'dB'])
0236 
0237 figure, imagesc(sol3,[0 1]); axis image; axis off; colormap gray;
0238 title(['BPDb8, SNR=',num2str(RSNR3), 'dB'])
0239 figure, imagesc(sol4,[0 1]); axis image; axis off; colormap gray;
0240 title(['RW- BPDb8, SNR=',num2str(RSNR4), 'dB'])
0241 
0242 figure, imagesc(sol5,[0 1]); axis image; axis off; colormap gray;
0243 title(['Curvelet, SNR=',num2str(RSNR5), 'dB'])
0244 figure, imagesc(sol6,[0 1]); axis image; axis off; colormap gray;
0245 title(['RW-Curvelet, SNR=',num2str(RSNR6), 'dB'])
0246 
0247 figure, imagesc(sol7,[0 1]); axis image; axis off; colormap gray;
0248 title(['TV, SNR=',num2str(RSNR7), 'dB'])
0249 figure, imagesc(sol8,[0 1]); axis image; axis off; colormap gray;
0250 title(['RW-TV, SNR=',num2str(RSNR8), 'dB'])
0251 
0252 
0253 
0254 
0255 
0256 
0257 
0258 
0259 
0260 
0261

Generated on Fri 22-Feb-2013 15:54:47 by m2html © 2005