diff options
author | Tomas Kulhanek <tomas.kulhanek@stfc.ac.uk> | 2019-02-21 02:10:14 -0500 |
---|---|---|
committer | Tomas Kulhanek <tomas.kulhanek@stfc.ac.uk> | 2019-02-21 02:10:14 -0500 |
commit | 3caa686662f7d937cf7eb852dde437cd66e79a6e (patch) | |
tree | 76088f5924ff9278e0a37140fce888cd89b84a7e /Wrappers/Matlab/demos | |
parent | 8f2e86726669b9dadb3c788e0ea681d397a2eeb7 (diff) | |
download | regularization-3caa686662f7d937cf7eb852dde437cd66e79a6e.tar.gz regularization-3caa686662f7d937cf7eb852dde437cd66e79a6e.tar.bz2 regularization-3caa686662f7d937cf7eb852dde437cd66e79a6e.tar.xz regularization-3caa686662f7d937cf7eb852dde437cd66e79a6e.zip |
restructured sources
Diffstat (limited to 'Wrappers/Matlab/demos')
-rw-r--r-- | Wrappers/Matlab/demos/demoMatlab_3Ddenoise.m | 178 | ||||
-rw-r--r-- | Wrappers/Matlab/demos/demoMatlab_denoise.m | 189 | ||||
-rw-r--r-- | Wrappers/Matlab/demos/demoMatlab_inpaint.m | 35 |
3 files changed, 0 insertions, 402 deletions
diff --git a/Wrappers/Matlab/demos/demoMatlab_3Ddenoise.m b/Wrappers/Matlab/demos/demoMatlab_3Ddenoise.m deleted file mode 100644 index 0c331a4..0000000 --- a/Wrappers/Matlab/demos/demoMatlab_3Ddenoise.m +++ /dev/null @@ -1,178 +0,0 @@ -% Volume (3D) denoising demo using CCPi-RGL -clear; close all -Path1 = sprintf(['..' filesep 'mex_compile' filesep 'installed'], 1i); -Path2 = sprintf(['..' filesep '..' filesep '..' filesep 'data' filesep], 1i); -Path3 = sprintf(['..' filesep 'supp'], 1i); -addpath(Path1); -addpath(Path2); -addpath(Path3); - -N = 512; -slices = 7; -vol3D = zeros(N,N,slices, 'single'); -Ideal3D = zeros(N,N,slices, 'single'); -Im = double(imread('lena_gray_512.tif'))/255; % loading image -for i = 1:slices -vol3D(:,:,i) = Im + .05*randn(size(Im)); -Ideal3D(:,:,i) = Im; -end -vol3D(vol3D < 0) = 0; -figure; imshow(vol3D(:,:,15), [0 1]); title('Noisy image'); - - -lambda_reg = 0.03; % regularsation parameter for all methods -%% -fprintf('Denoise a volume using the ROF-TV model (CPU) \n'); -tau_rof = 0.0025; % time-marching constant -iter_rof = 300; % number of ROF iterations -tic; u_rof = ROF_TV(single(vol3D), lambda_reg, iter_rof, tau_rof); toc; -energyfunc_val_rof = TV_energy(single(u_rof),single(vol3D),lambda_reg, 1); % get energy function value -rmse_rof = (RMSE(Ideal3D(:),u_rof(:))); -fprintf('%s %f \n', 'RMSE error for ROF is:', rmse_rof); -figure; imshow(u_rof(:,:,7), [0 1]); title('ROF-TV denoised volume (CPU)'); -%% -% fprintf('Denoise a volume using the ROF-TV model (GPU) \n'); -% tau_rof = 0.0025; % time-marching constant -% iter_rof = 300; % number of ROF iterations -% tic; u_rofG = ROF_TV_GPU(single(vol3D), lambda_reg, iter_rof, tau_rof); toc; -% rmse_rofG = (RMSE(Ideal3D(:),u_rofG(:))); -% fprintf('%s %f \n', 'RMSE error for ROF is:', rmse_rofG); -% figure; imshow(u_rofG(:,:,7), [0 1]); title('ROF-TV denoised volume (GPU)'); -%% -fprintf('Denoise a volume using the FGP-TV model (CPU) \n'); -iter_fgp = 300; % number of FGP iterations -epsil_tol = 1.0e-05; % tolerance -tic; u_fgp = FGP_TV(single(vol3D), lambda_reg, iter_fgp, epsil_tol); toc; -energyfunc_val_fgp = TV_energy(single(u_fgp),single(vol3D),lambda_reg, 1); % get energy function value -rmse_fgp = (RMSE(Ideal3D(:),u_fgp(:))); -fprintf('%s %f \n', 'RMSE error for FGP-TV is:', rmse_fgp); -figure; imshow(u_fgp(:,:,7), [0 1]); title('FGP-TV denoised volume (CPU)'); -%% -% fprintf('Denoise a volume using the FGP-TV model (GPU) \n'); -% iter_fgp = 300; % number of FGP iterations -% epsil_tol = 1.0e-05; % tolerance -% tic; u_fgpG = FGP_TV_GPU(single(vol3D), lambda_reg, iter_fgp, epsil_tol); toc; -% rmse_fgpG = (RMSE(Ideal3D(:),u_fgpG(:))); -% fprintf('%s %f \n', 'RMSE error for FGP-TV is:', rmse_fgpG); -% figure; imshow(u_fgpG(:,:,7), [0 1]); title('FGP-TV denoised volume (GPU)'); -%% -fprintf('Denoise a volume using the SB-TV model (CPU) \n'); -iter_sb = 150; % number of SB iterations -epsil_tol = 1.0e-05; % tolerance -tic; u_sb = SB_TV(single(vol3D), lambda_reg, iter_sb, epsil_tol); toc; -energyfunc_val_sb = TV_energy(single(u_sb),single(vol3D),lambda_reg, 1); % get energy function value -rmse_sb = (RMSE(Ideal3D(:),u_sb(:))); -fprintf('%s %f \n', 'RMSE error for SB-TV is:', rmse_sb); -figure; imshow(u_sb(:,:,7), [0 1]); title('SB-TV denoised volume (CPU)'); -%% -% fprintf('Denoise a volume using the SB-TV model (GPU) \n'); -% iter_sb = 150; % number of SB iterations -% epsil_tol = 1.0e-05; % tolerance -% tic; u_sbG = SB_TV_GPU(single(vol3D), lambda_reg, iter_sb, epsil_tol); toc; -% rmse_sbG = (RMSE(Ideal3D(:),u_sbG(:))); -% fprintf('%s %f \n', 'RMSE error for SB-TV is:', rmse_sbG); -% figure; imshow(u_sbG(:,:,7), [0 1]); title('SB-TV denoised volume (GPU)'); -%% -fprintf('Denoise a volume using the ROF-LLT model (CPU) \n'); -lambda_ROF = lambda_reg; % ROF regularisation parameter -lambda_LLT = lambda_reg*0.35; % LLT regularisation parameter -iter_LLT = 300; % iterations -tau_rof_llt = 0.0025; % time-marching constant -tic; u_rof_llt = LLT_ROF(single(vol3D), lambda_ROF, lambda_LLT, iter_LLT, tau_rof_llt); toc; -rmse_rof_llt = (RMSE(Ideal3D(:),u_rof_llt(:))); -fprintf('%s %f \n', 'RMSE error for ROF-LLT is:', rmse_rof_llt); -figure; imshow(u_rof_llt(:,:,7), [0 1]); title('ROF-LLT denoised volume (CPU)'); -%% -% fprintf('Denoise a volume using the ROF-LLT model (GPU) \n'); -% lambda_ROF = lambda_reg; % ROF regularisation parameter -% lambda_LLT = lambda_reg*0.35; % LLT regularisation parameter -% iter_LLT = 300; % iterations -% tau_rof_llt = 0.0025; % time-marching constant -% tic; u_rof_llt_g = LLT_ROF_GPU(single(vol3D), lambda_ROF, lambda_LLT, iter_LLT, tau_rof_llt); toc; -% rmse_rof_llt = (RMSE(Ideal3D(:),u_rof_llt_g(:))); -% fprintf('%s %f \n', 'RMSE error for ROF-LLT is:', rmse_rof_llt); -% figure; imshow(u_rof_llt_g(:,:,7), [0 1]); title('ROF-LLT denoised volume (GPU)'); -%% -fprintf('Denoise a volume using Nonlinear-Diffusion model (CPU) \n'); -iter_diff = 300; % number of diffusion iterations -lambda_regDiff = 0.025; % regularisation for the diffusivity -sigmaPar = 0.015; % edge-preserving parameter -tau_param = 0.025; % time-marching constant -tic; u_diff = NonlDiff(single(vol3D), lambda_regDiff, sigmaPar, iter_diff, tau_param, 'Huber'); toc; -rmse_diff = (RMSE(Ideal3D(:),u_diff(:))); -fprintf('%s %f \n', 'RMSE error for Diffusion is:', rmse_diff); -figure; imshow(u_diff(:,:,7), [0 1]); title('Diffusion denoised volume (CPU)'); -%% -% fprintf('Denoise a volume using Nonlinear-Diffusion model (GPU) \n'); -% iter_diff = 300; % number of diffusion iterations -% lambda_regDiff = 0.025; % regularisation for the diffusivity -% sigmaPar = 0.015; % edge-preserving parameter -% tau_param = 0.025; % time-marching constant -% tic; u_diff_g = NonlDiff_GPU(single(vol3D), lambda_regDiff, sigmaPar, iter_diff, tau_param, 'Huber'); toc; -% rmse_diff = (RMSE(Ideal3D(:),u_diff_g(:))); -% fprintf('%s %f \n', 'RMSE error for Diffusion is:', rmse_diff); -% figure; imshow(u_diff_g(:,:,7), [0 1]); title('Diffusion denoised volume (GPU)'); -%% -fprintf('Denoise using Fourth-order anisotropic diffusion model (CPU) \n'); -iter_diff = 300; % number of diffusion iterations -lambda_regDiff = 3.5; % regularisation for the diffusivity -sigmaPar = 0.02; % edge-preserving parameter -tau_param = 0.0015; % time-marching constant -tic; u_diff4 = Diffusion_4thO(single(vol3D), lambda_regDiff, sigmaPar, iter_diff, tau_param); toc; -rmse_diff4 = (RMSE(Ideal3D(:),u_diff4(:))); -fprintf('%s %f \n', 'RMSE error for Anis.Diff of 4th order is:', rmse_diff4); -figure; imshow(u_diff4(:,:,7), [0 1]); title('Diffusion 4thO denoised volume (CPU)'); -%% -% fprintf('Denoise using Fourth-order anisotropic diffusion model (GPU) \n'); -% iter_diff = 300; % number of diffusion iterations -% lambda_regDiff = 3.5; % regularisation for the diffusivity -% sigmaPar = 0.02; % edge-preserving parameter -% tau_param = 0.0015; % time-marching constant -% tic; u_diff4_g = Diffusion_4thO_GPU(single(vol3D), lambda_regDiff, sigmaPar, iter_diff, tau_param); toc; -% rmse_diff4 = (RMSE(Ideal3D(:),u_diff4_g(:))); -% fprintf('%s %f \n', 'RMSE error for Anis.Diff of 4th order is:', rmse_diff4); -% figure; imshow(u_diff4_g(:,:,7), [0 1]); title('Diffusion 4thO denoised volume (GPU)'); -%% -fprintf('Denoise using the TGV model (CPU) \n'); -lambda_TGV = 0.03; % regularisation parameter -alpha1 = 1.0; % parameter to control the first-order term -alpha0 = 2.0; % parameter to control the second-order term -iter_TGV = 500; % number of Primal-Dual iterations for TGV -tic; u_tgv = TGV(single(vol3D), lambda_TGV, alpha1, alpha0, iter_TGV); toc; -rmseTGV = RMSE(Ideal3D(:),u_tgv(:)); -fprintf('%s %f \n', 'RMSE error for TGV is:', rmseTGV); -figure; imshow(u_tgv(:,:,3), [0 1]); title('TGV denoised volume (CPU)'); -%% -%>>>>>>>>>>>>>> MULTI-CHANNEL priors <<<<<<<<<<<<<<< % -fprintf('Denoise a volume using the FGP-dTV model (CPU) \n'); - -% create another volume (reference) with slightly less amount of noise -vol3D_ref = zeros(N,N,slices, 'single'); -for i = 1:slices -vol3D_ref(:,:,i) = Im + .01*randn(size(Im)); -end -vol3D_ref(vol3D_ref < 0) = 0; -% vol3D_ref = zeros(size(Im),'single'); % pass zero reference (dTV -> TV) - -iter_fgp = 300; % number of FGP iterations -epsil_tol = 1.0e-05; % tolerance -eta = 0.2; % Reference image gradient smoothing constant -tic; u_fgp_dtv = FGP_dTV(single(vol3D), single(vol3D_ref), lambda_reg, iter_fgp, epsil_tol, eta); toc; -figure; imshow(u_fgp_dtv(:,:,7), [0 1]); title('FGP-dTV denoised volume (CPU)'); -%% -fprintf('Denoise a volume using the FGP-dTV model (GPU) \n'); - -% create another volume (reference) with slightly less amount of noise -vol3D_ref = zeros(N,N,slices, 'single'); -for i = 1:slices -vol3D_ref(:,:,i) = Im + .01*randn(size(Im)); -end -vol3D_ref(vol3D_ref < 0) = 0; -% vol3D_ref = zeros(size(Im),'single'); % pass zero reference (dTV -> TV) - -iter_fgp = 300; % number of FGP iterations -epsil_tol = 1.0e-05; % tolerance -eta = 0.2; % Reference image gradient smoothing constant -tic; u_fgp_dtv_g = FGP_dTV_GPU(single(vol3D), single(vol3D_ref), lambda_reg, iter_fgp, epsil_tol, eta); toc; -figure; imshow(u_fgp_dtv_g(:,:,7), [0 1]); title('FGP-dTV denoised volume (GPU)'); -%% diff --git a/Wrappers/Matlab/demos/demoMatlab_denoise.m b/Wrappers/Matlab/demos/demoMatlab_denoise.m deleted file mode 100644 index 14d3096..0000000 --- a/Wrappers/Matlab/demos/demoMatlab_denoise.m +++ /dev/null @@ -1,189 +0,0 @@ -% Image (2D) denoising demo using CCPi-RGL -clear; close all -fsep = '/'; - -Path1 = sprintf(['..' fsep 'mex_compile' fsep 'installed'], 1i); -Path2 = sprintf(['..' fsep '..' fsep '..' fsep 'data' fsep], 1i); -Path3 = sprintf(['..' fsep 'supp'], 1i); -addpath(Path1); addpath(Path2); addpath(Path3); - -Im = double(imread('lena_gray_512.tif'))/255; % loading image -u0 = Im + .05*randn(size(Im)); u0(u0 < 0) = 0; -figure; imshow(u0, [0 1]); title('Noisy image'); - -lambda_reg = 0.03; % regularsation parameter for all methods -%% -fprintf('Denoise using the ROF-TV model (CPU) \n'); -tau_rof = 0.0025; % time-marching constant -iter_rof = 750; % number of ROF iterations -tic; u_rof = ROF_TV(single(u0), lambda_reg, iter_rof, tau_rof); toc; -energyfunc_val_rof = TV_energy(single(u_rof),single(u0),lambda_reg, 1); % get energy function value -rmseROF = (RMSE(u_rof(:),Im(:))); -fprintf('%s %f \n', 'RMSE error for ROF-TV is:', rmseROF); -figure; imshow(u_rof, [0 1]); title('ROF-TV denoised image (CPU)'); -%% -% fprintf('Denoise using the ROF-TV model (GPU) \n'); -% tau_rof = 0.0025; % time-marching constant -% iter_rof = 750; % number of ROF iterations -% tic; u_rofG = ROF_TV_GPU(single(u0), lambda_reg, iter_rof, tau_rof); toc; -% figure; imshow(u_rofG, [0 1]); title('ROF-TV denoised image (GPU)'); -%% -fprintf('Denoise using the FGP-TV model (CPU) \n'); -iter_fgp = 1000; % number of FGP iterations -epsil_tol = 1.0e-06; % tolerance -tic; u_fgp = FGP_TV(single(u0), lambda_reg, iter_fgp, epsil_tol); toc; -energyfunc_val_fgp = TV_energy(single(u_fgp),single(u0),lambda_reg, 1); % get energy function value -rmseFGP = (RMSE(u_fgp(:),Im(:))); -fprintf('%s %f \n', 'RMSE error for FGP-TV is:', rmseFGP); -figure; imshow(u_fgp, [0 1]); title('FGP-TV denoised image (CPU)'); - -%% -% fprintf('Denoise using the FGP-TV model (GPU) \n'); -% iter_fgp = 1000; % number of FGP iterations -% epsil_tol = 1.0e-05; % tolerance -% tic; u_fgpG = FGP_TV_GPU(single(u0), lambda_reg, iter_fgp, epsil_tol); toc; -% figure; imshow(u_fgpG, [0 1]); title('FGP-TV denoised image (GPU)'); -%% -fprintf('Denoise using the SB-TV model (CPU) \n'); -iter_sb = 150; % number of SB iterations -epsil_tol = 1.0e-06; % tolerance -tic; u_sb = SB_TV(single(u0), lambda_reg, iter_sb, epsil_tol); toc; -energyfunc_val_sb = TV_energy(single(u_sb),single(u0),lambda_reg, 1); % get energy function value -rmseSB = (RMSE(u_sb(:),Im(:))); -fprintf('%s %f \n', 'RMSE error for SB-TV is:', rmseSB); -figure; imshow(u_sb, [0 1]); title('SB-TV denoised image (CPU)'); -%% -% fprintf('Denoise using the SB-TV model (GPU) \n'); -% iter_sb = 150; % number of SB iterations -% epsil_tol = 1.0e-06; % tolerance -% tic; u_sbG = SB_TV_GPU(single(u0), lambda_reg, iter_sb, epsil_tol); toc; -% figure; imshow(u_sbG, [0 1]); title('SB-TV denoised image (GPU)'); -%% -fprintf('Denoise using the TGV model (CPU) \n'); -lambda_TGV = 0.045; % regularisation parameter -alpha1 = 1.0; % parameter to control the first-order term -alpha0 = 2.0; % parameter to control the second-order term -iter_TGV = 2000; % number of Primal-Dual iterations for TGV -tic; u_tgv = TGV(single(u0), lambda_TGV, alpha1, alpha0, iter_TGV); toc; -rmseTGV = (RMSE(u_tgv(:),Im(:))); -fprintf('%s %f \n', 'RMSE error for TGV is:', rmseTGV); -figure; imshow(u_tgv, [0 1]); title('TGV denoised image (CPU)'); -%% -% fprintf('Denoise using the TGV model (GPU) \n'); -% lambda_TGV = 0.045; % regularisation parameter -% alpha1 = 1.0; % parameter to control the first-order term -% alpha0 = 2.0; % parameter to control the second-order term -% iter_TGV = 2000; % number of Primal-Dual iterations for TGV -% tic; u_tgv_gpu = TGV_GPU(single(u0), lambda_TGV, alpha1, alpha0, iter_TGV); toc; -% rmseTGV_gpu = (RMSE(u_tgv_gpu(:),Im(:))); -% fprintf('%s %f \n', 'RMSE error for TGV is:', rmseTGV_gpu); -% figure; imshow(u_tgv_gpu, [0 1]); title('TGV denoised image (GPU)'); -%% -fprintf('Denoise using the ROF-LLT model (CPU) \n'); -lambda_ROF = lambda_reg; % ROF regularisation parameter -lambda_LLT = lambda_reg*0.45; % LLT regularisation parameter -iter_LLT = 1; % iterations -tau_rof_llt = 0.0025; % time-marching constant -tic; u_rof_llt = LLT_ROF(single(u0), lambda_ROF, lambda_LLT, iter_LLT, tau_rof_llt); toc; -rmseROFLLT = (RMSE(u_rof_llt(:),Im(:))); -fprintf('%s %f \n', 'RMSE error for TGV is:', rmseROFLLT); -figure; imshow(u_rof_llt, [0 1]); title('ROF-LLT denoised image (CPU)'); -%% -% fprintf('Denoise using the ROF-LLT model (GPU) \n'); -% lambda_ROF = lambda_reg; % ROF regularisation parameter -% lambda_LLT = lambda_reg*0.45; % LLT regularisation parameter -% iter_LLT = 500; % iterations -% tau_rof_llt = 0.0025; % time-marching constant -% tic; u_rof_llt_g = LLT_ROF_GPU(single(u0), lambda_ROF, lambda_LLT, iter_LLT, tau_rof_llt); toc; -% rmseROFLLT_g = (RMSE(u_rof_llt_g(:),Im(:))); -% fprintf('%s %f \n', 'RMSE error for TGV is:', rmseROFLLT_g); -% figure; imshow(u_rof_llt_g, [0 1]); title('ROF-LLT denoised image (GPU)'); -%% -fprintf('Denoise using Nonlinear-Diffusion model (CPU) \n'); -iter_diff = 800; % number of diffusion iterations -lambda_regDiff = 0.025; % regularisation for the diffusivity -sigmaPar = 0.015; % edge-preserving parameter -tau_param = 0.025; % time-marching constant -tic; u_diff = NonlDiff(single(u0), lambda_regDiff, sigmaPar, iter_diff, tau_param, 'Huber'); toc; -rmseDiffus = (RMSE(u_diff(:),Im(:))); -fprintf('%s %f \n', 'RMSE error for Nonlinear Diffusion is:', rmseDiffus); -figure; imshow(u_diff, [0 1]); title('Diffusion denoised image (CPU)'); -%% -% fprintf('Denoise using Nonlinear-Diffusion model (GPU) \n'); -% iter_diff = 800; % number of diffusion iterations -% lambda_regDiff = 0.025; % regularisation for the diffusivity -% sigmaPar = 0.015; % edge-preserving parameter -% tau_param = 0.025; % time-marching constant -% tic; u_diff_g = NonlDiff_GPU(single(u0), lambda_regDiff, sigmaPar, iter_diff, tau_param, 'Huber'); toc; -% figure; imshow(u_diff_g, [0 1]); title('Diffusion denoised image (GPU)'); -%% -fprintf('Denoise using Fourth-order anisotropic diffusion model (CPU) \n'); -iter_diff = 800; % number of diffusion iterations -lambda_regDiff = 3.5; % regularisation for the diffusivity -sigmaPar = 0.02; % edge-preserving parameter -tau_param = 0.0015; % time-marching constant -tic; u_diff4 = Diffusion_4thO(single(u0), lambda_regDiff, sigmaPar, iter_diff, tau_param); toc; -rmseDiffHO = (RMSE(u_diff4(:),Im(:))); -fprintf('%s %f \n', 'RMSE error for Fourth-order anisotropic diffusion is:', rmseDiffHO); -figure; imshow(u_diff4, [0 1]); title('Diffusion 4thO denoised image (CPU)'); -%% -% fprintf('Denoise using Fourth-order anisotropic diffusion model (GPU) \n'); -% iter_diff = 800; % number of diffusion iterations -% lambda_regDiff = 3.5; % regularisation for the diffusivity -% sigmaPar = 0.02; % edge-preserving parameter -% tau_param = 0.0015; % time-marching constant -% tic; u_diff4_g = Diffusion_4thO_GPU(single(u0), lambda_regDiff, sigmaPar, iter_diff, tau_param); toc; -% figure; imshow(u_diff4_g, [0 1]); title('Diffusion 4thO denoised image (GPU)'); -%% -fprintf('Weights pre-calculation for Non-local TV (takes time on CPU) \n'); -SearchingWindow = 7; -PatchWindow = 2; -NeighboursNumber = 20; % the number of neibours to include -h = 0.23; % edge related parameter for NLM -tic; [H_i, H_j, Weights] = PatchSelect(single(u0), SearchingWindow, PatchWindow, NeighboursNumber, h); toc; -%% -fprintf('Denoise using Non-local Total Variation (CPU) \n'); -iter_nltv = 3; % number of nltv iterations -lambda_nltv = 0.05; % regularisation parameter for nltv -tic; u_nltv = Nonlocal_TV(single(u0), H_i, H_j, 0, Weights, lambda_nltv, iter_nltv); toc; -rmse_nltv = (RMSE(u_nltv(:),Im(:))); -fprintf('%s %f \n', 'RMSE error for Non-local Total Variation is:', rmse_nltv); -figure; imagesc(u_nltv, [0 1]); colormap(gray); daspect([1 1 1]); title('Non-local Total Variation denoised image (CPU)'); -%% -%>>>>>>>>>>>>>> MULTI-CHANNEL priors <<<<<<<<<<<<<<< % - -fprintf('Denoise using the FGP-dTV model (CPU) \n'); -% create another image (reference) with slightly less amount of noise -u_ref = Im + .01*randn(size(Im)); u_ref(u_ref < 0) = 0; -% u_ref = zeros(size(Im),'single'); % pass zero reference (dTV -> TV) - -iter_fgp = 1000; % number of FGP iterations -epsil_tol = 1.0e-06; % tolerance -eta = 0.2; % Reference image gradient smoothing constant -tic; u_fgp_dtv = FGP_dTV(single(u0), single(u_ref), lambda_reg, iter_fgp, epsil_tol, eta); toc; -rmse_dTV= (RMSE(u_fgp_dtv(:),Im(:))); -fprintf('%s %f \n', 'RMSE error for Directional Total Variation (dTV) is:', rmse_dTV); -figure; imshow(u_fgp_dtv, [0 1]); title('FGP-dTV denoised image (CPU)'); -%% -% fprintf('Denoise using the FGP-dTV model (GPU) \n'); -% % create another image (reference) with slightly less amount of noise -% u_ref = Im + .01*randn(size(Im)); u_ref(u_ref < 0) = 0; -% % u_ref = zeros(size(Im),'single'); % pass zero reference (dTV -> TV) -% -% iter_fgp = 1000; % number of FGP iterations -% epsil_tol = 1.0e-06; % tolerance -% eta = 0.2; % Reference image gradient smoothing constant -% tic; u_fgp_dtvG = FGP_dTV_GPU(single(u0), single(u_ref), lambda_reg, iter_fgp, epsil_tol, eta); toc; -% figure; imshow(u_fgp_dtvG, [0 1]); title('FGP-dTV denoised image (GPU)'); -%% -fprintf('Denoise using the TNV prior (CPU) \n'); -slices = 5; N = 512; -vol3D = zeros(N,N,slices, 'single'); -for i = 1:slices -vol3D(:,:,i) = Im + .05*randn(size(Im)); -end -vol3D(vol3D < 0) = 0; - -iter_tnv = 200; % number of TNV iterations -tic; u_tnv = TNV(single(vol3D), lambda_reg, iter_tnv); toc; -figure; imshow(u_tnv(:,:,3), [0 1]); title('TNV denoised stack of channels (CPU)'); diff --git a/Wrappers/Matlab/demos/demoMatlab_inpaint.m b/Wrappers/Matlab/demos/demoMatlab_inpaint.m deleted file mode 100644 index 66f9c15..0000000 --- a/Wrappers/Matlab/demos/demoMatlab_inpaint.m +++ /dev/null @@ -1,35 +0,0 @@ -% Image (2D) inpainting demo using CCPi-RGL -clear; close all -Path1 = sprintf(['..' filesep 'mex_compile' filesep 'installed'], 1i); -Path2 = sprintf(['..' filesep '..' filesep '..' filesep 'data' filesep], 1i); -addpath(Path1); -addpath(Path2); - -load('SinoInpaint.mat'); -Sinogram = Sinogram./max(Sinogram(:)); -Sino_mask = Sinogram.*(1-single(Mask)); -figure; -subplot(1,2,1); imshow(Sino_mask, [0 1]); title('Missing data sinogram'); -subplot(1,2,2); imshow(Mask, [0 1]); title('Mask'); -%% -fprintf('Inpaint using Linear-Diffusion model (CPU) \n'); -iter_diff = 5000; % number of diffusion iterations -lambda_regDiff = 6000; % regularisation for the diffusivity -sigmaPar = 0.0; % edge-preserving parameter -tau_param = 0.000075; % time-marching constant -tic; u_diff = NonlDiff_Inp(single(Sino_mask), Mask, lambda_regDiff, sigmaPar, iter_diff, tau_param); toc; -figure; imshow(u_diff, [0 1]); title('Linear-Diffusion inpainted sinogram (CPU)'); -%% -fprintf('Inpaint using Nonlinear-Diffusion model (CPU) \n'); -iter_diff = 1500; % number of diffusion iterations -lambda_regDiff = 80; % regularisation for the diffusivity -sigmaPar = 0.00009; % edge-preserving parameter -tau_param = 0.000008; % time-marching constant -tic; u_diff = NonlDiff_Inp(single(Sino_mask), Mask, lambda_regDiff, sigmaPar, iter_diff, tau_param, 'Huber'); toc; -figure; imshow(u_diff, [0 1]); title('Non-Linear Diffusion inpainted sinogram (CPU)'); -%% -fprintf('Inpaint using Nonlocal Vertical Marching model (CPU) \n'); -Increment = 1; % linear increment for the searching window -tic; [u_nom,maskupd] = NonlocalMarching_Inpaint(single(Sino_mask), Mask, Increment); toc; -figure; imshow(u_nom, [0 1]); title('NVM inpainted sinogram (CPU)'); -%%
\ No newline at end of file |