From 09eb48ffbb4ad699e2eefd25678e10dc59d6a177 Mon Sep 17 00:00:00 2001 From: Daniil Kazantsev Date: Tue, 1 May 2018 09:44:07 +0100 Subject: new inpainters --- Wrappers/Matlab/demos/demoMatlab_3Ddenoise.m | 9 +++---- Wrappers/Matlab/demos/demoMatlab_denoise.m | 9 +++---- Wrappers/Matlab/demos/demoMatlab_inpaint.m | 35 ++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 Wrappers/Matlab/demos/demoMatlab_inpaint.m (limited to 'Wrappers/Matlab/demos') diff --git a/Wrappers/Matlab/demos/demoMatlab_3Ddenoise.m b/Wrappers/Matlab/demos/demoMatlab_3Ddenoise.m index 5a54d18..c087433 100644 --- a/Wrappers/Matlab/demos/demoMatlab_3Ddenoise.m +++ b/Wrappers/Matlab/demos/demoMatlab_3Ddenoise.m @@ -1,8 +1,9 @@ % Volume (3D) denoising demo using CCPi-RGL -clear -close all -addpath('../mex_compile/installed'); -addpath('../../../data/'); +clear; close all +Path1 = sprintf(['..' filesep 'mex_compile' filesep 'installed'], 1i); +Path2 = sprintf(['..' filesep '..' filesep '..' filesep 'data' filesep], 1i); +addpath(Path1); +addpath(Path2); N = 512; slices = 30; diff --git a/Wrappers/Matlab/demos/demoMatlab_denoise.m b/Wrappers/Matlab/demos/demoMatlab_denoise.m index 151a604..d93f477 100644 --- a/Wrappers/Matlab/demos/demoMatlab_denoise.m +++ b/Wrappers/Matlab/demos/demoMatlab_denoise.m @@ -1,8 +1,9 @@ % Image (2D) denoising demo using CCPi-RGL -clear -close all -addpath('../mex_compile/installed'); -addpath('../../../data/'); +clear; close all +Path1 = sprintf(['..' filesep 'mex_compile' filesep 'installed'], 1i); +Path2 = sprintf(['..' filesep '..' filesep '..' filesep 'data' filesep], 1i); +addpath(Path1); +addpath(Path2); Im = double(imread('lena_gray_512.tif'))/255; % loading image u0 = Im + .05*randn(size(Im)); u0(u0 < 0) = 0; diff --git a/Wrappers/Matlab/demos/demoMatlab_inpaint.m b/Wrappers/Matlab/demos/demoMatlab_inpaint.m new file mode 100644 index 0000000..66f9c15 --- /dev/null +++ b/Wrappers/Matlab/demos/demoMatlab_inpaint.m @@ -0,0 +1,35 @@ +% 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 -- cgit v1.2.3