Description of Experiment3
Description: % Experiement3

Home > matlab > Experiment3.m

# Experiment3

## PURPOSE

% Experiement3

## SYNOPSIS

This is a script file.

## DESCRIPTION

    % Experiement3
     In this experiment we illustrate the application of SARA to Fourier
     imaging. We reconstruct a 224x168 positive brain image from standard
     variable density sampling. Fourier measurements, for an undersampling
     ratio of M = 0.05N and input SNR set to 30 dB.

## 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

This function is called by:

## SOURCE CODE

    0001 %% Experiement3
    0002 % In this experiment we illustrate the application of SARA to Fourier
    0003 % imaging. We reconstruct a 224x168 positive brain image from standard
    0004 % variable density sampling. Fourier measurements, for an undersampling
    0005 % ratio of M = 0.05N and input SNR set to 30 dB.
    0006
    0007
    0008 %% Clear workspace
    0009
    0010 clc
    0011 clear;
    0012
    0013
    0014 %% Define paths
    0015
    0016 addpath misc/
    0017 addpath prox_operators/
    0018 addpath test_images/
    0019
    0020
    0021 %% Read image
    0022
    0023 % Load image
    0024 load Brain_low_res
    0025 im=abs(map_ref);
    0026
    0027 % Normalise
    0028 im = im/max(max(im));
    0029
    0030 % Enforce positivity
    0031 im(im<0) = 0;
    0032
    0033 %% Parameters
    0034
    0035 input_snr = 30; % Noise level (on the measurements)
    0036
    0037 %Undersampling ratio M/N
    0038 %The range of p is 0 < p <= 0.5 since the vdsmask
    0039 %function samples only half plane. Therefore, full
    0040 %sampling is p = 0.5
    0041 p=0.05;
    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 %Sparsity averaging operator
    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
    0086 % Variable density mask
    0087 mask = sopt_mltb_vdsmask(size(im,1),size(im,2),p);
    0088 ind = find(mask==1);
    0089 % Masking matrix (sparse matrix in matlab)
    0090 Ma = sparse(1:numel(ind), ind, ones(numel(ind), 1), numel(ind), numel(im));
    0091
    0092
    0093 % Composition (Masking o Fourier)
    0094
    0095 A = @(x) Ma*reshape(fft2(x)/sqrt(numel(ind)), numel(x), 1);
    0096 At = @(x) (ifft2(reshape(Ma'*x(:), size(im))*sqrt(numel(ind))));
    0097
    0098 % Select p% of Fourier coefficients
    0099 y = A(im);
    0100 % Add Gaussian i.i.d. noise
    0101 sigma_noise = 10^(-input_snr/20)*std(im(:));
    0102 y = y + (randn(size(y)) + 1i*randn(size(y)))*sigma_noise/sqrt(2);
    0103
    0104
    0105 % Tolerance on noise
    0106 epsilon = sqrt(numel(y)+2*sqrt(numel(y)))*sigma_noise;
    0107 epsilon_up = sqrt(numel(y)+2.1*sqrt(numel(y)))*sigma_noise;
    0108
    0109
    0110 %% Parameters for BPDN
    0111 param.verbose = 1; % Print log or not
    0112 param.gamma = 1e-1; % Converge parameter
    0113 param.rel_obj = 4e-4; % Stopping criterion for the L1 problem
    0114 param.max_iter = 200; % Max. number of iterations for the L1 problem
    0115 param.tol_B2 = 1-(epsilon/epsilon_up); % Tolerance for the projection onto the L2-ball
    0116 param.nu_B2 = 1; % Bound on the norm of the operator A
    0117 param.tight_B2 = 0; % Indicate if A is a tight frame (1) or not (0)
    0118 param.pos_B2 = 1;  % Positivity constraint flag. (1) active (0) otherwise
    0119 param.tight_L1 = 1; % Indicate if Psit is a tight frame (1) or not (0)
    0120 param.nu_L1 = 1;
    0121 param.max_iter_L1 = 20;
    0122 param.rel_obj_L1 = 1e-2;
    0123
    0124 % Solve SARA
    0125 maxiter=10;
    0126 sigma=sigma_noise*sqrt(numel(y)/(numel(im)*9));
    0127 tol=1e-3;
    0128 sol1 = sopt_mltb_solve_rwBPDN(y, epsilon, A, At, Psi, Psit, param, sigma, tol, maxiter);
    0129
    0130 RSNR1=20*log10(norm(im,'fro')/norm(im-sol1,'fro'));
    0131
    0132
    0133 %% Parameters for TVDN
    0134 param1.verbose = 1; % Print log or not
    0135 param1.gamma = 3e-1; % Converge parameter
    0136 param1.rel_obj = 5e-4; % Stopping criterion for the TVDN problem
    0137 param1.max_iter = 200; % Max. number of iterations for the TVDN problem
    0138 param1.max_iter_TV = 200; % Max. nb. of iter. for the sub-problem (proximal TV operator)
    0139 param1.nu_B2 = 1; % Bound on the norm of the operator A
    0140 param1.tol_B2 = 1-(epsilon/epsilon_up); % Tolerance for the projection onto the L2-ball
    0141 param1.tight_B2 = 0; % Indicate if A is a tight frame (1) or not (0)
    0142 param1.max_iter_B2 = 200;
    0143 param1.pos_B2 = 1; % Positivity constraint flag. (1) active (0) otherwise
    0144
    0145 % Solve TVDN problem
    0146 sol2 = sopt_mltb_solve_TVDN(y, epsilon, A, At, param1);
    0147
    0148 RSNR2=20*log10(norm(im,'fro')/norm(im-sol2,'fro'));
    0149
    0150
    0151 % Solve BPDN problem
    0152 sol3 = sopt_mltb_solve_BPDN(y, epsilon, A, At, Psi2, Psit2, param);
    0153
    0154
    0155 RSNR3=20*log10(norm(im,'fro')/norm(im-sol3,'fro'));
    0156
    0157 figure, imagesc(sol1,[0 1]);axis image;axis off; colormap gray;
    0158 title(['SARA, SNR=',num2str(RSNR1), 'dB'])
    0159 figure, imagesc(sol2,[0 1]);axis image;axis off; colormap gray;
    0160 title(['TV, SNR=',num2str(RSNR2), 'dB'])
    0161 figure, imagesc(sol3,[0 1]);axis image;axis off; colormap gray;
    0162 title(['BPDb8, SNR=',num2str(RSNR3), 'dB'])
    0163 figure, imagesc(im, [0 1]); axis image; axis off; colormap gray;
    0164 title('Original image')
    0165
    0166
    0167
    0168
    0169
    0170
    0171
    0172
    0173
    0174
    0175
    0176
    0177
    0178
    0179
    0180
    0181
    0182
    0183