Description of Experiment1
Description: % Experiment1

Home > matlab > Experiment1.m

# Experiment1

## PURPOSE

% Experiment1

## SYNOPSIS

This is a script file.

## DESCRIPTION

    % Experiment1
     In this experiment we evaluate the performance of SARA for spread
     spectrum acquisition. We use a 256x256 version of Lena as a test image.
     Number of measurements is M = 0.2N 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:

- sopt_mltb_solve_BPDN sopt_mltb_solve_BPDN - Solve BPDN problem
- sopt_mltb_solve_TVDN sopt_mltb_solve_TVDN - Solve TVDN problem
- sopt_mltb_solve_rwBPDN sopt_mltb_solve_rwBPDN - Solve reweighted BPDN problem
- sopt_mltb_solve_rwTVDN sopt_mltb_solve_rwTVDN - Solve reweighted TVDN problem

This function is called by:

## SOURCE CODE

    0001 %% Experiment1
    0002 % In this experiment we evaluate the performance of SARA for spread
    0003 % spectrum acquisition. We use a 256x256 version of Lena as a test image.
    0004 % Number of measurements is M = 0.2N and input SNR is set to 30 dB. These
    0005 % parameters can be changed by modifying the variables p (for the
    0006 % undersampling ratio) and input_snr (for the input SNR).
    0007
    0008
    0009 %% Clear workspace
    0010
    0011 clc
    0012 clear;
    0013
    0014
    0015 %% Define paths
    0016
    0017 addpath misc/
    0018 addpath prox_operators/
    0019 addpath test_images/
    0020
    0021
    0022
    0023 %% Read image
    0024
    0025 imagename = 'lena_256.tiff';
    0026
    0027 % Load image
    0028 im = im2double(imread(imagename));
    0029
    0030 % Normalise
    0031 im = im/max(max(im));
    0032
    0033 % Enforce positivity
    0034 im(im<0) = 0;
    0035
    0036 %% Parameters
    0037
    0038 input_snr = 30; % Noise level (on the measurements)
    0039
    0040 %Undersampling ratio M/N
    0041 p=0.2;
    0042
    0043
    0044 %% Sparsity operators
    0045
    0046 %Wavelet decomposition depth
    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 %SARA
    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 %Db8 wavelet basis
    0082 Psit2 = @(x) wavedec2(x, nlevel,'db8');
    0083 Psi2 = @(x) waverec2(x,S,'db8');
    0084
    0085 %Curvelet
    0086 %CurveLab needs to be installed to run Curvelet simulations
    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 %% Spread spectrum operator
    0095 % Mask
    0096 mask = rand(size(im)) < p;
    0097 ind = find(mask==1);
    0098 % Masking matrix (sparse matrix in matlab)
    0099 Ma = sparse(1:numel(ind), ind, ones(numel(ind), 1), numel(ind), numel(im));
    0100
    0101 %Spread spectrum sequence
    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 % 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)) + 1i*randn(size(y)))*sigma_noise/sqrt(2);
    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 = 1; % 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 = 1; % 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 = 1; % 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; % Positivity constraint flag. (1) active (0) otherwise
    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
    0231 %Show reconstructed images
    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