summaryrefslogtreecommitdiffstats
path: root/Wrappers
diff options
context:
space:
mode:
Diffstat (limited to 'Wrappers')
-rw-r--r--Wrappers/CMakeLists.txt19
-rwxr-xr-xWrappers/Matlab/CMakeLists.txt147
-rw-r--r--Wrappers/Matlab/demos/demoMatlab_3Ddenoise.m186
-rw-r--r--Wrappers/Matlab/demos/demoMatlab_denoise.m209
-rw-r--r--Wrappers/Matlab/demos/demoMatlab_inpaint.m35
-rw-r--r--Wrappers/Matlab/mex_compile/compileCPU_mex_Linux.m81
-rw-r--r--Wrappers/Matlab/mex_compile/compileCPU_mex_WINDOWS.m135
-rw-r--r--Wrappers/Matlab/mex_compile/compileGPU_mex.m74
-rw-r--r--Wrappers/Matlab/mex_compile/installed/MEXed_files_location.txt0
-rw-r--r--Wrappers/Matlab/mex_compile/regularisers_CPU/Diffusion_4thO.c77
-rw-r--r--Wrappers/Matlab/mex_compile/regularisers_CPU/FGP_TV.c97
-rw-r--r--Wrappers/Matlab/mex_compile/regularisers_CPU/FGP_dTV.c114
-rw-r--r--Wrappers/Matlab/mex_compile/regularisers_CPU/LLT_ROF.c82
-rw-r--r--Wrappers/Matlab/mex_compile/regularisers_CPU/NonlDiff.c89
-rw-r--r--Wrappers/Matlab/mex_compile/regularisers_CPU/NonlDiff_Inp.c103
-rw-r--r--Wrappers/Matlab/mex_compile/regularisers_CPU/NonlocalMarching_Inpaint.c84
-rw-r--r--Wrappers/Matlab/mex_compile/regularisers_CPU/Nonlocal_TV.c88
-rw-r--r--Wrappers/Matlab/mex_compile/regularisers_CPU/PatchSelect.c92
-rw-r--r--Wrappers/Matlab/mex_compile/regularisers_CPU/ROF_TV.c77
-rw-r--r--Wrappers/Matlab/mex_compile/regularisers_CPU/SB_TV.c91
-rw-r--r--Wrappers/Matlab/mex_compile/regularisers_CPU/TGV.c83
-rw-r--r--Wrappers/Matlab/mex_compile/regularisers_CPU/TNV.c74
-rw-r--r--Wrappers/Matlab/mex_compile/regularisers_CPU/TV_energy.c72
-rw-r--r--Wrappers/Matlab/mex_compile/regularisers_GPU/Diffusion_4thO_GPU.cpp77
-rw-r--r--Wrappers/Matlab/mex_compile/regularisers_GPU/FGP_TV_GPU.cpp97
-rw-r--r--Wrappers/Matlab/mex_compile/regularisers_GPU/FGP_dTV_GPU.cpp113
-rw-r--r--Wrappers/Matlab/mex_compile/regularisers_GPU/LLT_ROF_GPU.cpp83
-rw-r--r--Wrappers/Matlab/mex_compile/regularisers_GPU/NonlDiff_GPU.cpp92
-rw-r--r--Wrappers/Matlab/mex_compile/regularisers_GPU/ROF_TV_GPU.cpp74
-rw-r--r--Wrappers/Matlab/mex_compile/regularisers_GPU/SB_TV_GPU.cpp91
-rw-r--r--Wrappers/Matlab/mex_compile/regularisers_GPU/TGV_GPU.cpp81
-rw-r--r--Wrappers/Matlab/supp/RMSE.m7
-rw-r--r--Wrappers/Matlab/supp/my_red_yellowMAP.matbin1761 -> 0 bytes
-rw-r--r--Wrappers/Python/CMakeLists.txt141
-rw-r--r--Wrappers/Python/ccpi/__init__.py0
-rw-r--r--Wrappers/Python/ccpi/filters/__init__.py0
-rw-r--r--Wrappers/Python/ccpi/filters/regularisers.py214
-rw-r--r--Wrappers/Python/ccpi/supp/__init__.py0
-rw-r--r--Wrappers/Python/ccpi/supp/qualitymetrics.py65
-rw-r--r--Wrappers/Python/conda-recipe/bld.bat20
-rw-r--r--Wrappers/Python/conda-recipe/build.sh17
-rw-r--r--Wrappers/Python/conda-recipe/conda_build_config.yaml9
-rw-r--r--Wrappers/Python/conda-recipe/lena_gray_512.tifbin262598 -> 0 bytes
-rw-r--r--Wrappers/Python/conda-recipe/meta.yaml40
-rwxr-xr-xWrappers/Python/conda-recipe/run_test.py819
-rw-r--r--Wrappers/Python/demos/demo_cpu_inpainters.py194
-rw-r--r--Wrappers/Python/demos/demo_cpu_regularisers.py572
-rw-r--r--Wrappers/Python/demos/demo_cpu_regularisers3D.py463
-rw-r--r--Wrappers/Python/demos/demo_cpu_vs_gpu_regularisers.py794
-rw-r--r--Wrappers/Python/demos/demo_gpu_regularisers.py512
-rw-r--r--Wrappers/Python/demos/demo_gpu_regularisers3D.py455
-rw-r--r--Wrappers/Python/setup-regularisers.py.in75
-rw-r--r--Wrappers/Python/src/cpu_regularisers.pyx685
-rw-r--r--Wrappers/Python/src/gpu_regularisers.pyx640
54 files changed, 0 insertions, 8539 deletions
diff --git a/Wrappers/CMakeLists.txt b/Wrappers/CMakeLists.txt
deleted file mode 100644
index bdcb8f4..0000000
--- a/Wrappers/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright 2017 Edoardo Pasca
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-if (BUILD_MATLAB_WRAPPER)
- add_subdirectory(Matlab)
-endif()
-if (BUILD_PYTHON_WRAPPER)
- add_subdirectory(Python)
-endif() \ No newline at end of file
diff --git a/Wrappers/Matlab/CMakeLists.txt b/Wrappers/Matlab/CMakeLists.txt
deleted file mode 100755
index 0c26148..0000000
--- a/Wrappers/Matlab/CMakeLists.txt
+++ /dev/null
@@ -1,147 +0,0 @@
-project(regulariserMatlab)
-
-
-find_package(Matlab REQUIRED COMPONENTS MAIN_PROGRAM MX_LIBRARY ENG_LIBRARY )
-
-
-
-#C:\Users\ofn77899\Documents\Projects\CCPi\GitHub\CCPi-FISTA_Reconstruction\Core\regularisers_CPU
-# matlab_add_mex(
- # NAME CPU_ROF
- # SRC
- # ${CMAKE_SOURCE_DIR}/Wrappers/Matlab/mex_compile/regularisers_CPU/ROF_TV.c
- # LINK_TO cilreg ${Matlab_LIBRARIES}
- # )
-
-# target_include_directories(CPU_ROF
- # PUBLIC ${CMAKE_SOURCE_DIR}/Core/regularisers_CPU
- # ${CMAKE_SOURCE_DIR}/Core/regularisers_GPU
- # ${CMAKE_SOURCE_DIR}/Core/inpainters_CPU
- # ${CMAKE_SOURCE_DIR}/Core/
- # ${MATLAB_INCLUDE_DIR})
-
- # matlab_add_mex(
- # NAME CPU_TNV
- # SRC
- # ${CMAKE_SOURCE_DIR}/Wrappers/Matlab/mex_compile/regularisers_CPU/TNV.c
- # LINK_TO cilreg ${Matlab_LIBRARIES}
- # )
-
-# target_include_directories(CPU_TNV
- # PUBLIC ${CMAKE_SOURCE_DIR}/Core/regularisers_CPU
- # ${CMAKE_SOURCE_DIR}/Core/regularisers_GPU
- # ${CMAKE_SOURCE_DIR}/Core/inpainters_CPU
- # ${CMAKE_SOURCE_DIR}/Core/
- # ${MATLAB_INCLUDE_DIR})
-
-#set (CPU_MEX_FILES "regularisers_CPU/TNV.c;regularisers_CPU/ROF_TV.c")
-#set (MEX_TARGETS "CPU_TNV;CPU_ROF")
-#list(APPEND MEX_TARGETS "CPU_TNV")
-#list(APPEND MEX_TARGETS "CPU_ROF")
-
-file(GLOB CPU_MEX_FILES
- "${CMAKE_SOURCE_DIR}/Wrappers/Matlab/mex_compile/regularisers_CPU/*.c"
- #"${CMAKE_SOURCE_DIR}/Wrappers/Matlab/mex_compile/regularisers_GPU/*.c"
-)
-
-#message("CPU_MEX_FILES " ${CPU_MEX_FILES})
-
-list(LENGTH CPU_MEX_FILES num)
-
-
-MATH(EXPR num "${num}-1")
-#set(num "-1")
-message("found ${num} files")
-
-foreach(tgt RANGE 0 ${num})
- message("number " ${tgt})
- list(LENGTH CPU_MEX_FILES num2)
- message("the list is ${num2}")
- #list(GET CPU_TARGETS ${tgt} current_target)
- list(GET CPU_MEX_FILES ${tgt} current_file_name)
- get_filename_component(current_file ${current_file_name} NAME)
- string(REGEX MATCH "(.+).c" match ${current_file})
- if (NOT ${match} EQUAL "" )
- set (current_target ${CMAKE_MATCH_1})
- endif()
- message("matlab_add_mex target " ${current_file} " and " ${current_target})
- matlab_add_mex(
- NAME ${current_target}
- SRC
- ${current_file_name}
- #${CMAKE_SOURCE_DIR}/Core/regularisers_CPU/FGP_TV_core.c
- #${CMAKE_SOURCE_DIR}/Core/regularisers_CPU/SB_TV_core.c
- #${CMAKE_SOURCE_DIR}/Core/regularisers_CPU/TGV_core.c
- #${CMAKE_SOURCE_DIR}/Core/regularisers_CPU/Diffusion_core.c
- #${CMAKE_SOURCE_DIR}/Core/regularisers_CPU/Diffus4th_order_core.c
- #${CMAKE_SOURCE_DIR}/Core/regularisers_CPU/LLT_ROF_core.c
- #${CMAKE_SOURCE_DIR}/Core/regularisers_CPU/ROF_TV_core.c
- #${CMAKE_SOURCE_DIR}/Core/regularisers_CPU/FGP_dTV_core.c
- #${CMAKE_SOURCE_DIR}/Core/regularisers_CPU/TNV_core.c
- #${CMAKE_SOURCE_DIR}/Core/regularisers_CPU/utils.c
- #${CMAKE_SOURCE_DIR}/Core/inpainters_CPU/Diffusion_Inpaint_core.c
- #${CMAKE_SOURCE_DIR}/Core/inpainters_CPU/NonlocalMarching_Inpaint_core.c
- LINK_TO cilreg ${Matlab_LIBRARIES}
- )
-
-target_include_directories(${current_target}
- PUBLIC ${CMAKE_SOURCE_DIR}/Core/regularisers_CPU
- ${CMAKE_SOURCE_DIR}/Core/regularisers_GPU
- ${CMAKE_SOURCE_DIR}/Core/inpainters_CPU
- ${CMAKE_SOURCE_DIR}/Core/
- ${MATLAB_INCLUDE_DIR})
- set_property(TARGET ${current_target} PROPERTY C_STANDARD 99)
- list(APPEND CPU_MEX_TARGETS ${current_target})
- INSTALL(TARGETS ${current_target} DESTINATION "${MATLAB_DEST}")
-endforeach()
-
-add_custom_target(MatlabWrapper DEPENDS ${CPU_MEX_TARGETS})
-
-if (BUILD_CUDA)
- find_package(CUDA)
- if (CUDA_FOUND)
- file(GLOB GPU_MEX_FILES
- "${CMAKE_SOURCE_DIR}/Wrappers/Matlab/mex_compile/regularisers_GPU/*.cpp"
- )
-
- list(LENGTH GPU_MEX_FILES num)
-message("number of GPU files " ${num})
-
- MATH(EXPR num "${num}-1")
- #set(num "-1")
-
- foreach(tgt RANGE ${num})
- message("number " ${tgt})
- list(LENGTH GPU_MEX_FILES num2)
- message("the list is ${num2}")
- #list(GET CPU_TARGETS ${tgt} current_target)
- list(GET GPU_MEX_FILES ${tgt} current_file_name)
- get_filename_component(current_file ${current_file_name} NAME)
- string(REGEX MATCH "(.+).c" match ${current_file})
- if (NOT ${match} EQUAL "" )
- set (current_target ${CMAKE_MATCH_1})
- endif()
- message("matlab_add_mex target " ${current_file} " and " ${current_target})
- message("matlab_add_mex " ${current_target})
- matlab_add_mex(
- NAME ${current_target}
- SRC
- ${current_file_name}
- LINK_TO cilregcuda ${Matlab_LIBRARIES}
- )
-
- target_include_directories(${current_target}
- PUBLIC ${CMAKE_SOURCE_DIR}/Core/regularisers_CPU
- ${CMAKE_SOURCE_DIR}/Core/regularisers_GPU
- ${CMAKE_SOURCE_DIR}/Core/inpainters_CPU
- ${CMAKE_SOURCE_DIR}/Core/
- ${MATLAB_INCLUDE_DIR})
-
- list(APPEND GPU_MEX_TARGETS ${current_target})
- INSTALL(TARGETS ${current_target} DESTINATION "${MATLAB_DEST}")
- endforeach()
-
- add_custom_target(MatlabWrapperGPU DEPENDS ${GPU_MEX_TARGETS})
-
- endif()
-endif()
diff --git a/Wrappers/Matlab/demos/demoMatlab_3Ddenoise.m b/Wrappers/Matlab/demos/demoMatlab_3Ddenoise.m
deleted file mode 100644
index ac8e1ba..0000000
--- a/Wrappers/Matlab/demos/demoMatlab_3Ddenoise.m
+++ /dev/null
@@ -1,186 +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 = 15;
-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(:,:,7), [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)');
-%%
-% fprintf('Denoise using the TGV model (GPU) \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_gpu = TGV_GPU(single(vol3D), lambda_TGV, alpha1, alpha0, iter_TGV); toc;
-% rmseTGV = RMSE(Ideal3D(:),u_tgv_gpu(:));
-% fprintf('%s %f \n', 'RMSE error for TGV is:', rmseTGV);
-% figure; imshow(u_tgv_gpu(:,:,3), [0 1]); title('TGV denoised volume (GPU)');
-%%
-%>>>>>>>>>>>>>> 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 7e041c6..0000000
--- a/Wrappers/Matlab/demos/demoMatlab_denoise.m
+++ /dev/null
@@ -1,209 +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');
-
-%%
-fprintf('Denoise using the ROF-TV model (CPU) \n');
-lambda_reg = 0.017; % regularsation parameter for all methods
-tau_rof = 0.0025; % time-marching constant
-iter_rof = 1200; % 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);
-[ssimval] = ssim(u_rof*255,single(Im)*255);
-fprintf('%s %f \n', 'MSSIM error for ROF-TV is:', ssimval);
-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 = 1200; % 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');
-lambda_reg = 0.033;
-iter_fgp = 300; % number of FGP iterations
-epsil_tol = 1.0e-09; % 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);
-[ssimval] = ssim(u_fgp*255,single(Im)*255);
-fprintf('%s %f \n', 'MSSIM error for FGP-TV is:', ssimval);
-figure; imshow(u_fgp, [0 1]); title('FGP-TV denoised image (CPU)');
-%%
-% fprintf('Denoise using the FGP-TV model (GPU) \n');
-% iter_fgp = 300; % number of FGP iterations
-% epsil_tol = 1.0e-09; % 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 = 80; % number of SB iterations
-epsil_tol = 1.0e-08; % 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);
-[ssimval] = ssim(u_sb*255,single(Im)*255);
-fprintf('%s %f \n', 'MSSIM error for SB-TV is:', ssimval);
-figure; imshow(u_sb, [0 1]); title('SB-TV denoised image (CPU)');
-%%
-% fprintf('Denoise using the SB-TV model (GPU) \n');
-% iter_sb = 80; % 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 Nonlinear-Diffusion model (CPU) \n');
-iter_diff = 450; % number of diffusion iterations
-lambda_regDiff = 0.025; % regularisation for the diffusivity
-sigmaPar = 0.015; % edge-preserving parameter
-tau_param = 0.02; % 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);
-[ssimval] = ssim(u_diff*255,single(Im)*255);
-fprintf('%s %f \n', 'MSSIM error for NDF is:', ssimval);
-figure; imshow(u_diff, [0 1]); title('Diffusion denoised image (CPU)');
-%%
-% fprintf('Denoise using Nonlinear-Diffusion model (GPU) \n');
-% iter_diff = 450; % 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 the TGV model (CPU) \n');
-lambda_TGV = 0.034; % regularisation parameter
-alpha1 = 1.0; % parameter to control the first-order term
-alpha0 = 1.0; % parameter to control the second-order term
-iter_TGV = 500; % 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);
-[ssimval] = ssim(u_tgv*255,single(Im)*255);
-fprintf('%s %f \n', 'MSSIM error for TGV is:', ssimval);
-figure; imshow(u_tgv, [0 1]); title('TGV denoised image (CPU)');
-%%
-% fprintf('Denoise using the TGV model (GPU) \n');
-% lambda_TGV = 0.034; % regularisation parameter
-% alpha1 = 1.0; % parameter to control the first-order term
-% alpha0 = 1.0; % parameter to control the second-order term
-% iter_TGV = 500; % 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);
-% [ssimval] = ssim(u_tgv_gpu*255,single(Im)*255);
-% fprintf('%s %f \n', 'MSSIM error for TGV is:', ssimval);
-% figure; imshow(u_tgv_gpu, [0 1]); title('TGV denoised image (GPU)');
-%%
-fprintf('Denoise using the ROF-LLT model (CPU) \n');
-lambda_ROF = 0.016; % ROF regularisation parameter
-lambda_LLT = lambda_reg*0.25; % LLT regularisation parameter
-iter_LLT = 500; % 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);
-[ssimval] = ssim(u_rof_llt*255,single(Im)*255);
-fprintf('%s %f \n', 'MSSIM error for ROFLLT is:', ssimval);
-figure; imshow(u_rof_llt, [0 1]); title('ROF-LLT denoised image (CPU)');
-%%
-% fprintf('Denoise using the ROF-LLT model (GPU) \n');
-% lambda_ROF = 0.016; % ROF regularisation parameter
-% lambda_LLT = lambda_reg*0.25; % 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 Fourth-order anisotropic diffusion model (CPU) \n');
-iter_diff = 800; % number of diffusion iterations
-lambda_regDiff = 3.5; % regularisation for the diffusivity
-sigmaPar = 0.021; % 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);
-[ssimval] = ssim(u_diff4*255,single(Im)*255);
-fprintf('%s %f \n', 'MSSIM error for DIFF4th is:', ssimval);
-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.055; % 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);
-[ssimval] = ssim(u_nltv*255,single(Im)*255);
-fprintf('%s %f \n', 'MSSIM error for NLTV is:', ssimval);
-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
diff --git a/Wrappers/Matlab/mex_compile/compileCPU_mex_Linux.m b/Wrappers/Matlab/mex_compile/compileCPU_mex_Linux.m
deleted file mode 100644
index 72a828e..0000000
--- a/Wrappers/Matlab/mex_compile/compileCPU_mex_Linux.m
+++ /dev/null
@@ -1,81 +0,0 @@
-% execute this mex file on Linux in Matlab once
-
-fsep = '/';
-
-pathcopyFrom = sprintf(['..' fsep '..' fsep '..' fsep 'Core' fsep 'regularisers_CPU'], 1i);
-pathcopyFrom1 = sprintf(['..' fsep '..' fsep '..' fsep 'Core' fsep 'CCPiDefines.h'], 1i);
-pathcopyFrom2 = sprintf(['..' fsep '..' fsep '..' fsep 'Core' fsep 'inpainters_CPU'], 1i);
-
-copyfile(pathcopyFrom, 'regularisers_CPU');
-copyfile(pathcopyFrom1, 'regularisers_CPU');
-copyfile(pathcopyFrom2, 'regularisers_CPU');
-
-cd regularisers_CPU
-
-Pathmove = sprintf(['..' fsep 'installed' fsep], 1i);
-
-fprintf('%s \n', '<<<<<<<<<<<Compiling CPU regularisers>>>>>>>>>>>>>');
-
-fprintf('%s \n', 'Compiling ROF-TV...');
-mex ROF_TV.c ROF_TV_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp"
-movefile('ROF_TV.mex*',Pathmove);
-
-fprintf('%s \n', 'Compiling FGP-TV...');
-mex FGP_TV.c FGP_TV_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp"
-movefile('FGP_TV.mex*',Pathmove);
-
-fprintf('%s \n', 'Compiling SB-TV...');
-mex SB_TV.c SB_TV_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp"
-movefile('SB_TV.mex*',Pathmove);
-
-fprintf('%s \n', 'Compiling dFGP-TV...');
-mex FGP_dTV.c FGP_dTV_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp"
-movefile('FGP_dTV.mex*',Pathmove);
-
-fprintf('%s \n', 'Compiling TNV...');
-mex TNV.c TNV_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp"
-movefile('TNV.mex*',Pathmove);
-
-fprintf('%s \n', 'Compiling NonLinear Diffusion...');
-mex NonlDiff.c Diffusion_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp"
-movefile('NonlDiff.mex*',Pathmove);
-
-fprintf('%s \n', 'Compiling Anisotropic diffusion of higher order...');
-mex Diffusion_4thO.c Diffus4th_order_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp"
-movefile('Diffusion_4thO.mex*',Pathmove);
-
-fprintf('%s \n', 'Compiling TGV...');
-mex TGV.c TGV_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp"
-movefile('TGV.mex*',Pathmove);
-
-fprintf('%s \n', 'Compiling ROF-LLT...');
-mex LLT_ROF.c LLT_ROF_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp"
-movefile('LLT_ROF.mex*',Pathmove);
-
-fprintf('%s \n', 'Compiling NonLocal-TV...');
-mex PatchSelect.c PatchSelect_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp"
-mex Nonlocal_TV.c Nonlocal_TV_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp"
-movefile('Nonlocal_TV.mex*',Pathmove);
-movefile('PatchSelect.mex*',Pathmove);
-
-fprintf('%s \n', 'Compiling additional tools...');
-mex TV_energy.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp"
-movefile('TV_energy.mex*',Pathmove);
-
-%############Inpainters##############%
-fprintf('%s \n', 'Compiling Nonlinear/Linear diffusion inpainting...');
-mex NonlDiff_Inp.c Diffusion_Inpaint_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp"
-movefile('NonlDiff_Inp.mex*',Pathmove);
-
-fprintf('%s \n', 'Compiling Nonlocal marching method for inpainting...');
-mex NonlocalMarching_Inpaint.c NonlocalMarching_Inpaint_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp"
-movefile('NonlocalMarching_Inpaint.mex*',Pathmove);
-
-delete SB_TV_core* ROF_TV_core* FGP_TV_core* FGP_dTV_core* TNV_core* utils* Diffusion_core* Diffus4th_order_core* TGV_core* LLT_ROF_core* CCPiDefines.h
-delete PatchSelect_core* Nonlocal_TV_core*
-delete Diffusion_Inpaint_core* NonlocalMarching_Inpaint_core*
-fprintf('%s \n', '<<<<<<< Regularisers successfully compiled! >>>>>>>');
-
-pathA2 = sprintf(['..' fsep '..' fsep], 1i);
-cd(pathA2);
-cd demos
diff --git a/Wrappers/Matlab/mex_compile/compileCPU_mex_WINDOWS.m b/Wrappers/Matlab/mex_compile/compileCPU_mex_WINDOWS.m
deleted file mode 100644
index 6f7541c..0000000
--- a/Wrappers/Matlab/mex_compile/compileCPU_mex_WINDOWS.m
+++ /dev/null
@@ -1,135 +0,0 @@
-% execute this mex file on Windows in Matlab once
-
-% >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-% I've been able to compile on Windows 7 with MinGW and Matlab 2016b, however,
-% not sure if openmp is enabled after the compilation.
-
-% Here I present two ways how software can be compiled, if you have some
-% other suggestions/remarks please contact me at dkazanc@hotmail.com
-% >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-fsep = '/';
-
-pathcopyFrom = sprintf(['..' fsep '..' fsep '..' fsep 'Core' fsep 'regularisers_CPU'], 1i);
-pathcopyFrom1 = sprintf(['..' fsep '..' fsep '..' fsep 'Core' fsep 'CCPiDefines.h'], 1i);
-pathcopyFrom2 = sprintf(['..' fsep '..' fsep '..' fsep 'Core' fsep 'inpainters_CPU'], 1i);
-
-copyfile(pathcopyFrom, 'regularisers_CPU');
-copyfile(pathcopyFrom1, 'regularisers_CPU');
-copyfile(pathcopyFrom2, 'regularisers_CPU');
-
-cd regularisers_CPU
-
-Pathmove = sprintf(['..' fsep 'installed' fsep], 1i);
-
-fprintf('%s \n', '<<<<<<<<<<<Compiling CPU regularisers>>>>>>>>>>>>>');
-
-fprintf('%s \n', 'Compiling ROF-TV...');
-mex ROF_TV.c ROF_TV_core.c utils.c COMPFLAGS="\$COMPFLAGS -fopenmp -Wall -std=c99"
-movefile('ROF_TV.mex*',Pathmove);
-
-fprintf('%s \n', 'Compiling FGP-TV...');
-mex FGP_TV.c FGP_TV_core.c utils.c COMPFLAGS="\$COMPFLAGS -fopenmp -Wall -std=c99"
-movefile('FGP_TV.mex*',Pathmove);
-
-fprintf('%s \n', 'Compiling SB-TV...');
-mex SB_TV.c SB_TV_core.c utils.c COMPFLAGS="\$COMPFLAGS -fopenmp -Wall -std=c99"
-movefile('SB_TV.mex*',Pathmove);
-
-fprintf('%s \n', 'Compiling dFGP-TV...');
-mex FGP_dTV.c FGP_dTV_core.c utils.c COMPFLAGS="\$COMPFLAGS -fopenmp -Wall -std=c99"
-movefile('FGP_dTV.mex*',Pathmove);
-
-fprintf('%s \n', 'Compiling TNV...');
-mex TNV.c TNV_core.c utils.c COMPFLAGS="\$COMPFLAGS -fopenmp -Wall -std=c99"
-movefile('TNV.mex*',Pathmove);
-
-fprintf('%s \n', 'Compiling NonLinear Diffusion...');
-mex NonlDiff.c Diffusion_core.c utils.c COMPFLAGS="\$COMPFLAGS -fopenmp -Wall -std=c99"
-movefile('NonlDiff.mex*',Pathmove);
-
-fprintf('%s \n', 'Compiling Anisotropic diffusion of higher order...');
-mex Diffusion_4thO.c Diffus4th_order_core.c utils.c COMPFLAGS="\$COMPFLAGS -fopenmp -Wall -std=c99"
-movefile('Diffusion_4thO.mex*',Pathmove);
-
-fprintf('%s \n', 'Compiling TGV...');
-mex TGV.c TGV_core.c utils.c COMPFLAGS="\$COMPFLAGS -fopenmp -Wall -std=c99"
-movefile('TGV.mex*',Pathmove);
-
-fprintf('%s \n', 'Compiling ROF-LLT...');
-mex LLT_ROF.c LLT_ROF_core.c utils.c COMPFLAGS="\$COMPFLAGS -fopenmp -Wall -std=c99"
-movefile('LLT_ROF.mex*',Pathmove);
-
-fprintf('%s \n', 'Compiling NonLocal-TV...');
-mex PatchSelect.c PatchSelect_core.c utils.c COMPFLAGS="\$COMPFLAGS -fopenmp -Wall -std=c99"
-mex Nonlocal_TV.c Nonlocal_TV_core.c utils.c COMPFLAGS="\$COMPFLAGS -fopenmp -Wall -std=c99"
-movefile('Nonlocal_TV.mex*',Pathmove);
-movefile('PatchSelect.mex*',Pathmove);
-
-fprintf('%s \n', 'Compiling additional tools...');
-mex TV_energy.c utils.c COMPFLAGS="\$COMPFLAGS -fopenmp -Wall -std=c99"
-movefile('TV_energy.mex*',Pathmove);
-
-%############Inpainters##############%
-fprintf('%s \n', 'Compiling Nonlinear/Linear diffusion inpainting...');
-mex NonlDiff_Inp.c Diffusion_Inpaint_core.c utils.c COMPFLAGS="\$COMPFLAGS -fopenmp -Wall -std=c99"
-movefile('NonlDiff_Inp.mex*',Pathmove);
-
-fprintf('%s \n', 'Compiling Nonlocal marching method for inpaiting...');
-mex NonlocalMarching_Inpaint.c NonlocalMarching_Inpaint_core.c utils.c COMPFLAGS="\$COMPFLAGS -fopenmp -Wall -std=c99"
-movefile('NonlocalMarching_Inpaint.mex*',Pathmove);
-
-
-%%
-%%% The second approach to compile using TDM-GCC which follows this
-%%% discussion:
-%%% https://uk.mathworks.com/matlabcentral/answers/279171-using-mingw-compiler-and-open-mp#comment_359122
-%%% 1. Install TDM-GCC independently from http://tdm-gcc.tdragon.net/ (I installed 5.1.0)
-%%% Install openmp version: http://sourceforge.net/projects/tdm-gcc/files/TDM-GCC%205%20series/5.1.0-tdm64-1/gcc-5.1.0-tdm64-1-openmp.zip/download
-%%% 2. Link til libgomp.a in that installation when compilling your mex file.
-
-%%% assuming you unzipped TDM GCC (OpenMp) in folder TDMGCC on C drive, uncomment
-%%% bellow
-% fprintf('%s \n', 'Compiling CPU regularisers...');
-% mex C:\TDMGCC\lib\gcc\x86_64-w64-mingw32\5.1.0\libgomp.a CXXFLAGS="$CXXFLAGS -std=c++11 -fopenmp" ROF_TV.c ROF_TV_core.c utils.c
-% movefile('ROF_TV.mex*',Pathmove);
-% mex C:\TDMGCC\lib\gcc\x86_64-w64-mingw32\5.1.0\libgomp.a CXXFLAGS="$CXXFLAGS -std=c++11 -fopenmp" FGP_TV.c FGP_TV_core.c utils.c
-% movefile('FGP_TV.mex*',Pathmove);
-% mex C:\TDMGCC\lib\gcc\x86_64-w64-mingw32\5.1.0\libgomp.a CXXFLAGS="$CXXFLAGS -std=c++11 -fopenmp" SB_TV.c SB_TV_core.c utils.c
-% movefile('SB_TV.mex*',Pathmove);
-% mex C:\TDMGCC\lib\gcc\x86_64-w64-mingw32\5.1.0\libgomp.a CXXFLAGS="$CXXFLAGS -std=c++11 -fopenmp" FGP_dTV.c FGP_dTV_core.c utils.c
-% movefile('FGP_dTV.mex*',Pathmove);
-% mex C:\TDMGCC\lib\gcc\x86_64-w64-mingw32\5.1.0\libgomp.a CXXFLAGS="$CXXFLAGS -std=c++11 -fopenmp" TNV.c TNV_core.c utils.c
-% movefile('TNV.mex*',Pathmove);
-% mex C:\TDMGCC\lib\gcc\x86_64-w64-mingw32\5.1.0\libgomp.a CXXFLAGS="$CXXFLAGS -std=c++11 -fopenmp" NonlDiff.c Diffusion_core.c utils.c
-% movefile('NonlDiff.mex*',Pathmove);
-% mex C:\TDMGCC\lib\gcc\x86_64-w64-mingw32\5.1.0\libgomp.a CXXFLAGS="$CXXFLAGS -std=c++11 -fopenmp" Diffusion_4thO.c Diffus4th_order_core.c utils.c
-% movefile('Diffusion_4thO.mex*',Pathmove);
-% mex C:\TDMGCC\lib\gcc\x86_64-w64-mingw32\5.1.0\libgomp.a CXXFLAGS="$CXXFLAGS -std=c++11 -fopenmp" TGV.c TGV_core.c utils.c
-% movefile('TGV.mex*',Pathmove);
-% mex C:\TDMGCC\lib\gcc\x86_64-w64-mingw32\5.1.0\libgomp.a CXXFLAGS="$CXXFLAGS -std=c++11 -fopenmp" LLT_ROF.c LLT_ROF_core.c utils.c
-% movefile('LLT_ROF.mex*',Pathmove);
-% mex C:\TDMGCC\lib\gcc\x86_64-w64-mingw32\5.1.0\libgomp.a CXXFLAGS="$CXXFLAGS -std=c++11 -fopenmp" PatchSelect.c PatchSelect_core.c utils.c
-% mex C:\TDMGCC\lib\gcc\x86_64-w64-mingw32\5.1.0\libgomp.a CXXFLAGS="$CXXFLAGS -std=c++11 -fopenmp" Nonlocal_TV.c Nonlocal_TV_core.c utils.c
-% movefile('Nonlocal_TV.mex*',Pathmove);
-% movefile('PatchSelect.mex*',Pathmove);
-% mex C:\TDMGCC\lib\gcc\x86_64-w64-mingw32\5.1.0\libgomp.a CXXFLAGS="$CXXFLAGS -std=c++11 -fopenmp" TV_energy.c utils.c
-% movefile('TV_energy.mex*',Pathmove);
-% mex C:\TDMGCC\lib\gcc\x86_64-w64-mingw32\5.1.0\libgomp.a CXXFLAGS="$CXXFLAGS -std=c++11 -fopenmp" NonlDiff_Inp.c Diffusion_Inpaint_core.c utils.c
-% movefile('NonlDiff_Inp.mex*',Pathmove);
-% mex C:\TDMGCC\lib\gcc\x86_64-w64-mingw32\5.1.0\libgomp.a CXXFLAGS="$CXXFLAGS -std=c++11 -fopenmp" NonlocalMarching_Inpaint.c NonlocalMarching_Inpaint_core.c utils.c
-% movefile('NonlocalMarching_Inpaint.mex*',Pathmove);
-
-
-delete SB_TV_core* ROF_TV_core* FGP_TV_core* FGP_dTV_core* TNV_core* utils* Diffusion_core* Diffus4th_order_core* TGV_core* CCPiDefines.h
-delete PatchSelect_core* Nonlocal_TV_core*
-delete Diffusion_Inpaint_core* NonlocalMarching_Inpaint_core*
-fprintf('%s \n', 'Regularisers successfully compiled!');
-
-
-%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-%pathA2 = sprintf(['..' fsep '..' fsep], 1i);
-%cd(pathA2);
-%cd demos
diff --git a/Wrappers/Matlab/mex_compile/compileGPU_mex.m b/Wrappers/Matlab/mex_compile/compileGPU_mex.m
deleted file mode 100644
index dd1475c..0000000
--- a/Wrappers/Matlab/mex_compile/compileGPU_mex.m
+++ /dev/null
@@ -1,74 +0,0 @@
-% execute this mex file in Matlab once
-
-%>>>>>>>>>>>>>>>>>Important<<<<<<<<<<<<<<<<<<<
-% In order to compile CUDA modules one needs to have nvcc-compiler
-% installed (see CUDA SDK), check it under MATLAB with !nvcc --version
-
-% In the code bellow we provide a full explicit path to nvcc compiler
-% ! paths to matlab and CUDA sdk can be different, modify accordingly !
-
-% Tested on Ubuntu 18.04/MATLAB 2016b/cuda10.0/gcc7.3
-
-% Installation HAS NOT been tested on Windows, please you Cmake build or
-% modify the code bellow accordingly
-fsep = '/';
-
-pathcopyFrom = sprintf(['..' fsep '..' fsep '..' fsep 'Core' fsep 'regularisers_GPU'], 1i);
-pathcopyFrom1 = sprintf(['..' fsep '..' fsep '..' fsep 'Core' fsep 'CCPiDefines.h'], 1i);
-
-copyfile(pathcopyFrom, 'regularisers_GPU');
-copyfile(pathcopyFrom1, 'regularisers_GPU');
-
-cd regularisers_GPU
-
-Pathmove = sprintf(['..' fsep 'installed' fsep], 1i);
-
-fprintf('%s \n', '<<<<<<<<<<<Compiling GPU regularisers (CUDA)>>>>>>>>>>>>>');
-
-fprintf('%s \n', 'Compiling ROF-TV...');
-!/usr/local/cuda/bin/nvcc -O0 -c TV_ROF_GPU_core.cu -Xcompiler -fPIC -I~/SOFT/MATLAB9/extern/include/
-mex -g -I/usr/local/cuda-10.0/include -L/usr/local/cuda-10.0/lib64 -lcudart -lcufft -lmwgpu ROF_TV_GPU.cpp TV_ROF_GPU_core.o
-movefile('ROF_TV_GPU.mex*',Pathmove);
-
-fprintf('%s \n', 'Compiling FGP-TV...');
-!/usr/local/cuda/bin/nvcc -O0 -c TV_FGP_GPU_core.cu -Xcompiler -fPIC -I~/SOFT/MATLAB9/extern/include/
-mex -g -I/usr/local/cuda-10.0/include -L/usr/local/cuda-10.0/lib64 -lcudart -lcufft -lmwgpu FGP_TV_GPU.cpp TV_FGP_GPU_core.o
-movefile('FGP_TV_GPU.mex*',Pathmove);
-
-fprintf('%s \n', 'Compiling SB-TV...');
-!/usr/local/cuda/bin/nvcc -O0 -c TV_SB_GPU_core.cu -Xcompiler -fPIC -I~/SOFT/MATLAB9/extern/include/
-mex -g -I/usr/local/cuda-10.0/include -L/usr/local/cuda-10.0/lib64 -lcudart -lcufft -lmwgpu SB_TV_GPU.cpp TV_SB_GPU_core.o
-movefile('SB_TV_GPU.mex*',Pathmove);
-
-fprintf('%s \n', 'Compiling TGV...');
-!/usr/local/cuda/bin/nvcc -O0 -c TGV_GPU_core.cu -Xcompiler -fPIC -I~/SOFT/MATLAB9/extern/include/
-mex -g -I/usr/local/cuda-10.0/include -L/usr/local/cuda-10.0/lib64 -lcudart -lcufft -lmwgpu TGV_GPU.cpp TGV_GPU_core.o
-movefile('TGV_GPU.mex*',Pathmove);
-
-fprintf('%s \n', 'Compiling dFGP-TV...');
-!/usr/local/cuda/bin/nvcc -O0 -c dTV_FGP_GPU_core.cu -Xcompiler -fPIC -I~/SOFT/MATLAB9/extern/include/
-mex -g -I/usr/local/cuda-10.0/include -L/usr/local/cuda-10.0/lib64 -lcudart -lcufft -lmwgpu FGP_dTV_GPU.cpp dTV_FGP_GPU_core.o
-movefile('FGP_dTV_GPU.mex*',Pathmove);
-
-fprintf('%s \n', 'Compiling NonLinear Diffusion...');
-!/usr/local/cuda/bin/nvcc -O0 -c NonlDiff_GPU_core.cu -Xcompiler -fPIC -I~/SOFT/MATLAB9/extern/include/
-mex -g -I/usr/local/cuda-10.0/include -L/usr/local/cuda-10.0/lib64 -lcudart -lcufft -lmwgpu NonlDiff_GPU.cpp NonlDiff_GPU_core.o
-movefile('NonlDiff_GPU.mex*',Pathmove);
-
-fprintf('%s \n', 'Compiling Anisotropic diffusion of higher order...');
-!/usr/local/cuda/bin/nvcc -O0 -c Diffus_4thO_GPU_core.cu -Xcompiler -fPIC -I~/SOFT/MATLAB9/extern/include/
-mex -g -I/usr/local/cuda-10.0/include -L/usr/local/cuda-10.0/lib64 -lcudart -lcufft -lmwgpu Diffusion_4thO_GPU.cpp Diffus_4thO_GPU_core.o
-movefile('Diffusion_4thO_GPU.mex*',Pathmove);
-
-fprintf('%s \n', 'Compiling ROF-LLT...');
-!/usr/local/cuda/bin/nvcc -O0 -c LLT_ROF_GPU_core.cu -Xcompiler -fPIC -I~/SOFT/MATLAB9/extern/include/
-mex -g -I/usr/local/cuda-10.0/include -L/usr/local/cuda-10.0/lib64 -lcudart -lcufft -lmwgpu LLT_ROF_GPU.cpp LLT_ROF_GPU_core.o
-movefile('LLT_ROF_GPU.mex*',Pathmove);
-
-
-delete TV_ROF_GPU_core* TV_FGP_GPU_core* TV_SB_GPU_core* dTV_FGP_GPU_core* NonlDiff_GPU_core* Diffus_4thO_GPU_core* TGV_GPU_core* LLT_ROF_GPU_core* CCPiDefines.h
-fprintf('%s \n', 'All successfully compiled!');
-
-pathA2 = sprintf(['..' fsep '..' fsep], 1i);
-cd(pathA2);
-cd demos \ No newline at end of file
diff --git a/Wrappers/Matlab/mex_compile/installed/MEXed_files_location.txt b/Wrappers/Matlab/mex_compile/installed/MEXed_files_location.txt
deleted file mode 100644
index e69de29..0000000
--- a/Wrappers/Matlab/mex_compile/installed/MEXed_files_location.txt
+++ /dev/null
diff --git a/Wrappers/Matlab/mex_compile/regularisers_CPU/Diffusion_4thO.c b/Wrappers/Matlab/mex_compile/regularisers_CPU/Diffusion_4thO.c
deleted file mode 100644
index 66ea9be..0000000
--- a/Wrappers/Matlab/mex_compile/regularisers_CPU/Diffusion_4thO.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * This work is part of the Core Imaging Library developed by
- * Visual Analytics and Imaging System Group of the Science Technology
- * Facilities Council, STFC
- *
- * Copyright 2017 Daniil Kazantsev
- * Copyright 2017 Srikanth Nagella, Edoardo Pasca
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "matrix.h"
-#include "mex.h"
-#include "Diffus4th_order_core.h"
-
-/* C-OMP implementation of fourth-order diffusion scheme [1] for piecewise-smooth recovery (2D/3D case)
- * The minimisation is performed using explicit scheme.
- *
- * Input Parameters:
- * 1. Noisy image/volume [REQUIRED]
- * 2. lambda - regularization parameter [REQUIRED]
- * 3. Edge-preserving parameter (sigma) [REQUIRED]
- * 4. Number of iterations, for explicit scheme >= 150 is recommended [OPTIONAL, default 300]
- * 5. tau - time-marching step for the explicit scheme [OPTIONAL, default 0.015]
- *
- * Output:
- * [1] Regularized image/volume
- *
- * This function is based on the paper by
- * [1] Hajiaboli, M.R., 2011. An anisotropic fourth-order diffusion filter for image noise removal. International Journal of Computer Vision, 92(2), pp.177-191.
- */
-
-void mexFunction(
- int nlhs, mxArray *plhs[],
- int nrhs, const mxArray *prhs[])
-
-{
- int number_of_dims, iter_numb;
- mwSize dimX, dimY, dimZ;
- const mwSize *dim_array;
- float *Input, *Output=NULL, lambda, tau, sigma;
-
- dim_array = mxGetDimensions(prhs[0]);
- number_of_dims = mxGetNumberOfDimensions(prhs[0]);
-
- /*Handling Matlab input data*/
- Input = (float *) mxGetData(prhs[0]);
- lambda = (float) mxGetScalar(prhs[1]); /* regularization parameter */
- sigma = (float) mxGetScalar(prhs[2]); /* Edge-preserving parameter */
- iter_numb = 300; /* iterations number */
- tau = 0.01; /* marching step parameter */
-
- if (mxGetClassID(prhs[0]) != mxSINGLE_CLASS) {mexErrMsgTxt("The input image must be in a single precision"); }
- if ((nrhs < 3) || (nrhs > 5)) mexErrMsgTxt("At least 3 parameters is required, all parameters are: Image(2D/3D), Regularisation parameter, Edge-preserving parameter, iterations number, time-marching constant");
- if ((nrhs == 4) || (nrhs == 5)) iter_numb = (int) mxGetScalar(prhs[3]); /* iterations number */
- if (nrhs == 5) tau = (float) mxGetScalar(prhs[4]); /* marching step parameter */
-
- /*Handling Matlab output data*/
- dimX = dim_array[0]; dimY = dim_array[1]; dimZ = dim_array[2];
-
- /* output arrays*/
- if (number_of_dims == 2) {
- dimZ = 1; /*2D case*/
- /* output image/volume */
- Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(2, dim_array, mxSINGLE_CLASS, mxREAL));
- }
- if (number_of_dims == 3) Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(3, dim_array, mxSINGLE_CLASS, mxREAL));
-
- Diffus4th_CPU_main(Input, Output, lambda, sigma, iter_numb, tau, dimX, dimY, dimZ);
-} \ No newline at end of file
diff --git a/Wrappers/Matlab/mex_compile/regularisers_CPU/FGP_TV.c b/Wrappers/Matlab/mex_compile/regularisers_CPU/FGP_TV.c
deleted file mode 100644
index 642362f..0000000
--- a/Wrappers/Matlab/mex_compile/regularisers_CPU/FGP_TV.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * This work is part of the Core Imaging Library developed by
- * Visual Analytics and Imaging System Group of the Science Technology
- * Facilities Council, STFC
- *
- * Copyright 2017 Daniil Kazantsev
- * Copyright 2017 Srikanth Nagella, Edoardo Pasca
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "matrix.h"
-#include "mex.h"
-#include "FGP_TV_core.h"
-
-/* C-OMP implementation of FGP-TV [1] denoising/regularization model (2D/3D case)
- *
- * Input Parameters:
- * 1. Noisy image/volume
- * 2. lambdaPar - regularization parameter
- * 3. Number of iterations
- * 4. eplsilon: tolerance constant
- * 5. TV-type: methodTV - 'iso' (0) or 'l1' (1)
- * 6. nonneg: 'nonnegativity (0 is OFF by default)
- * 7. print information: 0 (off) or 1 (on)
- *
- * Output:
- * [1] Filtered/regularized image
- *
- * This function is based on the Matlab's code and paper by
- * [1] Amir Beck and Marc Teboulle, "Fast Gradient-Based Algorithms for Constrained Total Variation Image Denoising and Deblurring Problems"
- */
-
-
-void mexFunction(
- int nlhs, mxArray *plhs[],
- int nrhs, const mxArray *prhs[])
-
-{
- int number_of_dims, iter, methTV, printswitch, nonneg;
- mwSize dimX, dimY, dimZ;
- const mwSize *dim_array;
- float *Input, *Output=NULL, lambda, epsil;
-
- number_of_dims = mxGetNumberOfDimensions(prhs[0]);
- dim_array = mxGetDimensions(prhs[0]);
-
- /*Handling Matlab input data*/
- if ((nrhs < 2) || (nrhs > 7)) mexErrMsgTxt("At least 2 parameters is required, all parameters are: Image(2D/3D), Regularization parameter, Regularization parameter, iterations number, tolerance, penalty type ('iso' or 'l1'), nonnegativity switch, print switch");
-
- Input = (float *) mxGetData(prhs[0]); /*noisy image (2D/3D) */
- lambda = (float) mxGetScalar(prhs[1]); /* regularization parameter */
- iter = 300; /* default iterations number */
- epsil = 0.0001; /* default tolerance constant */
- methTV = 0; /* default isotropic TV penalty */
- nonneg = 0; /* default nonnegativity switch, off - 0 */
- printswitch = 0; /*default print is switched, off - 0 */
-
- if (mxGetClassID(prhs[0]) != mxSINGLE_CLASS) {mexErrMsgTxt("The input image must be in a single precision"); }
-
- if ((nrhs == 3) || (nrhs == 4) || (nrhs == 5) || (nrhs == 6) || (nrhs == 7)) iter = (int) mxGetScalar(prhs[2]); /* iterations number */
- if ((nrhs == 4) || (nrhs == 5) || (nrhs == 6) || (nrhs == 7)) epsil = (float) mxGetScalar(prhs[3]); /* tolerance constant */
- if ((nrhs == 5) || (nrhs == 6) || (nrhs == 7)) {
- char *penalty_type;
- penalty_type = mxArrayToString(prhs[4]); /* choosing TV penalty: 'iso' or 'l1', 'iso' is the default */
- if ((strcmp(penalty_type, "l1") != 0) && (strcmp(penalty_type, "iso") != 0)) mexErrMsgTxt("Choose TV type: 'iso' or 'l1',");
- if (strcmp(penalty_type, "l1") == 0) methTV = 1; /* enable 'l1' penalty */
- mxFree(penalty_type);
- }
- if ((nrhs == 6) || (nrhs == 7)) {
- nonneg = (int) mxGetScalar(prhs[5]);
- if ((nonneg != 0) && (nonneg != 1)) mexErrMsgTxt("Nonnegativity constraint can be enabled by choosing 1 or off - 0");
- }
- if (nrhs == 7) {
- printswitch = (int) mxGetScalar(prhs[6]);
- if ((printswitch != 0) && (printswitch != 1)) mexErrMsgTxt("Print can be enabled by choosing 1 or off - 0");
- }
-
- /*Handling Matlab output data*/
- dimX = dim_array[0]; dimY = dim_array[1]; dimZ = dim_array[2];
-
- if (number_of_dims == 2) {
- dimZ = 1; /*2D case*/
- Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(2, dim_array, mxSINGLE_CLASS, mxREAL));
- }
- if (number_of_dims == 3) Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(3, dim_array, mxSINGLE_CLASS, mxREAL));
-
- /* running the function */
- TV_FGP_CPU_main(Input, Output, lambda, iter, epsil, methTV, nonneg, printswitch, dimX, dimY, dimZ);
-} \ No newline at end of file
diff --git a/Wrappers/Matlab/mex_compile/regularisers_CPU/FGP_dTV.c b/Wrappers/Matlab/mex_compile/regularisers_CPU/FGP_dTV.c
deleted file mode 100644
index 1a0c070..0000000
--- a/Wrappers/Matlab/mex_compile/regularisers_CPU/FGP_dTV.c
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * This work is part of the Core Imaging Library developed by
- * Visual Analytics and Imaging System Group of the Science Technology
- * Facilities Council, STFC
- *
- * Copyright 2017 Daniil Kazantsev
- * Copyright 2017 Srikanth Nagella, Edoardo Pasca
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "matrix.h"
-#include "mex.h"
-#include "FGP_dTV_core.h"
-
-/* C-OMP implementation of FGP-dTV [1,2] denoising/regularization model (2D/3D case)
- * which employs structural similarity of the level sets of two images/volumes, see [1,2]
- * The current implementation updates image 1 while image 2 is being fixed.
- *
- * Input Parameters:
- * 1. Noisy image/volume [REQUIRED]
- * 2. Additional reference image/volume of the same dimensions as (1) [REQUIRED]
- * 3. lambdaPar - regularization parameter [REQUIRED]
- * 4. Number of iterations [OPTIONAL]
- * 5. eplsilon: tolerance constant [OPTIONAL]
- * 6. eta: smoothing constant to calculate gradient of the reference [OPTIONAL] *
- * 7. TV-type: methodTV - 'iso' (0) or 'l1' (1) [OPTIONAL]
- * 8. nonneg: 'nonnegativity (0 is OFF by default) [OPTIONAL]
- * 9. print information: 0 (off) or 1 (on) [OPTIONAL]
- *
- * Output:
- * [1] Filtered/regularized image/volume
- *
- * This function is based on the Matlab's codes and papers by
- * [1] Amir Beck and Marc Teboulle, "Fast Gradient-Based Algorithms for Constrained Total Variation Image Denoising and Deblurring Problems"
- * [2] M. J. Ehrhardt and M. M. Betcke, Multi-Contrast MRI Reconstruction with Structure-Guided Total Variation, SIAM Journal on Imaging Sciences 9(3), pp. 1084–1106
- */
-
-
-void mexFunction(
- int nlhs, mxArray *plhs[],
- int nrhs, const mxArray *prhs[])
-
-{
- int number_of_dims, iter, methTV, printswitch, nonneg;
- mwSize dimX, dimY, dimZ;
- const mwSize *dim_array;
- const mwSize *dim_array2;
- float *Input, *InputRef, *Output=NULL, lambda, epsil, eta;
-
- number_of_dims = mxGetNumberOfDimensions(prhs[0]);
- dim_array = mxGetDimensions(prhs[0]);
- dim_array2 = mxGetDimensions(prhs[1]);
-
- /*Handling Matlab input data*/
- if ((nrhs < 3) || (nrhs > 9)) mexErrMsgTxt("At least 3 parameters is required, all parameters are: Image(2D/3D), Reference(2D/3D), Regularization parameter, iterations number, tolerance, smoothing constant, penalty type ('iso' or 'l1'), nonnegativity switch, print switch");
-
- Input = (float *) mxGetData(prhs[0]); /*noisy image (2D/3D) */
- InputRef = (float *) mxGetData(prhs[1]); /* reference image (2D/3D) */
- lambda = (float) mxGetScalar(prhs[2]); /* regularization parameter */
- iter = 300; /* default iterations number */
- epsil = 0.0001; /* default tolerance constant */
- eta = 0.01; /* default smoothing constant */
- methTV = 0; /* default isotropic TV penalty */
- nonneg = 0; /* default nonnegativity switch, off - 0 */
- printswitch = 0; /*default print is switched, off - 0 */
-
-
- if (mxGetClassID(prhs[0]) != mxSINGLE_CLASS) {mexErrMsgTxt("The input image must be in a single precision"); }
- if (mxGetClassID(prhs[1]) != mxSINGLE_CLASS) {mexErrMsgTxt("The input image must be in a single precision"); }
-
- /*Handling Matlab output data*/
- dimX = dim_array[0]; dimY = dim_array[1]; dimZ = dim_array[2];
- if (number_of_dims == 2) { if ((dimX != dim_array2[0]) || (dimY != dim_array2[1])) mexErrMsgTxt("The input images have different dimensionalities");}
- if (number_of_dims == 3) { if ((dimX != dim_array2[0]) || (dimY != dim_array2[1]) || (dimZ != dim_array2[2])) mexErrMsgTxt("The input volumes have different dimensionalities");}
-
-
- if ((nrhs == 4) || (nrhs == 5) || (nrhs == 6) || (nrhs == 7) || (nrhs == 8) || (nrhs == 9)) iter = (int) mxGetScalar(prhs[3]); /* iterations number */
- if ((nrhs == 5) || (nrhs == 6) || (nrhs == 7) || (nrhs == 8) || (nrhs == 9)) epsil = (float) mxGetScalar(prhs[4]); /* tolerance constant */
- if ((nrhs == 6) || (nrhs == 7) || (nrhs == 8) || (nrhs == 9)) {
- eta = (float) mxGetScalar(prhs[5]); /* smoothing constant for the gradient of InputRef */
- }
- if ((nrhs == 7) || (nrhs == 8) || (nrhs == 9)) {
- char *penalty_type;
- penalty_type = mxArrayToString(prhs[6]); /* choosing TV penalty: 'iso' or 'l1', 'iso' is the default */
- if ((strcmp(penalty_type, "l1") != 0) && (strcmp(penalty_type, "iso") != 0)) mexErrMsgTxt("Choose TV type: 'iso' or 'l1',");
- if (strcmp(penalty_type, "l1") == 0) methTV = 1; /* enable 'l1' penalty */
- mxFree(penalty_type);
- }
- if ((nrhs == 8) || (nrhs == 9)) {
- nonneg = (int) mxGetScalar(prhs[7]);
- if ((nonneg != 0) && (nonneg != 1)) mexErrMsgTxt("Nonnegativity constraint can be enabled by choosing 1 or off - 0");
- }
- if (nrhs == 9) {
- printswitch = (int) mxGetScalar(prhs[8]);
- if ((printswitch != 0) && (printswitch != 1)) mexErrMsgTxt("Print can be enabled by choosing 1 or off - 0");
- }
-
- if (number_of_dims == 2) {
- dimZ = 1; /*2D case*/
- Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(2, dim_array, mxSINGLE_CLASS, mxREAL));
- }
- if (number_of_dims == 3) Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(3, dim_array, mxSINGLE_CLASS, mxREAL));
-
- /* running the function */
- dTV_FGP_CPU_main(Input, InputRef, Output, lambda, iter, epsil, eta, methTV, nonneg, printswitch, dimX, dimY, dimZ);
-} \ No newline at end of file
diff --git a/Wrappers/Matlab/mex_compile/regularisers_CPU/LLT_ROF.c b/Wrappers/Matlab/mex_compile/regularisers_CPU/LLT_ROF.c
deleted file mode 100644
index ab45446..0000000
--- a/Wrappers/Matlab/mex_compile/regularisers_CPU/LLT_ROF.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * This work is part of the Core Imaging Library developed by
- * Visual Analytics and Imaging System Group of the Science Technology
- * Facilities Council, STFC
- *
- * Copyright 2017 Daniil Kazantsev
- * Copyright 2017 Srikanth Nagella, Edoardo Pasca
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "matrix.h"
-#include "mex.h"
-#include "LLT_ROF_core.h"
-
-/* C-OMP implementation of Lysaker, Lundervold and Tai (LLT) model [1] combined with Rudin-Osher-Fatemi [2] TV regularisation penalty.
-*
-* This penalty can deliver visually pleasant piecewise-smooth recovery if regularisation parameters are selected well.
-* The rule of thumb for selection is to start with lambdaLLT = 0 (just the ROF-TV model) and then proceed to increase
-* lambdaLLT starting with smaller values.
-*
-* Input Parameters:
-* 1. U0 - original noise image/volume
-* 2. lambdaROF - ROF-related regularisation parameter
-* 3. lambdaLLT - LLT-related regularisation parameter
-* 4. tau - time-marching step
-* 5. iter - iterations number (for both models)
-*
-* Output:
-* Filtered/regularised image
-*
-* References:
-* [1] Lysaker, M., Lundervold, A. and Tai, X.C., 2003. Noise removal using fourth-order partial differential equation with applications to medical magnetic resonance images in space and time. IEEE Transactions on image processing, 12(12), pp.1579-1590.
-* [2] Rudin, Osher, Fatemi, "Nonlinear Total Variation based noise removal algorithms"
-*/
-
-void mexFunction(
- int nlhs, mxArray *plhs[],
- int nrhs, const mxArray *prhs[])
-
-{
- int number_of_dims, iterationsNumb;
- mwSize dimX, dimY, dimZ;
- const mwSize *dim_array;
- float *Input, *Output=NULL, lambdaROF, lambdaLLT, tau;
-
- dim_array = mxGetDimensions(prhs[0]);
- number_of_dims = mxGetNumberOfDimensions(prhs[0]);
-
- if ((nrhs < 3) || (nrhs > 5)) mexErrMsgTxt("At least 3 parameters is required, all parameters are: Image(2D/3D), Regularisation parameter (ROF), Regularisation parameter (LTT), iterations number, time-marching parameter");
-
- /*Handling Matlab input data*/
- Input = (float *) mxGetData(prhs[0]);
- lambdaROF = (float) mxGetScalar(prhs[1]); /* ROF regularization parameter */
- lambdaLLT = (float) mxGetScalar(prhs[2]); /* ROF regularization parameter */
- iterationsNumb = 250;
- tau = 0.0025;
-
- if (mxGetClassID(prhs[0]) != mxSINGLE_CLASS) {mexErrMsgTxt("The input image must be in a single precision"); }
- if ((nrhs == 4) || (nrhs == 5)) iterationsNumb = (int) mxGetScalar(prhs[3]); /* iterations number */
- if (nrhs == 5) tau = (float) mxGetScalar(prhs[4]); /* marching step parameter */
-
- /*Handling Matlab output data*/
- dimX = dim_array[0]; dimY = dim_array[1]; dimZ = dim_array[2];
-
- /* output arrays*/
- if (number_of_dims == 2) {
- dimZ = 1; /*2D case*/
- /* output image/volume */
- Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(2, dim_array, mxSINGLE_CLASS, mxREAL));
- }
- if (number_of_dims == 3) Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(3, dim_array, mxSINGLE_CLASS, mxREAL));
-
- LLT_ROF_CPU_main(Input, Output, lambdaROF, lambdaLLT, iterationsNumb, tau, dimX, dimY, dimZ);
-} \ No newline at end of file
diff --git a/Wrappers/Matlab/mex_compile/regularisers_CPU/NonlDiff.c b/Wrappers/Matlab/mex_compile/regularisers_CPU/NonlDiff.c
deleted file mode 100644
index ec35b8b..0000000
--- a/Wrappers/Matlab/mex_compile/regularisers_CPU/NonlDiff.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * This work is part of the Core Imaging Library developed by
- * Visual Analytics and Imaging System Group of the Science Technology
- * Facilities Council, STFC
- *
- * Copyright 2017 Daniil Kazantsev
- * Copyright 2017 Srikanth Nagella, Edoardo Pasca
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "matrix.h"
-#include "mex.h"
-#include "Diffusion_core.h"
-
-/* C-OMP implementation of linear and nonlinear diffusion with the regularisation model [1] (2D/3D case)
- * The minimisation is performed using explicit scheme.
- *
- * Input Parameters:
- * 1. Noisy image/volume
- * 2. lambda - regularization parameter
- * 3. Edge-preserving parameter (sigma), when sigma equals to zero nonlinear diffusion -> linear diffusion
- * 4. Number of iterations, for explicit scheme >= 150 is recommended [OPTIONAL parameter]
- * 5. tau - time-marching step for explicit scheme [OPTIONAL parameter]
- * 6. Penalty type: 1 - Huber, 2 - Perona-Malik, 3 - Tukey Biweight [OPTIONAL parameter]
- *
- * Output:
- * [1] Regularized image/volume
- *
- * This function is based on the paper by
- * [1] Perona, P. and Malik, J., 1990. Scale-space and edge detection using anisotropic diffusion. IEEE Transactions on pattern analysis and machine intelligence, 12(7), pp.629-639.
- */
-
-void mexFunction(
- int nlhs, mxArray *plhs[],
- int nrhs, const mxArray *prhs[])
-
-{
- int number_of_dims, iter_numb, penaltytype;
- mwSize dimX, dimY, dimZ;
- const mwSize *dim_array;
-
- float *Input, *Output=NULL, lambda, tau, sigma;
-
- dim_array = mxGetDimensions(prhs[0]);
- number_of_dims = mxGetNumberOfDimensions(prhs[0]);
-
- /*Handling Matlab input data*/
- Input = (float *) mxGetData(prhs[0]);
- lambda = (float) mxGetScalar(prhs[1]); /* regularization parameter */
- sigma = (float) mxGetScalar(prhs[2]); /* Edge-preserving parameter */
- iter_numb = 300; /* iterations number */
- tau = 0.025; /* marching step parameter */
- penaltytype = 1; /* Huber penalty by default */
-
- if (mxGetClassID(prhs[0]) != mxSINGLE_CLASS) {mexErrMsgTxt("The input image must be in a single precision"); }
- if ((nrhs < 3) || (nrhs > 6)) mexErrMsgTxt("At least 3 parameters is required, all parameters are: Image(2D/3D), Regularisation parameter, Edge-preserving parameter, iterations number, time-marching constant, penalty type - Huber, PM or Tukey");
- if ((nrhs == 4) || (nrhs == 5) || (nrhs == 6)) iter_numb = (int) mxGetScalar(prhs[3]); /* iterations number */
- if ((nrhs == 5) || (nrhs == 6)) tau = (float) mxGetScalar(prhs[4]); /* marching step parameter */
- if (nrhs == 6) {
- char *penalty_type;
- penalty_type = mxArrayToString(prhs[5]); /* Huber, PM or Tukey 'Huber' is the default */
- if ((strcmp(penalty_type, "Huber") != 0) && (strcmp(penalty_type, "PM") != 0) && (strcmp(penalty_type, "Tukey") != 0)) mexErrMsgTxt("Choose penalty: 'Huber', 'PM' or 'Tukey',");
- if (strcmp(penalty_type, "Huber") == 0) penaltytype = 1; /* enable 'Huber' penalty */
- if (strcmp(penalty_type, "PM") == 0) penaltytype = 2; /* enable Perona-Malik penalty */
- if (strcmp(penalty_type, "Tukey") == 0) penaltytype = 3; /* enable Tikey Biweight penalty */
- mxFree(penalty_type);
- }
-
- /*Handling Matlab output data*/
- dimX = dim_array[0]; dimY = dim_array[1]; dimZ = dim_array[2];
-
- /* output arrays*/
- if (number_of_dims == 2) {
- dimZ = 1; /*2D case*/
- /* output image/volume */
- Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(2, dim_array, mxSINGLE_CLASS, mxREAL));
- }
- if (number_of_dims == 3) Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(3, dim_array, mxSINGLE_CLASS, mxREAL));
-
- Diffusion_CPU_main(Input, Output, lambda, sigma, iter_numb, tau, penaltytype, dimX, dimY, dimZ);
-} \ No newline at end of file
diff --git a/Wrappers/Matlab/mex_compile/regularisers_CPU/NonlDiff_Inp.c b/Wrappers/Matlab/mex_compile/regularisers_CPU/NonlDiff_Inp.c
deleted file mode 100644
index 9833392..0000000
--- a/Wrappers/Matlab/mex_compile/regularisers_CPU/NonlDiff_Inp.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * This work is part of the Core Imaging Library developed by
- * Visual Analytics and Imaging System Group of the Science Technology
- * Facilities Council, STFC
- *
- * Copyright 2017 Daniil Kazantsev
- * Copyright 2017 Srikanth Nagella, Edoardo Pasca
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "matrix.h"
-#include "mex.h"
-#include "Diffusion_Inpaint_core.h"
-
-/* C-OMP implementation of linear and nonlinear diffusion [1,2] for inpainting task (2D/3D case)
- * The minimisation is performed using explicit scheme.
- *
- * Input Parameters:
- * 1. Image/volume to inpaint
- * 2. Inpainting Mask of the same size as (1) in 'unsigned char' format (ones mark the region to inpaint, zeros belong to the data)
- * 3. lambda - regularization parameter
- * 4. Edge-preserving parameter (sigma), when sigma equals to zero nonlinear diffusion -> linear diffusion
- * 5. Number of iterations, for explicit scheme >= 150 is recommended
- * 6. tau - time-marching step for explicit scheme
- * 7. Penalty type: 1 - Huber, 2 - Perona-Malik, 3 - Tukey Biweight
- *
- * Output:
- * [1] Inpainted image/volume
- *
- * This function is based on the paper by
- * [1] Perona, P. and Malik, J., 1990. Scale-space and edge detection using anisotropic diffusion. IEEE Transactions on pattern analysis and machine intelligence, 12(7), pp.629-639.
- * [2] Black, M.J., Sapiro, G., Marimont, D.H. and Heeger, D., 1998. Robust anisotropic diffusion. IEEE Transactions on image processing, 7(3), pp.421-432.
- */
-
-void mexFunction(
- int nlhs, mxArray *plhs[],
- int nrhs, const mxArray *prhs[])
-
-{
- int number_of_dims, iter_numb, penaltytype, i, inpaint_elements;
- mwSize dimX, dimY, dimZ;
- const mwSize *dim_array;
- const mwSize *dim_array2;
-
- float *Input, *Output=NULL, lambda, tau, sigma;
- unsigned char *Mask;
-
- dim_array = mxGetDimensions(prhs[0]);
- dim_array2 = mxGetDimensions(prhs[1]);
- number_of_dims = mxGetNumberOfDimensions(prhs[0]);
-
- /*Handling Matlab input data*/
- Input = (float *) mxGetData(prhs[0]);
- Mask = (unsigned char *) mxGetData(prhs[1]); /* MASK */
- lambda = (float) mxGetScalar(prhs[2]); /* regularization parameter */
- sigma = (float) mxGetScalar(prhs[3]); /* Edge-preserving parameter */
- iter_numb = 300; /* iterations number */
- tau = 0.025; /* marching step parameter */
- penaltytype = 1; /* Huber penalty by default */
-
- if ((nrhs < 4) || (nrhs > 7)) mexErrMsgTxt("At least 4 parameters is required, all parameters are: Image(2D/3D), Mask(2D/3D), Regularisation parameter, Edge-preserving parameter, iterations number, time-marching constant, penalty type - Huber, PM or Tukey");
- if ((nrhs == 5) || (nrhs == 6) || (nrhs == 7)) iter_numb = (int) mxGetScalar(prhs[4]); /* iterations number */
- if ((nrhs == 6) || (nrhs == 7)) tau = (float) mxGetScalar(prhs[5]); /* marching step parameter */
- if (nrhs == 7) {
- char *penalty_type;
- penalty_type = mxArrayToString(prhs[6]); /* Huber, PM or Tukey 'Huber' is the default */
- if ((strcmp(penalty_type, "Huber") != 0) && (strcmp(penalty_type, "PM") != 0) && (strcmp(penalty_type, "Tukey") != 0)) mexErrMsgTxt("Choose penalty: 'Huber', 'PM' or 'Tukey',");
- if (strcmp(penalty_type, "Huber") == 0) penaltytype = 1; /* enable 'Huber' penalty */
- if (strcmp(penalty_type, "PM") == 0) penaltytype = 2; /* enable Perona-Malik penalty */
- if (strcmp(penalty_type, "Tukey") == 0) penaltytype = 3; /* enable Tikey Biweight penalty */
- mxFree(penalty_type);
- }
-
- if (mxGetClassID(prhs[0]) != mxSINGLE_CLASS) {mexErrMsgTxt("The input image must be in a single precision"); }
- if (mxGetClassID(prhs[1]) != mxUINT8_CLASS) {mexErrMsgTxt("The mask must be in uint8 precision");}
-
- dimX = dim_array[0]; dimY = dim_array[1]; dimZ = dim_array[2];
-
- /* output arrays*/
- if (number_of_dims == 2) {
- dimZ = 1; /*2D case*/
- /* output image/volume */
- if ((dimX != dim_array2[0]) || (dimY != dim_array2[1])) mexErrMsgTxt("Input image and the provided mask are of different dimensions!");
- Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(2, dim_array, mxSINGLE_CLASS, mxREAL));
- }
- if (number_of_dims == 3) {
- if ((dimX != dim_array2[0]) || (dimY != dim_array2[1]) || (dimZ != dim_array2[2])) mexErrMsgTxt("Input image and the provided mask are of different dimensions!");
- Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(3, dim_array, mxSINGLE_CLASS, mxREAL));
- }
-
- inpaint_elements = 0;
- for (i=0; i<(int)(dimY*dimX*dimZ); i++) if (Mask[i] == 1) inpaint_elements++;
- if (inpaint_elements == 0) mexErrMsgTxt("The mask is full of zeros, nothing to inpaint");
- Diffusion_Inpaint_CPU_main(Input, Mask, Output, lambda, sigma, iter_numb, tau, penaltytype, dimX, dimY, dimZ);
-} \ No newline at end of file
diff --git a/Wrappers/Matlab/mex_compile/regularisers_CPU/NonlocalMarching_Inpaint.c b/Wrappers/Matlab/mex_compile/regularisers_CPU/NonlocalMarching_Inpaint.c
deleted file mode 100644
index b3f2c98..0000000
--- a/Wrappers/Matlab/mex_compile/regularisers_CPU/NonlocalMarching_Inpaint.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * This work is part of the Core Imaging Library developed by
- * Visual Analytics and Imaging System Group of the Science Technology
- * Facilities Council, STFC
- *
- * Copyright 2017 Daniil Kazantsev
- * Copyright 2017 Srikanth Nagella, Edoardo Pasca
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "matrix.h"
-#include "mex.h"
-#include "NonlocalMarching_Inpaint_core.h"
-
-/* C-OMP implementation of Nonlocal Vertical Marching inpainting method (2D case)
- * The method is heuristic but computationally efficent (especially for larger images).
- * It developed specifically to smoothly inpaint horizontal or inclined missing data regions in sinograms
- * The method WILL not work satisfactory if you have lengthy vertical stripes of missing data
- *
- * Input:
- * 1. 2D image or sinogram [REQUIRED]
- * 2. Mask of the same size as A in 'unsigned char' format (ones mark the region to inpaint, zeros belong to the data) [REQUIRED]
- * 3. Linear increment to increase searching window size in iterations, values from 1-3 is a good choice [OPTIONAL, default 1]
- * 4. Number of iterations [OPTIONAL, default - calculate based on the mask]
- *
- * Output:
- * 1. Inpainted sinogram
- * 2. updated mask
- * Reference: TBA
- */
-
-void mexFunction(
- int nlhs, mxArray *plhs[],
- int nrhs, const mxArray *prhs[])
-
-{
- int number_of_dims, iterations, SW_increment;
- mwSize dimX, dimY, dimZ;
- const mwSize *dim_array;
- const mwSize *dim_array2;
-
- float *Input, *Output=NULL;
- unsigned char *Mask, *Mask_upd=NULL;
-
- dim_array = mxGetDimensions(prhs[0]);
- dim_array2 = mxGetDimensions(prhs[1]);
- number_of_dims = mxGetNumberOfDimensions(prhs[0]);
-
- /*Handling Matlab input data*/
- Input = (float *) mxGetData(prhs[0]);
- Mask = (unsigned char *) mxGetData(prhs[1]); /* MASK */
- SW_increment = 1;
- iterations = 0;
-
- if ((nrhs < 2) || (nrhs > 4)) mexErrMsgTxt("At least 4 parameters is required, all parameters are: Image(2D/3D), Mask(2D/3D), Linear increment, Iterations number");
- if ((nrhs == 3) || (nrhs == 4)) SW_increment = (int) mxGetScalar(prhs[2]); /* linear increment */
- if ((nrhs == 4)) iterations = (int) mxGetScalar(prhs[3]); /* iterations number */
-
- if (mxGetClassID(prhs[0]) != mxSINGLE_CLASS) {mexErrMsgTxt("The input image must be in a single precision"); }
- if (mxGetClassID(prhs[1]) != mxUINT8_CLASS) {mexErrMsgTxt("The mask must be in uint8 precision");}
-
- dimX = dim_array[0]; dimY = dim_array[1]; dimZ = dim_array[2];
-
- /* output arrays*/
- if (number_of_dims == 2) {
- dimZ = 1; /*2D case*/
- /* output image/volume */
- if ((dimX != dim_array2[0]) || (dimY != dim_array2[1])) mexErrMsgTxt("Input image and the provided mask are of different dimensions!");
- Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(2, dim_array, mxSINGLE_CLASS, mxREAL));
- Mask_upd = (unsigned char*)mxGetPr(plhs[1] = mxCreateNumericArray(2, dim_array, mxUINT8_CLASS, mxREAL));
- }
- if (number_of_dims == 3) {
- mexErrMsgTxt("Currently 2D supported only");
- }
- NonlocalMarching_Inpaint_main(Input, Mask, Output, Mask_upd, SW_increment, iterations, 0, dimX, dimY, dimZ);
-} \ No newline at end of file
diff --git a/Wrappers/Matlab/mex_compile/regularisers_CPU/Nonlocal_TV.c b/Wrappers/Matlab/mex_compile/regularisers_CPU/Nonlocal_TV.c
deleted file mode 100644
index 014c0a0..0000000
--- a/Wrappers/Matlab/mex_compile/regularisers_CPU/Nonlocal_TV.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * This work is part of the Core Imaging Library developed by
- * Visual Analytics and Imaging System Group of the Science Technology
- * Facilities Council, STFC and Diamond Light Source Ltd.
- *
- * Copyright 2017 Daniil Kazantsev
- * Copyright 2017 Srikanth Nagella, Edoardo Pasca
- * Copyright 2018 Diamond Light Source Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "matrix.h"
-#include "mex.h"
-#include "Nonlocal_TV_core.h"
-
-#define EPS 1.0000e-9
-
-/* Matlab wrapper for C-OMP implementation of non-local regulariser
- * Weights and associated indices must be given as an input.
- * Gauss-Seidel fixed point iteration requires ~ 3 iterations, so the main effort
- * goes in pre-calculation of weights and selection of patches
- *
- *
- * Input Parameters:
- * 1. 2D/3D grayscale image/volume
- * 2. AR_i - indeces of i neighbours
- * 3. AR_j - indeces of j neighbours
- * 4. AR_k - indeces of k neighbours (0 - for 2D case)
- * 5. Weights_ij(k) - associated weights
- * 6. regularisation parameter
- * 7. iterations number
-
- * Output:
- * 1. denoised image/volume
- * Elmoataz, Abderrahim, Olivier Lezoray, and Sébastien Bougleux. "Nonlocal discrete regularization on weighted graphs: a framework for image and manifold processing." IEEE Trans. Image Processing 17, no. 7 (2008): 1047-1060.
- */
-
-void mexFunction(
- int nlhs, mxArray *plhs[],
- int nrhs, const mxArray *prhs[])
-{
- long number_of_dims, dimX, dimY, dimZ;
- int IterNumb, NumNeighb = 0;
- unsigned short *H_i, *H_j, *H_k;
- const int *dim_array;
- const int *dim_array2;
- float *A_orig, *Output=NULL, *Weights, lambda;
-
- dim_array = mxGetDimensions(prhs[0]);
- dim_array2 = mxGetDimensions(prhs[1]);
- number_of_dims = mxGetNumberOfDimensions(prhs[0]);
-
- /*Handling Matlab input data*/
- A_orig = (float *) mxGetData(prhs[0]); /* a 2D image or a set of 2D images (3D stack) */
- H_i = (unsigned short *) mxGetData(prhs[1]); /* indeces of i neighbours */
- H_j = (unsigned short *) mxGetData(prhs[2]); /* indeces of j neighbours */
- H_k = (unsigned short *) mxGetData(prhs[3]); /* indeces of k neighbours */
- Weights = (float *) mxGetData(prhs[4]); /* weights for patches */
- lambda = (float) mxGetScalar(prhs[5]); /* regularisation parameter */
- IterNumb = (int) mxGetScalar(prhs[6]); /* the number of iterations */
-
- dimX = dim_array[0]; dimY = dim_array[1]; dimZ = dim_array[2];
-
- /*****2D INPUT *****/
- if (number_of_dims == 2) {
- dimZ = 0;
- NumNeighb = dim_array2[2];
- Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(2, dim_array, mxSINGLE_CLASS, mxREAL));
- }
- /*****3D INPUT *****/
- /****************************************************/
- if (number_of_dims == 3) {
- NumNeighb = dim_array2[3];
- Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(3, dim_array, mxSINGLE_CLASS, mxREAL));
- }
-
- /* run the main function here */
- Nonlocal_TV_CPU_main(A_orig, Output, H_i, H_j, H_k, Weights, dimX, dimY, dimZ, NumNeighb, lambda, IterNumb);
-}
diff --git a/Wrappers/Matlab/mex_compile/regularisers_CPU/PatchSelect.c b/Wrappers/Matlab/mex_compile/regularisers_CPU/PatchSelect.c
deleted file mode 100644
index f942539..0000000
--- a/Wrappers/Matlab/mex_compile/regularisers_CPU/PatchSelect.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * This work is part of the Core Imaging Library developed by
- * Visual Analytics and Imaging System Group of the Science Technology
- * Facilities Council, STFC and Diamond Light Source Ltd.
- *
- * Copyright 2017 Daniil Kazantsev
- * Copyright 2017 Srikanth Nagella, Edoardo Pasca
- * Copyright 2018 Diamond Light Source Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "matrix.h"
-#include "mex.h"
-#include "PatchSelect_core.h"
-
-/* C-OMP implementation of non-local weight pre-calculation for non-local priors
- * Weights and associated indices are stored into pre-allocated arrays and passed
- * to the regulariser
- *
- *
- * Input Parameters:
- * 1. 2D/3D grayscale image/volume
- * 2. Searching window (half-size of the main bigger searching window, e.g. 11)
- * 3. Similarity window (half-size of the patch window, e.g. 2)
- * 4. The number of neighbours to take (the most prominent after sorting neighbours will be taken)
- * 5. noise-related parameter to calculate non-local weights
- *
- * Output [2D]:
- * 1. AR_i - indeces of i neighbours
- * 2. AR_j - indeces of j neighbours
- * 3. Weights_ij - associated weights
- *
- * Output [3D]:
- * 1. AR_i - indeces of i neighbours
- * 2. AR_j - indeces of j neighbours
- * 3. AR_k - indeces of j neighbours
- * 4. Weights_ijk - associated weights
- */
-/**************************************************/
-void mexFunction(
- int nlhs, mxArray *plhs[],
- int nrhs, const mxArray *prhs[])
-{
- int number_of_dims, SearchWindow, SimilarWin, NumNeighb;
- mwSize dimX, dimY, dimZ;
- unsigned short *H_i=NULL, *H_j=NULL, *H_k=NULL;
- const int *dim_array;
- float *A, *Weights = NULL, h;
- int dim_array2[3]; /* for 2D data */
- int dim_array3[4]; /* for 3D data */
-
- dim_array = mxGetDimensions(prhs[0]);
- number_of_dims = mxGetNumberOfDimensions(prhs[0]);
-
- /*Handling Matlab input data*/
- A = (float *) mxGetData(prhs[0]); /* a 2D or 3D image/volume */
- SearchWindow = (int) mxGetScalar(prhs[1]); /* Large Searching window */
- SimilarWin = (int) mxGetScalar(prhs[2]); /* Similarity window (patch-search)*/
- NumNeighb = (int) mxGetScalar(prhs[3]); /* the total number of neighbours to take */
- h = (float) mxGetScalar(prhs[4]); /* NLM parameter */
-
- dimX = dim_array[0]; dimY = dim_array[1]; dimZ = dim_array[2];
- dim_array2[0] = dimX; dim_array2[1] = dimY; dim_array2[2] = NumNeighb; /* 2D case */
- dim_array3[0] = dimX; dim_array3[1] = dimY; dim_array3[2] = dimZ; dim_array3[3] = NumNeighb; /* 3D case */
-
- /****************2D INPUT ***************/
- if (number_of_dims == 2) {
- dimZ = 0;
- H_i = (unsigned short*)mxGetPr(plhs[0] = mxCreateNumericArray(3, dim_array2, mxUINT16_CLASS, mxREAL));
- H_j = (unsigned short*)mxGetPr(plhs[1] = mxCreateNumericArray(3, dim_array2, mxUINT16_CLASS, mxREAL));
- Weights = (float*)mxGetPr(plhs[2] = mxCreateNumericArray(3, dim_array2, mxSINGLE_CLASS, mxREAL));
- }
- /****************3D INPUT ***************/
- if (number_of_dims == 3) {
- H_i = (unsigned short*)mxGetPr(plhs[0] = mxCreateNumericArray(4, dim_array3, mxUINT16_CLASS, mxREAL));
- H_j = (unsigned short*)mxGetPr(plhs[1] = mxCreateNumericArray(4, dim_array3, mxUINT16_CLASS, mxREAL));
- H_k = (unsigned short*)mxGetPr(plhs[2] = mxCreateNumericArray(4, dim_array3, mxUINT16_CLASS, mxREAL));
- Weights = (float*)mxGetPr(plhs[3] = mxCreateNumericArray(4, dim_array3, mxSINGLE_CLASS, mxREAL));
- }
-
- PatchSelect_CPU_main(A, H_i, H_j, H_k, Weights, (long)(dimX), (long)(dimY), (long)(dimZ), SearchWindow, SimilarWin, NumNeighb, h, 0);
-
- }
diff --git a/Wrappers/Matlab/mex_compile/regularisers_CPU/ROF_TV.c b/Wrappers/Matlab/mex_compile/regularisers_CPU/ROF_TV.c
deleted file mode 100644
index 55ef2b1..0000000
--- a/Wrappers/Matlab/mex_compile/regularisers_CPU/ROF_TV.c
+++ /dev/null
@@ -1,77 +0,0 @@
-
-/*
- * This work is part of the Core Imaging Library developed by
- * Visual Analytics and Imaging System Group of the Science Technology
- * Facilities Council, STFC
- *
- * Copyright 2017 Daniil Kazantsev
- * Copyright 2017 Srikanth Nagella, Edoardo Pasca
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "matrix.h"
-#include "mex.h"
-#include "ROF_TV_core.h"
-
-/* ROF-TV denoising/regularization model [1] (2D/3D case)
- * (MEX wrapper for MATLAB)
- *
- * Input Parameters:
- * 1. Noisy image/volume [REQUIRED]
- * 2. lambda - regularization parameter [REQUIRED]
- * 3. Number of iterations, for explicit scheme >= 150 is recommended [REQUIRED]
- * 4. tau - marching step for explicit scheme, ~1 is recommended [REQUIRED]
- *
- * Output:
- * [1] Regularized image/volume
- *
- * This function is based on the paper by
- * [1] Rudin, Osher, Fatemi, "Nonlinear Total Variation based noise removal algorithms"
- *
- * D. Kazantsev, 2016-18
- */
-
-void mexFunction(
- int nlhs, mxArray *plhs[],
- int nrhs, const mxArray *prhs[])
-
-{
- int number_of_dims, iter_numb;
- mwSize dimX, dimY, dimZ;
- const mwSize *dim_array_i;
- float *Input, *Output=NULL, lambda, tau;
-
- dim_array_i = mxGetDimensions(prhs[0]);
- number_of_dims = mxGetNumberOfDimensions(prhs[0]);
-
- /*Handling Matlab input data*/
- Input = (float *) mxGetData(prhs[0]);
- lambda = (float) mxGetScalar(prhs[1]); /* regularization parameter */
- iter_numb = (int) mxGetScalar(prhs[2]); /* iterations number */
- tau = (float) mxGetScalar(prhs[3]); /* marching step parameter */
-
- if (mxGetClassID(prhs[0]) != mxSINGLE_CLASS) {mexErrMsgTxt("The input image must be in a single precision"); }
- if(nrhs != 4) mexErrMsgTxt("Four inputs reqired: Image(2D,3D), regularization parameter, iterations number, marching step constant");
- /*Handling Matlab output data*/
- dimX = dim_array_i[0]; dimY = dim_array_i[1]; dimZ = dim_array_i[2];
-
- /* output arrays*/
- if (number_of_dims == 2) {
- dimZ = 1; /*2D case*/
- /* output image/volume */
- Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(2, dim_array_i, mxSINGLE_CLASS, mxREAL));
- }
- if (number_of_dims == 3) {
- Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(3, dim_array_i, mxSINGLE_CLASS, mxREAL));
- }
-
- TV_ROF_CPU_main(Input, Output, lambda, iter_numb, tau, dimX, dimY, dimZ);
-} \ No newline at end of file
diff --git a/Wrappers/Matlab/mex_compile/regularisers_CPU/SB_TV.c b/Wrappers/Matlab/mex_compile/regularisers_CPU/SB_TV.c
deleted file mode 100644
index 8636322..0000000
--- a/Wrappers/Matlab/mex_compile/regularisers_CPU/SB_TV.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * This work is part of the Core Imaging Library developed by
- * Visual Analytics and Imaging System Group of the Science Technology
- * Facilities Council, STFC
- *
- * Copyright 2017 Daniil Kazantsev
- * Copyright 2017 Srikanth Nagella, Edoardo Pasca
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "matrix.h"
-#include "mex.h"
-#include "SB_TV_core.h"
-
-/* C-OMP implementation of Split Bregman - TV denoising-regularisation model (2D/3D) [1]
-*
-* Input Parameters:
-* 1. Noisy image/volume
-* 2. lambda - regularisation parameter
-* 3. Number of iterations [OPTIONAL parameter]
-* 4. eplsilon - tolerance constant [OPTIONAL parameter]
-* 5. TV-type: 'iso' or 'l1' [OPTIONAL parameter]
-* 6. print information: 0 (off) or 1 (on) [OPTIONAL parameter]
-*
-* Output:
-* 1. Filtered/regularized image
-*
-* This function is based on the Matlab's code and paper by
-* [1]. Goldstein, T. and Osher, S., 2009. The split Bregman method for L1-regularized problems. SIAM journal on imaging sciences, 2(2), pp.323-343.
-*/
-
-void mexFunction(
- int nlhs, mxArray *plhs[],
- int nrhs, const mxArray *prhs[])
-
-{
- int number_of_dims, iter, methTV, printswitch;
- mwSize dimX, dimY, dimZ;
- const mwSize *dim_array;
-
- float *Input, *Output=NULL, lambda, epsil;
-
- number_of_dims = mxGetNumberOfDimensions(prhs[0]);
- dim_array = mxGetDimensions(prhs[0]);
-
- /*Handling Matlab input data*/
- if ((nrhs < 2) || (nrhs > 6)) mexErrMsgTxt("At least 2 parameters is required, all parameters are: Image(2D/3D), Regularization parameter, Regularization parameter, iterations number, tolerance, penalty type ('iso' or 'l1'), print switch");
-
- Input = (float *) mxGetData(prhs[0]); /*noisy image (2D/3D) */
- lambda = (float) mxGetScalar(prhs[1]); /* regularization parameter */
- iter = 100; /* default iterations number */
- epsil = 0.0001; /* default tolerance constant */
- methTV = 0; /* default isotropic TV penalty */
- printswitch = 0; /*default print is switched, off - 0 */
-
- if (mxGetClassID(prhs[0]) != mxSINGLE_CLASS) {mexErrMsgTxt("The input image must be in a single precision"); }
-
- if ((nrhs == 3) || (nrhs == 4) || (nrhs == 5) || (nrhs == 6)) iter = (int) mxGetScalar(prhs[2]); /* iterations number */
- if ((nrhs == 4) || (nrhs == 5) || (nrhs == 6)) epsil = (float) mxGetScalar(prhs[3]); /* tolerance constant */
- if ((nrhs == 5) || (nrhs == 6)) {
- char *penalty_type;
- penalty_type = mxArrayToString(prhs[4]); /* choosing TV penalty: 'iso' or 'l1', 'iso' is the default */
- if ((strcmp(penalty_type, "l1") != 0) && (strcmp(penalty_type, "iso") != 0)) mexErrMsgTxt("Choose TV type: 'iso' or 'l1',");
- if (strcmp(penalty_type, "l1") == 0) methTV = 1; /* enable 'l1' penalty */
- mxFree(penalty_type);
- }
- if (nrhs == 6) {
- printswitch = (int) mxGetScalar(prhs[5]);
- if ((printswitch != 0) && (printswitch != 1)) mexErrMsgTxt("Print can be enabled by choosing 1 or off - 0");
- }
-
- /*Handling Matlab output data*/
- dimX = dim_array[0]; dimY = dim_array[1]; dimZ = dim_array[2];
-
- if (number_of_dims == 2) {
- dimZ = 1; /*2D case*/
- Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(2, dim_array, mxSINGLE_CLASS, mxREAL));
- }
- if (number_of_dims == 3) Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(3, dim_array, mxSINGLE_CLASS, mxREAL));
-
- /* running the function */
- SB_TV_CPU_main(Input, Output, lambda, iter, epsil, methTV, printswitch, dimX, dimY, dimZ);
-}
diff --git a/Wrappers/Matlab/mex_compile/regularisers_CPU/TGV.c b/Wrappers/Matlab/mex_compile/regularisers_CPU/TGV.c
deleted file mode 100644
index aa4eed4..0000000
--- a/Wrappers/Matlab/mex_compile/regularisers_CPU/TGV.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
-This work is part of the Core Imaging Library developed by
-Visual Analytics and Imaging System Group of the Science Technology
-Facilities Council, STFC
-
-Copyright 2017 Daniil Kazantsev
-Copyright 2017 Srikanth Nagella, Edoardo Pasca
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-http://www.apache.org/licenses/LICENSE-2.0
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-#include "mex.h"
-#include "TGV_core.h"
-
-/* C-OMP implementation of Primal-Dual denoising method for
- * Total Generilized Variation (TGV)-L2 model [1] (2D/3D)
- *
- * Input Parameters:
- * 1. Noisy image/volume (2D/3D)
- * 2. lambda - regularisation parameter
- * 3. parameter to control the first-order term (alpha1)
- * 4. parameter to control the second-order term (alpha0)
- * 5. Number of Chambolle-Pock (Primal-Dual) iterations
- * 6. Lipshitz constant (default is 12)
- *
- * Output:
- * Filtered/regulariaed image
- *
- * References:
- * [1] K. Bredies "Total Generalized Variation"
- */
-
-void mexFunction(
- int nlhs, mxArray *plhs[],
- int nrhs, const mxArray *prhs[])
-
-{
- int number_of_dims, iter;
- mwSize dimX, dimY, dimZ;
- const mwSize *dim_array;
-
- float *Input, *Output=NULL, lambda, alpha0, alpha1, L2;
-
- number_of_dims = mxGetNumberOfDimensions(prhs[0]);
- dim_array = mxGetDimensions(prhs[0]);
-
- /*Handling Matlab input data*/
- if ((nrhs < 2) || (nrhs > 6)) mexErrMsgTxt("At least 2 parameters is required, all parameters are: Image(2D), Regularisation parameter, alpha0, alpha1, iterations number, Lipshitz Constant");
-
- Input = (float *) mxGetData(prhs[0]); /*noisy image/volume */
- lambda = (float) mxGetScalar(prhs[1]); /* regularisation parameter */
- alpha1 = 1.0f; /* parameter to control the first-order term */
- alpha0 = 0.5f; /* parameter to control the second-order term */
- iter = 300; /* Iterations number */
- L2 = 12.0f; /* Lipshitz constant */
-
- if (mxGetClassID(prhs[0]) != mxSINGLE_CLASS) {mexErrMsgTxt("The input image must be in a single precision"); }
- if ((nrhs == 3) || (nrhs == 4) || (nrhs == 5) || (nrhs == 6)) alpha1 = (float) mxGetScalar(prhs[2]); /* parameter to control the first-order term */
- if ((nrhs == 4) || (nrhs == 5) || (nrhs == 6)) alpha0 = (float) mxGetScalar(prhs[3]); /* parameter to control the second-order term */
- if ((nrhs == 5) || (nrhs == 6)) iter = (int) mxGetScalar(prhs[4]); /* Iterations number */
- if (nrhs == 6) L2 = (float) mxGetScalar(prhs[5]); /* Lipshitz constant */
-
- /*Handling Matlab output data*/
- dimX = dim_array[0]; dimY = dim_array[1]; dimZ = dim_array[2];
-
- if (number_of_dims == 2) {
- dimZ = 1; /*2D case*/
- Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(2, dim_array, mxSINGLE_CLASS, mxREAL));
- }
- if (number_of_dims == 3) {
- Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(3, dim_array, mxSINGLE_CLASS, mxREAL));
- }
- /* running the function */
- TGV_main(Input, Output, lambda, alpha1, alpha0, iter, L2, dimX, dimY, dimZ);
-}
diff --git a/Wrappers/Matlab/mex_compile/regularisers_CPU/TNV.c b/Wrappers/Matlab/mex_compile/regularisers_CPU/TNV.c
deleted file mode 100644
index acea75d..0000000
--- a/Wrappers/Matlab/mex_compile/regularisers_CPU/TNV.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * This work is part of the Core Imaging Library developed by
- * Visual Analytics and Imaging System Group of the Science Technology
- * Facilities Council, STFC
- *
- * Copyright 2017 Daniil Kazantsev
- * Copyright 2017 Srikanth Nagella, Edoardo Pasca
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "matrix.h"
-#include "mex.h"
-#include "TNV_core.h"
-/*
- * C-OMP implementation of Total Nuclear Variation regularisation model (2D + channels) [1]
- * The code is modified from the implementation by Joan Duran <joan.duran@uib.es> see
- * "denoisingPDHG_ipol.cpp" in Joans Collaborative Total Variation package
- *
- * Input Parameters:
- * 1. Noisy volume of 2D + channel dimension, i.e. 3D volume
- * 2. lambda - regularisation parameter
- * 3. Number of iterations [OPTIONAL parameter]
- * 4. eplsilon - tolerance constant [OPTIONAL parameter]
- * 5. print information: 0 (off) or 1 (on) [OPTIONAL parameter]
- *
- * Output:
- * 1. Filtered/regularized image
- *
- * [1]. Duran, J., Moeller, M., Sbert, C. and Cremers, D., 2016. Collaborative total variation: a general framework for vectorial TV models. SIAM Journal on Imaging Sciences, 9(1), pp.116-151.
- */
-void mexFunction(
- int nlhs, mxArray *plhs[],
- int nrhs, const mxArray *prhs[])
-
-{
- int number_of_dims, iter;
- mwSize dimX, dimY, dimZ;
- const mwSize *dim_array;
- float *Input, *Output=NULL, lambda, epsil;
-
- number_of_dims = mxGetNumberOfDimensions(prhs[0]);
- dim_array = mxGetDimensions(prhs[0]);
-
- /*Handling Matlab input data*/
- if ((nrhs < 2) || (nrhs > 4)) mexErrMsgTxt("At least 2 parameters is required, all parameters are: Image(2D + channels), Regularisation parameter, Regularization parameter, iterations number, tolerance");
-
- Input = (float *) mxGetData(prhs[0]); /* noisy sequence of channels (2D + channels) */
- lambda = (float) mxGetScalar(prhs[1]); /* regularization parameter */
- iter = 1000; /* default iterations number */
- epsil = 1.00e-05; /* default tolerance constant */
-
- if (mxGetClassID(prhs[0]) != mxSINGLE_CLASS) {mexErrMsgTxt("The input image must be in a single precision"); }
-
- if ((nrhs == 3) || (nrhs == 4)) iter = (int) mxGetScalar(prhs[2]); /* iterations number */
- if (nrhs == 4) epsil = (float) mxGetScalar(prhs[3]); /* tolerance constant */
-
- /*Handling Matlab output data*/
- dimX = dim_array[0]; dimY = dim_array[1]; dimZ = dim_array[2];
-
- if (number_of_dims == 2) mexErrMsgTxt("The input must be 3D: [X,Y,Channels]");
- if (number_of_dims == 3) {
- Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(3, dim_array, mxSINGLE_CLASS, mxREAL));
- /* running the function */
- TNV_CPU_main(Input, Output, lambda, iter, epsil, dimX, dimY, dimZ);
- }
-} \ No newline at end of file
diff --git a/Wrappers/Matlab/mex_compile/regularisers_CPU/TV_energy.c b/Wrappers/Matlab/mex_compile/regularisers_CPU/TV_energy.c
deleted file mode 100644
index d457f46..0000000
--- a/Wrappers/Matlab/mex_compile/regularisers_CPU/TV_energy.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * This work is part of the Core Imaging Library developed by
- * Visual Analytics and Imaging System Group of the Science Technology
- * Facilities Council, STFC
- *
- * Copyright 2017 Daniil Kazantsev
- * Copyright 2017 Srikanth Nagella, Edoardo Pasca
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "matrix.h"
-#include "mex.h"
-#include "utils.h"
-/*
- * Function to calculate TV energy value with respect to the denoising variational problem
- *
- * Input:
- * 1. Denoised Image/volume
- * 2. Original (noisy) Image/volume
- * 3. lambda - regularisation parameter
- *
- * Output:
- * 1. Energy function value
- *
- */
-void mexFunction(
- int nlhs, mxArray *plhs[],
- int nrhs, const mxArray *prhs[])
-
-{
- int number_of_dims, type;
-
- mwSize dimX, dimY, dimZ;
- const mwSize *dim_array;
- float *Input, *Input0, lambda;
-
- number_of_dims = mxGetNumberOfDimensions(prhs[0]);
- dim_array = mxGetDimensions(prhs[0]);
-
- /*Handling Matlab input data*/
- if ((nrhs != 4)) mexErrMsgTxt("4 inputs: Two images or volumes of the same size required, estimated and the original (noisy), regularisation parameter, type");
-
- Input = (float *) mxGetData(prhs[0]); /* Denoised Image/volume */
- Input0 = (float *) mxGetData(prhs[1]); /* Original (noisy) Image/volume */
- lambda = (float) mxGetScalar(prhs[2]); /* regularisation parameter */
- type = (int) mxGetScalar(prhs[3]); /* type of energy */
-
- if (mxGetClassID(prhs[0]) != mxSINGLE_CLASS) {mexErrMsgTxt("The input image must be in a single precision"); }
- if (mxGetClassID(prhs[1]) != mxSINGLE_CLASS) {mexErrMsgTxt("The input image must be in a single precision"); }
-
- /*output energy function value */
- plhs[0] = mxCreateNumericMatrix(1, 1, mxSINGLE_CLASS, mxREAL);
- float *funcvalA = (float *) mxGetData(plhs[0]);
-
- /*Handling Matlab output data*/
- dimX = dim_array[0]; dimY = dim_array[1]; dimZ = dim_array[2];
-
- if (number_of_dims == 2) {
- TV_energy2D(Input, Input0, funcvalA, lambda, type, dimX, dimY);
- }
- if (number_of_dims == 3) {
- TV_energy3D(Input, Input0, funcvalA, lambda, type, dimX, dimY, dimZ);
- }
-}
diff --git a/Wrappers/Matlab/mex_compile/regularisers_GPU/Diffusion_4thO_GPU.cpp b/Wrappers/Matlab/mex_compile/regularisers_GPU/Diffusion_4thO_GPU.cpp
deleted file mode 100644
index 0cc042b..0000000
--- a/Wrappers/Matlab/mex_compile/regularisers_GPU/Diffusion_4thO_GPU.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * This work is part of the Core Imaging Library developed by
- * Visual Analytics and Imaging System Group of the Science Technology
- * Facilities Council, STFC
- *
- * Copyright 2017 Daniil Kazantsev
- * Copyright 2017 Srikanth Nagella, Edoardo Pasca
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "matrix.h"
-#include "mex.h"
-#include "Diffus_4thO_GPU_core.h"
-
-/* CUDA implementation of fourth-order diffusion scheme [1] for piecewise-smooth recovery (2D/3D case)
- * The minimisation is performed using explicit scheme.
- *
- * Input Parameters:
- * 1. Noisy image/volume [REQUIRED]
- * 2. lambda - regularization parameter [REQUIRED]
- * 3. Edge-preserving parameter (sigma) [REQUIRED]
- * 4. Number of iterations, for explicit scheme >= 150 is recommended [OPTIONAL, default 300]
- * 5. tau - time-marching step for the explicit scheme [OPTIONAL, default 0.015]
- *
- * Output:
- * [1] Regularized image/volume
- *
- * This function is based on the paper by
- * [1] Hajiaboli, M.R., 2011. An anisotropic fourth-order diffusion filter for image noise removal. International Journal of Computer Vision, 92(2), pp.177-191.
- */
-
-void mexFunction(
- int nlhs, mxArray *plhs[],
- int nrhs, const mxArray *prhs[])
-
-{
- int number_of_dims, iter_numb;
- mwSize dimX, dimY, dimZ;
- const mwSize *dim_array;
- float *Input, *Output=NULL, lambda, tau, sigma;
-
- dim_array = mxGetDimensions(prhs[0]);
- number_of_dims = mxGetNumberOfDimensions(prhs[0]);
-
- /*Handling Matlab input data*/
- Input = (float *) mxGetData(prhs[0]);
- lambda = (float) mxGetScalar(prhs[1]); /* regularization parameter */
- sigma = (float) mxGetScalar(prhs[2]); /* Edge-preserving parameter */
- iter_numb = 300; /* iterations number */
- tau = 0.01; /* marching step parameter */
-
- if (mxGetClassID(prhs[0]) != mxSINGLE_CLASS) {mexErrMsgTxt("The input image must be in a single precision"); }
- if ((nrhs < 3) || (nrhs > 5)) mexErrMsgTxt("At least 3 parameters is required, all parameters are: Image(2D/3D), Regularisation parameter, Edge-preserving parameter, iterations number, time-marching constant");
- if ((nrhs == 4) || (nrhs == 5)) iter_numb = (int) mxGetScalar(prhs[3]); /* iterations number */
- if (nrhs == 5) tau = (float) mxGetScalar(prhs[4]); /* marching step parameter */
-
- /*Handling Matlab output data*/
- dimX = dim_array[0]; dimY = dim_array[1]; dimZ = dim_array[2];
-
- /* output arrays*/
- if (number_of_dims == 2) {
- dimZ = 1; /*2D case*/
- /* output image/volume */
- Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(2, dim_array, mxSINGLE_CLASS, mxREAL));
- }
- if (number_of_dims == 3) Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(3, dim_array, mxSINGLE_CLASS, mxREAL));
-
- Diffus4th_GPU_main(Input, Output, lambda, sigma, iter_numb, tau, dimX, dimY, dimZ);
-} \ No newline at end of file
diff --git a/Wrappers/Matlab/mex_compile/regularisers_GPU/FGP_TV_GPU.cpp b/Wrappers/Matlab/mex_compile/regularisers_GPU/FGP_TV_GPU.cpp
deleted file mode 100644
index c174e75..0000000
--- a/Wrappers/Matlab/mex_compile/regularisers_GPU/FGP_TV_GPU.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * This work is part of the Core Imaging Library developed by
- * Visual Analytics and Imaging System Group of the Science Technology
- * Facilities Council, STFC
- *
- * Copyright 2017 Daniil Kazantsev
- * Copyright 2017 Srikanth Nagella, Edoardo Pasca
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "matrix.h"
-#include "mex.h"
-#include "TV_FGP_GPU_core.h"
-
-/* GPU (CUDA) implementation of FGP-TV [1] denoising/regularization model (2D/3D case)
- *
- * Input Parameters:
- * 1. Noisy image/volume
- * 2. lambdaPar - regularization parameter
- * 3. Number of iterations
- * 4. eplsilon: tolerance constant
- * 5. TV-type: methodTV - 'iso' (0) or 'l1' (1)
- * 6. nonneg: 'nonnegativity (0 is OFF by default)
- * 7. print information: 0 (off) or 1 (on)
- *
- * Output:
- * [1] Filtered/regularized image
- *
- * This function is based on the Matlab's code and paper by
- * [1] Amir Beck and Marc Teboulle, "Fast Gradient-Based Algorithms for Constrained Total Variation Image Denoising and Deblurring Problems"
- */
-
-void mexFunction(
- int nlhs, mxArray *plhs[],
- int nrhs, const mxArray *prhs[])
-
-{
- int number_of_dims, iter, methTV, printswitch, nonneg;
- mwSize dimX, dimY, dimZ;
- const mwSize *dim_array;
-
- float *Input, *Output=NULL, lambda, epsil;
-
- number_of_dims = mxGetNumberOfDimensions(prhs[0]);
- dim_array = mxGetDimensions(prhs[0]);
-
- /*Handling Matlab input data*/
- if ((nrhs < 2) || (nrhs > 7)) mexErrMsgTxt("At least 2 parameters is required, all parameters are: Image(2D/3D), Regularization parameter. The full list of parameters: Image(2D/3D), Regularization parameter, iterations number, tolerance, penalty type ('iso' or 'l1'), nonnegativity switch, print switch");
-
- Input = (float *) mxGetData(prhs[0]); /*noisy image (2D/3D) */
- lambda = (float) mxGetScalar(prhs[1]); /* regularization parameter */
- iter = 300; /* default iterations number */
- epsil = 0.0001; /* default tolerance constant */
- methTV = 0; /* default isotropic TV penalty */
- nonneg = 0; /* default nonnegativity switch, off - 0 */
- printswitch = 0; /*default print is switched, off - 0 */
-
- if (mxGetClassID(prhs[0]) != mxSINGLE_CLASS) {mexErrMsgTxt("The input image must be in a single precision"); }
-
- if ((nrhs == 3) || (nrhs == 4) || (nrhs == 5) || (nrhs == 6) || (nrhs == 7)) iter = (int) mxGetScalar(prhs[2]); /* iterations number */
- if ((nrhs == 4) || (nrhs == 5) || (nrhs == 6) || (nrhs == 7)) epsil = (float) mxGetScalar(prhs[3]); /* tolerance constant */
- if ((nrhs == 5) || (nrhs == 6) || (nrhs == 7)) {
- char *penalty_type;
- penalty_type = mxArrayToString(prhs[4]); /* choosing TV penalty: 'iso' or 'l1', 'iso' is the default */
- if ((strcmp(penalty_type, "l1") != 0) && (strcmp(penalty_type, "iso") != 0)) mexErrMsgTxt("Choose TV type: 'iso' or 'l1',");
- if (strcmp(penalty_type, "l1") == 0) methTV = 1; /* enable 'l1' penalty */
- mxFree(penalty_type);
- }
- if ((nrhs == 6) || (nrhs == 7)) {
- nonneg = (int) mxGetScalar(prhs[5]);
- if ((nonneg != 0) && (nonneg != 1)) mexErrMsgTxt("Nonnegativity constraint can be enabled by choosing 1 or off - 0");
- }
- if (nrhs == 7) {
- printswitch = (int) mxGetScalar(prhs[6]);
- if ((printswitch != 0) && (printswitch != 1)) mexErrMsgTxt("Print can be enabled by choosing 1 or off - 0");
- }
-
- /*Handling Matlab output data*/
- dimX = dim_array[0]; dimY = dim_array[1]; dimZ = dim_array[2];
-
- if (number_of_dims == 2) {
- dimZ = 1; /*2D case*/
- Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(2, dim_array, mxSINGLE_CLASS, mxREAL));
- }
- if (number_of_dims == 3) Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(3, dim_array, mxSINGLE_CLASS, mxREAL));
-
- /* running the function */
- TV_FGP_GPU_main(Input, Output, lambda, iter, epsil, methTV, nonneg, printswitch, dimX, dimY, dimZ);
-} \ No newline at end of file
diff --git a/Wrappers/Matlab/mex_compile/regularisers_GPU/FGP_dTV_GPU.cpp b/Wrappers/Matlab/mex_compile/regularisers_GPU/FGP_dTV_GPU.cpp
deleted file mode 100644
index 3f5a4b3..0000000
--- a/Wrappers/Matlab/mex_compile/regularisers_GPU/FGP_dTV_GPU.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * This work is part of the Core Imaging Library developed by
- * Visual Analytics and Imaging System Group of the Science Technology
- * Facilities Council, STFC
- *
- * Copyright 2017 Daniil Kazantsev
- * Copyright 2017 Srikanth Nagella, Edoardo Pasca
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "matrix.h"
-#include "mex.h"
-#include "dTV_FGP_GPU_core.h"
-
-/* CUDA implementation of FGP-dTV [1,2] denoising/regularization model (2D/3D case)
- * which employs structural similarity of the level sets of two images/volumes, see [1,2]
- * The current implementation updates image 1 while image 2 is being fixed.
- *
- * Input Parameters:
- * 1. Noisy image/volume [REQUIRED]
- * 2. Additional reference image/volume of the same dimensions as (1) [REQUIRED]
- * 3. lambdaPar - regularization parameter [REQUIRED]
- * 4. Number of iterations [OPTIONAL]
- * 5. eplsilon: tolerance constant [OPTIONAL]
- * 6. eta: smoothing constant to calculate gradient of the reference [OPTIONAL] *
- * 7. TV-type: methodTV - 'iso' (0) or 'l1' (1) [OPTIONAL]
- * 8. nonneg: 'nonnegativity (0 is OFF by default) [OPTIONAL]
- * 9. print information: 0 (off) or 1 (on) [OPTIONAL]
- *
- * Output:
- * [1] Filtered/regularized image/volume
- *
- * This function is based on the Matlab's codes and papers by
- * [1] Amir Beck and Marc Teboulle, "Fast Gradient-Based Algorithms for Constrained Total Variation Image Denoising and Deblurring Problems"
- * [2] M. J. Ehrhardt and M. M. Betcke, Multi-Contrast MRI Reconstruction with Structure-Guided Total Variation, SIAM Journal on Imaging Sciences 9(3), pp. 1084–1106
- */
-void mexFunction(
- int nlhs, mxArray *plhs[],
- int nrhs, const mxArray *prhs[])
-
-{
- int number_of_dims, iter, methTV, printswitch, nonneg;
- mwSize dimX, dimY, dimZ;
- const mwSize *dim_array;
- const mwSize *dim_array2;
-
- float *Input, *InputRef, *Output=NULL, lambda, epsil, eta;
-
- number_of_dims = mxGetNumberOfDimensions(prhs[0]);
- dim_array = mxGetDimensions(prhs[0]);
- dim_array2 = mxGetDimensions(prhs[1]);
-
- /*Handling Matlab input data*/
- if ((nrhs < 3) || (nrhs > 9)) mexErrMsgTxt("At least 3 parameters is required, all parameters are: Image(2D/3D), Reference(2D/3D), Regularization parameter, iterations number, tolerance, smoothing constant, penalty type ('iso' or 'l1'), nonnegativity switch, print switch");
-
- Input = (float *) mxGetData(prhs[0]); /*noisy image (2D/3D) */
- InputRef = (float *) mxGetData(prhs[1]); /* reference image (2D/3D) */
- lambda = (float) mxGetScalar(prhs[2]); /* regularization parameter */
- iter = 300; /* default iterations number */
- epsil = 0.0001; /* default tolerance constant */
- eta = 0.01; /* default smoothing constant */
- methTV = 0; /* default isotropic TV penalty */
- nonneg = 0; /* default nonnegativity switch, off - 0 */
- printswitch = 0; /*default print is switched, off - 0 */
-
-
- if (mxGetClassID(prhs[0]) != mxSINGLE_CLASS) {mexErrMsgTxt("The input image must be in a single precision"); }
- if (mxGetClassID(prhs[1]) != mxSINGLE_CLASS) {mexErrMsgTxt("The input image must be in a single precision"); }
-
- /*Handling Matlab output data*/
- dimX = dim_array[0]; dimY = dim_array[1]; dimZ = dim_array[2];
- if (number_of_dims == 2) { if ((dimX != dim_array2[0]) || (dimY != dim_array2[1])) mexErrMsgTxt("The input images have different dimensionalities");}
- if (number_of_dims == 3) { if ((dimX != dim_array2[0]) || (dimY != dim_array2[1]) || (dimZ != dim_array2[2])) mexErrMsgTxt("The input volumes have different dimensionalities");}
-
-
- if ((nrhs == 4) || (nrhs == 5) || (nrhs == 6) || (nrhs == 7) || (nrhs == 8) || (nrhs == 9)) iter = (int) mxGetScalar(prhs[3]); /* iterations number */
- if ((nrhs == 5) || (nrhs == 6) || (nrhs == 7) || (nrhs == 8) || (nrhs == 9)) epsil = (float) mxGetScalar(prhs[4]); /* tolerance constant */
- if ((nrhs == 6) || (nrhs == 7) || (nrhs == 8) || (nrhs == 9)) {
- eta = (float) mxGetScalar(prhs[5]); /* smoothing constant for the gradient of InputRef */
- }
- if ((nrhs == 7) || (nrhs == 8) || (nrhs == 9)) {
- char *penalty_type;
- penalty_type = mxArrayToString(prhs[6]); /* choosing TV penalty: 'iso' or 'l1', 'iso' is the default */
- if ((strcmp(penalty_type, "l1") != 0) && (strcmp(penalty_type, "iso") != 0)) mexErrMsgTxt("Choose TV type: 'iso' or 'l1',");
- if (strcmp(penalty_type, "l1") == 0) methTV = 1; /* enable 'l1' penalty */
- mxFree(penalty_type);
- }
- if ((nrhs == 8) || (nrhs == 9)) {
- nonneg = (int) mxGetScalar(prhs[7]);
- if ((nonneg != 0) && (nonneg != 1)) mexErrMsgTxt("Nonnegativity constraint can be enabled by choosing 1 or off - 0");
- }
- if (nrhs == 9) {
- printswitch = (int) mxGetScalar(prhs[8]);
- if ((printswitch != 0) && (printswitch != 1)) mexErrMsgTxt("Print can be enabled by choosing 1 or off - 0");
- }
-
- if (number_of_dims == 2) {
- dimZ = 1; /*2D case*/
- Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(2, dim_array, mxSINGLE_CLASS, mxREAL));
- }
- if (number_of_dims == 3) Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(3, dim_array, mxSINGLE_CLASS, mxREAL));
-
- /* running the function */
- dTV_FGP_GPU_main(Input, InputRef, Output, lambda, iter, epsil, eta, methTV, nonneg, printswitch, dimX, dimY, dimZ);
-} \ No newline at end of file
diff --git a/Wrappers/Matlab/mex_compile/regularisers_GPU/LLT_ROF_GPU.cpp b/Wrappers/Matlab/mex_compile/regularisers_GPU/LLT_ROF_GPU.cpp
deleted file mode 100644
index e8da4ce..0000000
--- a/Wrappers/Matlab/mex_compile/regularisers_GPU/LLT_ROF_GPU.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * This work is part of the Core Imaging Library developed by
- * Visual Analytics and Imaging System Group of the Science Technology
- * Facilities Council, STFC
- *
- * Copyright 2017 Daniil Kazantsev
- * Copyright 2017 Srikanth Nagella, Edoardo Pasca
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "matrix.h"
-#include "mex.h"
-#include "LLT_ROF_GPU_core.h"
-
-/* CUDA implementation of Lysaker, Lundervold and Tai (LLT) model [1] combined with Rudin-Osher-Fatemi [2] TV regularisation penalty.
-*
-* This penalty can deliver visually pleasant piecewise-smooth recovery if regularisation parameters are selected well.
-* The rule of thumb for selection is to start with lambdaLLT = 0 (just the ROF-TV model) and then proceed to increase
-* lambdaLLT starting with smaller values.
-*
-* Input Parameters:
-* 1. U0 - original noise image/volume
-* 2. lambdaROF - ROF-related regularisation parameter
-* 3. lambdaLLT - LLT-related regularisation parameter
-* 4. tau - time-marching step
-* 5. iter - iterations number (for both models)
-*
-* Output:
-* Filtered/regularised image
-*
-* References:
-* [1] Lysaker, M., Lundervold, A. and Tai, X.C., 2003. Noise removal using fourth-order partial differential equation with applications to medical magnetic resonance images in space and time. IEEE Transactions on image processing, 12(12), pp.1579-1590.
-* [2] Rudin, Osher, Fatemi, "Nonlinear Total Variation based noise removal algorithms"
-*/
-
-void mexFunction(
- int nlhs, mxArray *plhs[],
- int nrhs, const mxArray *prhs[])
-
-{
- int number_of_dims, iterationsNumb;
- mwSize dimX, dimY, dimZ;
- const mwSize *dim_array;
-
- float *Input, *Output=NULL, lambdaROF, lambdaLLT, tau;
-
- dim_array = mxGetDimensions(prhs[0]);
- number_of_dims = mxGetNumberOfDimensions(prhs[0]);
-
- if ((nrhs < 3) || (nrhs > 5)) mexErrMsgTxt("At least 3 parameters is required, all parameters are: Image(2D/3D), Regularisation parameter (ROF), Regularisation parameter (LTT), iterations number, time-marching parameter");
-
- /*Handling Matlab input data*/
- Input = (float *) mxGetData(prhs[0]);
- lambdaROF = (float) mxGetScalar(prhs[1]); /* ROF regularization parameter */
- lambdaLLT = (float) mxGetScalar(prhs[2]); /* ROF regularization parameter */
- iterationsNumb = 250;
- tau = 0.0025;
-
- if (mxGetClassID(prhs[0]) != mxSINGLE_CLASS) {mexErrMsgTxt("The input image must be in a single precision"); }
- if ((nrhs == 4) || (nrhs == 5)) iterationsNumb = (int) mxGetScalar(prhs[3]); /* iterations number */
- if (nrhs == 5) tau = (float) mxGetScalar(prhs[4]); /* marching step parameter */
-
- /*Handling Matlab output data*/
- dimX = dim_array[0]; dimY = dim_array[1]; dimZ = dim_array[2];
-
- /* output arrays*/
- if (number_of_dims == 2) {
- dimZ = 1; /*2D case*/
- /* output image/volume */
- Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(2, dim_array, mxSINGLE_CLASS, mxREAL));
- }
- if (number_of_dims == 3) Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(3, dim_array, mxSINGLE_CLASS, mxREAL));
-
- LLT_ROF_GPU_main(Input, Output, lambdaROF, lambdaLLT, iterationsNumb, tau, dimX, dimY, dimZ);
-} \ No newline at end of file
diff --git a/Wrappers/Matlab/mex_compile/regularisers_GPU/NonlDiff_GPU.cpp b/Wrappers/Matlab/mex_compile/regularisers_GPU/NonlDiff_GPU.cpp
deleted file mode 100644
index 1cd0cdc..0000000
--- a/Wrappers/Matlab/mex_compile/regularisers_GPU/NonlDiff_GPU.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * This work is part of the Core Imaging Library developed by
- * Visual Analytics and Imaging System Group of the Science Technology
- * Facilities Council, STFC
- *
- * Copyright 2017 Daniil Kazantsev
- * Copyright 2017 Srikanth Nagella, Edoardo Pasca
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "matrix.h"
-#include "mex.h"
-#include <stdio.h>
-#include <string.h>
-#include "NonlDiff_GPU_core.h"
-
-/* CUDA implementation of linear and nonlinear diffusion with the regularisation model [1,2] (2D/3D case)
- * The minimisation is performed using explicit scheme.
- *
- * Input Parameters:
- * 1. Noisy image/volume
- * 2. lambda - regularization parameter
- * 3. Edge-preserving parameter (sigma), when sigma equals to zero nonlinear diffusion -> linear diffusion
- * 4. Number of iterations, for explicit scheme >= 150 is recommended
- * 5. tau - time-marching step for explicit scheme
- * 6. Penalty type: 1 - Huber, 2 - Perona-Malik, 3 - Tukey Biweight
- *
- * Output:
- * [1] Regularized image/volume
- *
- * This function is based on the paper by
- * [1] Perona, P. and Malik, J., 1990. Scale-space and edge detection using anisotropic diffusion. IEEE Transactions on pattern analysis and machine intelligence, 12(7), pp.629-639.
- * [2] Black, M.J., Sapiro, G., Marimont, D.H. and Heeger, D., 1998. Robust anisotropic diffusion. IEEE Transactions on image processing, 7(3), pp.421-432.
- */
-
-void mexFunction(
- int nlhs, mxArray *plhs[],
- int nrhs, const mxArray *prhs[])
-
-{
- int number_of_dims, iter_numb, penaltytype;
- mwSize dimX, dimY, dimZ;
- const mwSize *dim_array;
-
- float *Input, *Output=NULL, lambda, tau, sigma;
-
- dim_array = mxGetDimensions(prhs[0]);
- number_of_dims = mxGetNumberOfDimensions(prhs[0]);
-
- /*Handling Matlab input data*/
- Input = (float *) mxGetData(prhs[0]);
- lambda = (float) mxGetScalar(prhs[1]); /* regularization parameter */
- sigma = (float) mxGetScalar(prhs[2]); /* Edge-preserving parameter */
- iter_numb = 300; /* iterations number */
- tau = 0.025; /* marching step parameter */
- penaltytype = 1; /* Huber penalty by default */
-
- if (mxGetClassID(prhs[0]) != mxSINGLE_CLASS) {mexErrMsgTxt("The input image must be in a single precision"); }
- if ((nrhs < 3) || (nrhs > 6)) mexErrMsgTxt("At least 3 parameters is required, all parameters are: Image(2D/3D), Regularisation parameter, Edge-preserving parameter, iterations number, time-marching constant, penalty type - Huber, PM or Tukey");
- if ((nrhs == 4) || (nrhs == 5) || (nrhs == 6)) iter_numb = (int) mxGetScalar(prhs[3]); /* iterations number */
- if ((nrhs == 5) || (nrhs == 6)) tau = (float) mxGetScalar(prhs[4]); /* marching step parameter */
- if (nrhs == 6) {
- char *penalty_type;
- penalty_type = mxArrayToString(prhs[5]); /* Huber, PM or Tukey 'Huber' is the default */
- if ((strcmp(penalty_type, "Huber") != 0) && (strcmp(penalty_type, "PM") != 0) && (strcmp(penalty_type, "Tukey") != 0)) mexErrMsgTxt("Choose penalty: 'Huber', 'PM' or 'Tukey',");
- if (strcmp(penalty_type, "Huber") == 0) penaltytype = 1; /* enable 'Huber' penalty */
- if (strcmp(penalty_type, "PM") == 0) penaltytype = 2; /* enable Perona-Malik penalty */
- if (strcmp(penalty_type, "Tukey") == 0) penaltytype = 3; /* enable Tikey Biweight penalty */
- mxFree(penalty_type);
- }
-
- /*Handling Matlab output data*/
- dimX = dim_array[0]; dimY = dim_array[1]; dimZ = dim_array[2];
-
- /* output arrays*/
- if (number_of_dims == 2) {
- dimZ = 1; /*2D case*/
- /* output image/volume */
- Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(2, dim_array, mxSINGLE_CLASS, mxREAL));
- }
- if (number_of_dims == 3) Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(3, dim_array, mxSINGLE_CLASS, mxREAL));
-
- NonlDiff_GPU_main(Input, Output, lambda, sigma, iter_numb, tau, penaltytype, dimX, dimY, dimZ);
-} \ No newline at end of file
diff --git a/Wrappers/Matlab/mex_compile/regularisers_GPU/ROF_TV_GPU.cpp b/Wrappers/Matlab/mex_compile/regularisers_GPU/ROF_TV_GPU.cpp
deleted file mode 100644
index bd01d55..0000000
--- a/Wrappers/Matlab/mex_compile/regularisers_GPU/ROF_TV_GPU.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * This work is part of the Core Imaging Library developed by
- * Visual Analytics and Imaging System Group of the Science Technology
- * Facilities Council, STFC
- *
- * Copyright 2017 Daniil Kazantsev
- * Copyright 2017 Srikanth Nagella, Edoardo Pasca
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "matrix.h"
-#include "mex.h"
-#include "TV_ROF_GPU_core.h"
-
-/* ROF-TV denoising/regularization model [1] (2D/3D case)
- * (MEX wrapper for MATLAB)
- *
- * Input Parameters:
- * 1. Noisy image/volume [REQUIRED]
- * 2. lambda - regularization parameter [REQUIRED]
- * 3. Number of iterations, for explicit scheme >= 150 is recommended [REQUIRED]
- * 4. tau - marching step for explicit scheme, ~1 is recommended [REQUIRED]
- *
- * Output:
- * [1] Regularized image/volume
- *
- * This function is based on the paper by
- * [1] Rudin, Osher, Fatemi, "Nonlinear Total Variation based noise removal algorithms"
- *
- * D. Kazantsev, 2016-18
- */
-void mexFunction(
- int nlhs, mxArray *plhs[],
- int nrhs, const mxArray *prhs[])
-
-{
- int number_of_dims, iter_numb;
- mwSize dimX, dimY, dimZ;
- const mwSize *dim_array;
-
- float *Input, *Output=NULL, lambda, tau;
-
- dim_array = mxGetDimensions(prhs[0]);
- number_of_dims = mxGetNumberOfDimensions(prhs[0]);
-
- /*Handling Matlab input data*/
- Input = (float *) mxGetData(prhs[0]);
- lambda = (float) mxGetScalar(prhs[1]); /* regularization parameter */
- iter_numb = (int) mxGetScalar(prhs[2]); /* iterations number */
- tau = (float) mxGetScalar(prhs[3]); /* marching step parameter */
-
- if (mxGetClassID(prhs[0]) != mxSINGLE_CLASS) {mexErrMsgTxt("The input image must be in a single precision"); }
- if(nrhs != 4) mexErrMsgTxt("Four inputs reqired: Image(2D,3D), regularization parameter, iterations number, marching step constant");
- /*Handling Matlab output data*/
- dimX = dim_array[0]; dimY = dim_array[1]; dimZ = dim_array[2];
-
- /* output arrays*/
- if (number_of_dims == 2) {
- dimZ = 1; /*2D case*/
- /* output image/volume */
- Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(2, dim_array, mxSINGLE_CLASS, mxREAL));
- }
- if (number_of_dims == 3) Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(3, dim_array, mxSINGLE_CLASS, mxREAL));
-
- TV_ROF_GPU_main(Input, Output, lambda, iter_numb, tau, dimX, dimY, dimZ);
-} \ No newline at end of file
diff --git a/Wrappers/Matlab/mex_compile/regularisers_GPU/SB_TV_GPU.cpp b/Wrappers/Matlab/mex_compile/regularisers_GPU/SB_TV_GPU.cpp
deleted file mode 100644
index 9d1328f..0000000
--- a/Wrappers/Matlab/mex_compile/regularisers_GPU/SB_TV_GPU.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * This work is part of the Core Imaging Library developed by
- * Visual Analytics and Imaging System Group of the Science Technology
- * Facilities Council, STFC
- *
- * Copyright 2017 Daniil Kazantsev
- * Copyright 2017 Srikanth Nagella, Edoardo Pasca
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "matrix.h"
-#include "mex.h"
-#include "TV_SB_GPU_core.h"
-
-/* CUDA mex-file for implementation of Split Bregman - TV denoising-regularisation model (2D/3D) [1]
-*
-* Input Parameters:
-* 1. Noisy image/volume
-* 2. lambda - regularisation parameter
-* 3. Number of iterations [OPTIONAL parameter]
-* 4. eplsilon - tolerance constant [OPTIONAL parameter]
-* 5. TV-type: 'iso' or 'l1' [OPTIONAL parameter]
-* 6. print information: 0 (off) or 1 (on) [OPTIONAL parameter]
-*
-* Output:
-* 1. Filtered/regularized image
-*
-* This function is based on the Matlab's code and paper by
-* [1]. Goldstein, T. and Osher, S., 2009. The split Bregman method for L1-regularized problems. SIAM journal on imaging sciences, 2(2), pp.323-343.
-*/
-
-void mexFunction(
- int nlhs, mxArray *plhs[],
- int nrhs, const mxArray *prhs[])
-
-{
- int number_of_dims, iter, methTV, printswitch;
- mwSize dimX, dimY, dimZ;
- const mwSize *dim_array;
-
- float *Input, *Output=NULL, lambda, epsil;
-
- number_of_dims = mxGetNumberOfDimensions(prhs[0]);
- dim_array = mxGetDimensions(prhs[0]);
-
- /*Handling Matlab input data*/
- if ((nrhs < 2) || (nrhs > 6)) mexErrMsgTxt("At least 2 parameters is required, all parameters are: Image(2D/3D), Regularization parameter, Regularization parameter, iterations number, tolerance, penalty type ('iso' or 'l1'), print switch");
-
- Input = (float *) mxGetData(prhs[0]); /*noisy image (2D/3D) */
- lambda = (float) mxGetScalar(prhs[1]); /* regularization parameter */
- iter = 100; /* default iterations number */
- epsil = 0.0001; /* default tolerance constant */
- methTV = 0; /* default isotropic TV penalty */
- printswitch = 0; /*default print is switched, off - 0 */
-
- if (mxGetClassID(prhs[0]) != mxSINGLE_CLASS) {mexErrMsgTxt("The input image must be in a single precision"); }
-
- if ((nrhs == 3) || (nrhs == 4) || (nrhs == 5) || (nrhs == 6)) iter = (int) mxGetScalar(prhs[2]); /* iterations number */
- if ((nrhs == 4) || (nrhs == 5) || (nrhs == 6)) epsil = (float) mxGetScalar(prhs[3]); /* tolerance constant */
- if ((nrhs == 5) || (nrhs == 6)) {
- char *penalty_type;
- penalty_type = mxArrayToString(prhs[4]); /* choosing TV penalty: 'iso' or 'l1', 'iso' is the default */
- if ((strcmp(penalty_type, "l1") != 0) && (strcmp(penalty_type, "iso") != 0)) mexErrMsgTxt("Choose TV type: 'iso' or 'l1',");
- if (strcmp(penalty_type, "l1") == 0) methTV = 1; /* enable 'l1' penalty */
- mxFree(penalty_type);
- }
- if (nrhs == 6) {
- printswitch = (int) mxGetScalar(prhs[5]);
- if ((printswitch != 0) && (printswitch != 1)) mexErrMsgTxt("Print can be enabled by choosing 1 or off - 0");
- }
-
- /*Handling Matlab output data*/
- dimX = dim_array[0]; dimY = dim_array[1]; dimZ = dim_array[2];
-
- if (number_of_dims == 2) {
- dimZ = 1; /*2D case*/
- Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(2, dim_array, mxSINGLE_CLASS, mxREAL));
- }
- if (number_of_dims == 3) Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(3, dim_array, mxSINGLE_CLASS, mxREAL));
-
- /* running the function */
- TV_SB_GPU_main(Input, Output, lambda, iter, epsil, methTV, printswitch, dimX, dimY, dimZ);
-}
diff --git a/Wrappers/Matlab/mex_compile/regularisers_GPU/TGV_GPU.cpp b/Wrappers/Matlab/mex_compile/regularisers_GPU/TGV_GPU.cpp
deleted file mode 100644
index 1173282..0000000
--- a/Wrappers/Matlab/mex_compile/regularisers_GPU/TGV_GPU.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
-This work is part of the Core Imaging Library developed by
-Visual Analytics and Imaging System Group of the Science Technology
-Facilities Council, STFC
-
-Copyright 2017 Daniil Kazantsev
-Copyright 2017 Srikanth Nagella, Edoardo Pasca
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-http://www.apache.org/licenses/LICENSE-2.0
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-#include "mex.h"
-#include "TGV_GPU_core.h"
-
-/* CUDA implementation of Primal-Dual denoising method for
- * Total Generilized Variation (TGV)-L2 model [1] (2D/3D)
- *
- * Input Parameters:
- * 1. Noisy image/volume (2D/3D)
- * 2. lambda - regularisation parameter
- * 3. parameter to control the first-order term (alpha1)
- * 4. parameter to control the second-order term (alpha0)
- * 5. Number of Chambolle-Pock (Primal-Dual) iterations
- * 6. Lipshitz constant (default is 12)
- *
- * Output:
- * Filtered/regularised image
- *
- * References:
- * [1] K. Bredies "Total Generalized Variation"
- */
-
-void mexFunction(
- int nlhs, mxArray *plhs[],
- int nrhs, const mxArray *prhs[])
-
-{
- int number_of_dims, iter;
- mwSize dimX, dimY, dimZ;
- const mwSize *dim_array;
- float *Input, *Output=NULL, lambda, alpha0, alpha1, L2;
-
- number_of_dims = mxGetNumberOfDimensions(prhs[0]);
- dim_array = mxGetDimensions(prhs[0]);
-
- /*Handling Matlab input data*/
- if ((nrhs < 2) || (nrhs > 6)) mexErrMsgTxt("At least 2 parameters is required, all parameters are: Image(2D), Regularisation parameter, alpha0, alpha1, iterations number, Lipshitz Constant");
-
- Input = (float *) mxGetData(prhs[0]); /*noisy image (2D) */
- lambda = (float) mxGetScalar(prhs[1]); /* regularisation parameter */
- alpha1 = 1.0f; /* parameter to control the first-order term */
- alpha0 = 2.0f; /* parameter to control the second-order term */
- iter = 500; /* Iterations number */
- L2 = 12.0f; /* Lipshitz constant */
-
- if (mxGetClassID(prhs[0]) != mxSINGLE_CLASS) {mexErrMsgTxt("The input image must be in a single precision"); }
- if ((nrhs == 3) || (nrhs == 4) || (nrhs == 5) || (nrhs == 6)) alpha1 = (float) mxGetScalar(prhs[2]); /* parameter to control the first-order term */
- if ((nrhs == 4) || (nrhs == 5) || (nrhs == 6)) alpha0 = (float) mxGetScalar(prhs[3]); /* parameter to control the second-order term */
- if ((nrhs == 5) || (nrhs == 6)) iter = (int) mxGetScalar(prhs[4]); /* Iterations number */
- if (nrhs == 6) L2 = (float) mxGetScalar(prhs[5]); /* Lipshitz constant */
-
- /*Handling Matlab output data*/
- dimX = dim_array[0]; dimY = dim_array[1]; dimZ = dim_array[2];
-
- if (number_of_dims == 2) {
- dimZ = 1; /*2D case*/
- Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(2, dim_array, mxSINGLE_CLASS, mxREAL));
- }
- if (number_of_dims == 3) Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(3, dim_array, mxSINGLE_CLASS, mxREAL));
-
- /* running the function */
- TGV_GPU_main(Input, Output, lambda, alpha1, alpha0, iter, L2, dimX, dimY, dimZ);
-}
diff --git a/Wrappers/Matlab/supp/RMSE.m b/Wrappers/Matlab/supp/RMSE.m
deleted file mode 100644
index 002f776..0000000
--- a/Wrappers/Matlab/supp/RMSE.m
+++ /dev/null
@@ -1,7 +0,0 @@
-function err = RMSE(signal1, signal2)
-%RMSE Root Mean Squared Error
-
-err = sum((signal1 - signal2).^2)/length(signal1); % MSE
-err = sqrt(err); % RMSE
-
-end \ No newline at end of file
diff --git a/Wrappers/Matlab/supp/my_red_yellowMAP.mat b/Wrappers/Matlab/supp/my_red_yellowMAP.mat
deleted file mode 100644
index c2a5b87..0000000
--- a/Wrappers/Matlab/supp/my_red_yellowMAP.mat
+++ /dev/null
Binary files differ
diff --git a/Wrappers/Python/CMakeLists.txt b/Wrappers/Python/CMakeLists.txt
deleted file mode 100644
index c2ef855..0000000
--- a/Wrappers/Python/CMakeLists.txt
+++ /dev/null
@@ -1,141 +0,0 @@
-# Copyright 2018 Edoardo Pasca
-cmake_minimum_required (VERSION 3.0)
-
-project(regulariserPython)
-#https://stackoverflow.com/questions/13298504/using-cmake-with-setup-py
-
-# The version number.
-
-#set (CIL_VERSION $ENV{CIL_VERSION} CACHE INTERNAL "Core Imaging Library version" FORCE)
-
-# conda orchestrated build
-message("CIL_VERSION: ${CIL_VERSION}")
-#include (GenerateExportHeader)
-
-find_package(PythonInterp REQUIRED)
-if (PYTHONINTERP_FOUND)
- message ("Current Python " ${PYTHON_VERSION_STRING} " found " ${PYTHON_EXECUTABLE})
-endif()
-
-
-## Build the regularisers package as a library
-message("Creating Regularisers as shared library")
-
-message("CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}")
-
-set(CMAKE_BUILD_TYPE "Release")
-
-if(WIN32)
- set (FLAGS "/DWIN32 /EHsc /openmp /DCCPiCore_EXPORTS")
- set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:MSVCRT.lib")
-
- set (EXTRA_LIBRARIES)
-
- message("library lib: ${LIBRARY_LIB}")
-
-elseif(UNIX)
- set (FLAGS "-fopenmp -O2 -funsigned-char -Wall -Wl,--no-undefined -DCCPiReconstructionIterative_EXPORTS -std=c++0x")
- set (EXTRA_LIBRARIES
- "gomp"
- )
-endif()
-
-# GPU regularisers
-if (BUILD_CUDA)
- find_package(CUDA)
- if (CUDA_FOUND)
- message("CUDA FOUND")
- set (SETUP_GPU_WRAPPERS "extra_libraries += ['cilregcuda']\n\
-setup( \n\
- name='ccpi', \n\
- description='CCPi Core Imaging Library - Image regularisers GPU',\n\
- version=cil_version,\n\
- cmdclass = {'build_ext': build_ext},\n\
- ext_modules = [Extension('ccpi.filters.gpu_regularisers',\n\
- sources=[ \n\
- os.path.join('.' , 'src', 'gpu_regularisers.pyx' ),\n\
- ],\n\
- include_dirs=extra_include_dirs, \n\
- library_dirs=extra_library_dirs, \n\
- extra_compile_args=extra_compile_args, \n\
- libraries=extra_libraries ), \n\
- ],\n\
- zip_safe = False, \n\
- packages = {'ccpi','ccpi.filters'},\n\
- )")
- else()
- message("CUDA NOT FOUND")
- set(SETUP_GPU_WRAPPERS "#CUDA NOT FOUND")
- endif()
-endif()
-configure_file("${CMAKE_CURRENT_SOURCE_DIR}/setup-regularisers.py.in" "${CMAKE_CURRENT_BINARY_DIR}/setup-regularisers.py")
-
-
-find_package(PythonInterp)
-find_package(PythonLibs)
-if (PYTHONINTERP_FOUND)
- message(STATUS "Found PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}")
- message(STATUS "Python version ${PYTHON_VERSION_STRING}")
-endif()
-if (PYTHONLIBS_FOUND)
- message(STATUS "Found PYTHON_INCLUDE_DIRS=${PYTHON_INCLUDE_DIRS}")
- message(STATUS "Found PYTHON_LIBRARIES=${PYTHON_LIBRARIES}")
-endif()
-
-if (PYTHONINTERP_FOUND)
- message("Python found " ${PYTHON_EXECUTABLE})
- set(SETUP_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/setup-regularisers.py.in")
- set(SETUP_PY "${CMAKE_CURRENT_BINARY_DIR}/setup-regularisers.py")
- #set(DEPS "${CMAKE_CURRENT_SOURCE_DIR}/module/__init__.py")
- set (DEPS "${CMAKE_BINARY_DIR}/Core/")
- set(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/build/timestamp")
-
- configure_file(${SETUP_PY_IN} ${SETUP_PY})
-
- message("Core binary dir " ${CMAKE_BINARY_DIR}/Core/${CMAKE_BUILD_TYPE})
-
- if (CONDA_BUILD)
- add_custom_command(OUTPUT ${OUTPUT}
- COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src
- COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/ccpi ${CMAKE_CURRENT_BINARY_DIR}/ccpi
- COMMAND ${CMAKE_COMMAND} -E env CIL_VERSION=${CIL_VERSION}
- PREFIX=${CMAKE_SOURCE_DIR}/Core
- LIBRARY_INC=${CMAKE_SOURCE_DIR}/Core
- LIBRARY_LIB=${CMAKE_BINARY_DIR}/Core
- ${PYTHON_EXECUTABLE} ${SETUP_PY} install
- COMMAND ${CMAKE_COMMAND} -E touch ${OUTPUT}
- DEPENDS cilreg)
-
- else()
- if (WIN32)
- add_custom_command(OUTPUT ${OUTPUT}
- COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src
- COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/ccpi ${CMAKE_CURRENT_BINARY_DIR}/ccpi
- COMMAND ${CMAKE_COMMAND} -E env CIL_VERSION=${CIL_VERSION}
- PREFIX=${CMAKE_SOURCE_DIR}/Core
- LIBRARY_INC=${CMAKE_SOURCE_DIR}/Core
- LIBRARY_LIB=${CMAKE_BINARY_DIR}/Core/${CMAKE_BUILD_TYPE}
- ${PYTHON_EXECUTABLE} ${SETUP_PY} build_ext --inplace
- COMMAND ${CMAKE_COMMAND} -E touch ${OUTPUT}
- DEPENDS cilreg)
- else()
- add_custom_command(OUTPUT ${OUTPUT}
- COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src
- COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/ccpi ${CMAKE_CURRENT_BINARY_DIR}/ccpi
- COMMAND ${CMAKE_COMMAND} -E env CIL_VERSION=${CIL_VERSION}
- PREFIX=${CMAKE_SOURCE_DIR}/Core
- LIBRARY_INC=${CMAKE_SOURCE_DIR}/Core
- LIBRARY_LIB=${CMAKE_BINARY_DIR}/Core
- ${PYTHON_EXECUTABLE} ${SETUP_PY} build_ext --inplace
- COMMAND ${CMAKE_COMMAND} -E touch ${OUTPUT}
- DEPENDS cilreg)
- endif()
- install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ccpi
- DESTINATION ${PYTHON_DEST})
- endif()
-
-
- add_custom_target(PythonWrapper ALL DEPENDS ${OUTPUT})
-
- #install(CODE "execute_process(COMMAND ${PYTHON} ${SETUP_PY} install)")
-endif()
diff --git a/Wrappers/Python/ccpi/__init__.py b/Wrappers/Python/ccpi/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/Wrappers/Python/ccpi/__init__.py
+++ /dev/null
diff --git a/Wrappers/Python/ccpi/filters/__init__.py b/Wrappers/Python/ccpi/filters/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/Wrappers/Python/ccpi/filters/__init__.py
+++ /dev/null
diff --git a/Wrappers/Python/ccpi/filters/regularisers.py b/Wrappers/Python/ccpi/filters/regularisers.py
deleted file mode 100644
index 588ea32..0000000
--- a/Wrappers/Python/ccpi/filters/regularisers.py
+++ /dev/null
@@ -1,214 +0,0 @@
-"""
-script which assigns a proper device core function based on a flag ('cpu' or 'gpu')
-"""
-
-from ccpi.filters.cpu_regularisers import TV_ROF_CPU, TV_FGP_CPU, TV_SB_CPU, dTV_FGP_CPU, TNV_CPU, NDF_CPU, Diff4th_CPU, TGV_CPU, LLT_ROF_CPU, PATCHSEL_CPU, NLTV_CPU
-try:
- from ccpi.filters.gpu_regularisers import TV_ROF_GPU, TV_FGP_GPU, TV_SB_GPU, dTV_FGP_GPU, NDF_GPU, Diff4th_GPU, TGV_GPU, LLT_ROF_GPU, PATCHSEL_GPU
- gpu_enabled = True
-except ImportError:
- gpu_enabled = False
-from ccpi.filters.cpu_regularisers import NDF_INPAINT_CPU, NVM_INPAINT_CPU
-
-def ROF_TV(inputData, regularisation_parameter, iterations,
- time_marching_parameter,device='cpu'):
- if device == 'cpu':
- return TV_ROF_CPU(inputData,
- regularisation_parameter,
- iterations,
- time_marching_parameter)
- elif device == 'gpu' and gpu_enabled:
- return TV_ROF_GPU(inputData,
- regularisation_parameter,
- iterations,
- time_marching_parameter)
- else:
- if not gpu_enabled and device == 'gpu':
- raise ValueError ('GPU is not available')
- raise ValueError('Unknown device {0}. Expecting gpu or cpu'\
- .format(device))
-
-def FGP_TV(inputData, regularisation_parameter,iterations,
- tolerance_param, methodTV, nonneg, printM, device='cpu'):
- if device == 'cpu':
- return TV_FGP_CPU(inputData,
- regularisation_parameter,
- iterations,
- tolerance_param,
- methodTV,
- nonneg,
- printM)
- elif device == 'gpu' and gpu_enabled:
- return TV_FGP_GPU(inputData,
- regularisation_parameter,
- iterations,
- tolerance_param,
- methodTV,
- nonneg,
- printM)
- else:
- if not gpu_enabled and device == 'gpu':
- raise ValueError ('GPU is not available')
- raise ValueError('Unknown device {0}. Expecting gpu or cpu'\
- .format(device))
-def SB_TV(inputData, regularisation_parameter, iterations,
- tolerance_param, methodTV, printM, device='cpu'):
- if device == 'cpu':
- return TV_SB_CPU(inputData,
- regularisation_parameter,
- iterations,
- tolerance_param,
- methodTV,
- printM)
- elif device == 'gpu' and gpu_enabled:
- return TV_SB_GPU(inputData,
- regularisation_parameter,
- iterations,
- tolerance_param,
- methodTV,
- printM)
- else:
- if not gpu_enabled and device == 'gpu':
- raise ValueError ('GPU is not available')
- raise ValueError('Unknown device {0}. Expecting gpu or cpu'\
- .format(device))
-def FGP_dTV(inputData, refdata, regularisation_parameter, iterations,
- tolerance_param, eta_const, methodTV, nonneg, printM, device='cpu'):
- if device == 'cpu':
- return dTV_FGP_CPU(inputData,
- refdata,
- regularisation_parameter,
- iterations,
- tolerance_param,
- eta_const,
- methodTV,
- nonneg,
- printM)
- elif device == 'gpu' and gpu_enabled:
- return dTV_FGP_GPU(inputData,
- refdata,
- regularisation_parameter,
- iterations,
- tolerance_param,
- eta_const,
- methodTV,
- nonneg,
- printM)
- else:
- if not gpu_enabled and device == 'gpu':
- raise ValueError ('GPU is not available')
- raise ValueError('Unknown device {0}. Expecting gpu or cpu'\
- .format(device))
-def TNV(inputData, regularisation_parameter, iterations, tolerance_param):
- return TNV_CPU(inputData,
- regularisation_parameter,
- iterations,
- tolerance_param)
-def NDF(inputData, regularisation_parameter, edge_parameter, iterations,
- time_marching_parameter, penalty_type, device='cpu'):
- if device == 'cpu':
- return NDF_CPU(inputData,
- regularisation_parameter,
- edge_parameter,
- iterations,
- time_marching_parameter,
- penalty_type)
- elif device == 'gpu' and gpu_enabled:
- return NDF_GPU(inputData,
- regularisation_parameter,
- edge_parameter,
- iterations,
- time_marching_parameter,
- penalty_type)
- else:
- if not gpu_enabled and device == 'gpu':
- raise ValueError ('GPU is not available')
- raise ValueError('Unknown device {0}. Expecting gpu or cpu'\
- .format(device))
-def Diff4th(inputData, regularisation_parameter, edge_parameter, iterations,
- time_marching_parameter, device='cpu'):
- if device == 'cpu':
- return Diff4th_CPU(inputData,
- regularisation_parameter,
- edge_parameter,
- iterations,
- time_marching_parameter)
- elif device == 'gpu' and gpu_enabled:
- return Diff4th_GPU(inputData,
- regularisation_parameter,
- edge_parameter,
- iterations,
- time_marching_parameter)
- else:
- if not gpu_enabled and device == 'gpu':
- raise ValueError ('GPU is not available')
- raise ValueError('Unknown device {0}. Expecting gpu or cpu'\
- .format(device))
-
-def PatchSelect(inputData, searchwindow, patchwindow, neighbours, edge_parameter, device='cpu'):
- if device == 'cpu':
- return PATCHSEL_CPU(inputData,
- searchwindow,
- patchwindow,
- neighbours,
- edge_parameter)
- elif device == 'gpu' and gpu_enabled:
- return PATCHSEL_GPU(inputData,
- searchwindow,
- patchwindow,
- neighbours,
- edge_parameter)
- else:
- if not gpu_enabled and device == 'gpu':
- raise ValueError ('GPU is not available')
- raise ValueError('Unknown device {0}. Expecting gpu or cpu'\
- .format(device))
-
-def NLTV(inputData, H_i, H_j, H_k, Weights, regularisation_parameter, iterations):
- return NLTV_CPU(inputData,
- H_i,
- H_j,
- H_k,
- Weights,
- regularisation_parameter,
- iterations)
-
-def TGV(inputData, regularisation_parameter, alpha1, alpha0, iterations,
- LipshitzConst, device='cpu'):
- if device == 'cpu':
- return TGV_CPU(inputData,
- regularisation_parameter,
- alpha1,
- alpha0,
- iterations,
- LipshitzConst)
- elif device == 'gpu' and gpu_enabled:
- return TGV_GPU(inputData,
- regularisation_parameter,
- alpha1,
- alpha0,
- iterations,
- LipshitzConst)
- else:
- if not gpu_enabled and device == 'gpu':
- raise ValueError ('GPU is not available')
- raise ValueError('Unknown device {0}. Expecting gpu or cpu'\
- .format(device))
-def LLT_ROF(inputData, regularisation_parameterROF, regularisation_parameterLLT, iterations,
- time_marching_parameter, device='cpu'):
- if device == 'cpu':
- return LLT_ROF_CPU(inputData, regularisation_parameterROF, regularisation_parameterLLT, iterations, time_marching_parameter)
- elif device == 'gpu' and gpu_enabled:
- return LLT_ROF_GPU(inputData, regularisation_parameterROF, regularisation_parameterLLT, iterations, time_marching_parameter)
- else:
- if not gpu_enabled and device == 'gpu':
- raise ValueError ('GPU is not available')
- raise ValueError('Unknown device {0}. Expecting gpu or cpu'\
- .format(device))
-def NDF_INP(inputData, maskData, regularisation_parameter, edge_parameter, iterations,
- time_marching_parameter, penalty_type):
- return NDF_INPAINT_CPU(inputData, maskData, regularisation_parameter,
- edge_parameter, iterations, time_marching_parameter, penalty_type)
-
-def NVM_INP(inputData, maskData, SW_increment, iterations):
- return NVM_INPAINT_CPU(inputData, maskData, SW_increment, iterations)
diff --git a/Wrappers/Python/ccpi/supp/__init__.py b/Wrappers/Python/ccpi/supp/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/Wrappers/Python/ccpi/supp/__init__.py
+++ /dev/null
diff --git a/Wrappers/Python/ccpi/supp/qualitymetrics.py b/Wrappers/Python/ccpi/supp/qualitymetrics.py
deleted file mode 100644
index f44d832..0000000
--- a/Wrappers/Python/ccpi/supp/qualitymetrics.py
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/usr/bin/env python2
-# -*- coding: utf-8 -*-
-"""
-A class for some standard image quality metrics
-"""
-import numpy as np
-
-class QualityTools:
- def __init__(self, im1, im2):
- if im1.size != im2.size:
- print ('Error: Sizes of images/volumes are different')
- raise SystemExit
- self.im1 = im1 # image or volume - 1
- self.im2 = im2 # image or volume - 2
- def nrmse(self):
- """ Normalised Root Mean Square Error """
- rmse = np.sqrt(np.sum((self.im2 - self.im1) ** 2) / float(self.im1.size))
- max_val = max(np.max(self.im1), np.max(self.im2))
- min_val = min(np.min(self.im1), np.min(self.im2))
- return 1 - (rmse / (max_val - min_val))
- def rmse(self):
- """ Root Mean Square Error """
- rmse = np.sqrt(np.sum((self.im1 - self.im2) ** 2) / float(self.im1.size))
- return rmse
- def ssim(self, window, k=(0.01, 0.03), l=255):
- from scipy.signal import fftconvolve
- """See https://ece.uwaterloo.ca/~z70wang/research/ssim/"""
- # Check if the window is smaller than the images.
- for a, b in zip(window.shape, self.im1.shape):
- if a > b:
- return None, None
- # Values in k must be positive according to the base implementation.
- for ki in k:
- if ki < 0:
- return None, None
-
- c1 = (k[0] * l) ** 2
- c2 = (k[1] * l) ** 2
- window = window/np.sum(window)
-
- mu1 = fftconvolve(self.im1, window, mode='valid')
- mu2 = fftconvolve(self.im2, window, mode='valid')
- mu1_sq = mu1 * mu1
- mu2_sq = mu2 * mu2
- mu1_mu2 = mu1 * mu2
- sigma1_sq = fftconvolve(self.im1 * self.im1, window, mode='valid') - mu1_sq
- sigma2_sq = fftconvolve(self.im2 * self.im2, window, mode='valid') - mu2_sq
- sigma12 = fftconvolve(self.im1 * self.im2, window, mode='valid') - mu1_mu2
-
- if c1 > 0 and c2 > 0:
- num = (2 * mu1_mu2 + c1) * (2 * sigma12 + c2)
- den = (mu1_sq + mu2_sq + c1) * (sigma1_sq + sigma2_sq + c2)
- ssim_map = num / den
- else:
- num1 = 2 * mu1_mu2 + c1
- num2 = 2 * sigma12 + c2
- den1 = mu1_sq + mu2_sq + c1
- den2 = sigma1_sq + sigma2_sq + c2
- ssim_map = np.ones(np.shape(mu1))
- index = (den1 * den2) > 0
- ssim_map[index] = (num1[index] * num2[index]) / (den1[index] * den2[index])
- index = (den1 != 0) & (den2 == 0)
- ssim_map[index] = num1[index] / den1[index]
- mssim = ssim_map.mean()
- return mssim, ssim_map
diff --git a/Wrappers/Python/conda-recipe/bld.bat b/Wrappers/Python/conda-recipe/bld.bat
deleted file mode 100644
index 6c84355..0000000
--- a/Wrappers/Python/conda-recipe/bld.bat
+++ /dev/null
@@ -1,20 +0,0 @@
-IF NOT DEFINED CIL_VERSION (
-ECHO CIL_VERSION Not Defined.
-exit 1
-)
-
-mkdir "%SRC_DIR%\ccpi"
-ROBOCOPY /E "%RECIPE_DIR%\..\.." "%SRC_DIR%\ccpi"
-ROBOCOPY /E "%RECIPE_DIR%\..\..\..\Core" "%SRC_DIR%\Core"
-::cd %SRC_DIR%\ccpi\Python
-cd %SRC_DIR%
-
-:: issue cmake to create setup.py
-cmake -G "NMake Makefiles" %RECIPE_DIR%\..\..\..\ -DBUILD_PYTHON_WRAPPERS=ON -DCONDA_BUILD=ON -DBUILD_CUDA=OFF -DCMAKE_BUILD_TYPE="Release" -DLIBRARY_LIB="%CONDA_PREFIX%\lib" -DLIBRARY_INC="%CONDA_PREFIX%" -DCMAKE_INSTALL_PREFIX="%PREFIX%\Library"
-
-::%PYTHON% setup-regularisers.py build_ext
-::if errorlevel 1 exit 1
-::%PYTHON% setup-regularisers.py install
-::if errorlevel 1 exit 1
-nmake install
-if errorlevel 1 exit 1 \ No newline at end of file
diff --git a/Wrappers/Python/conda-recipe/build.sh b/Wrappers/Python/conda-recipe/build.sh
deleted file mode 100644
index 39c0f2c..0000000
--- a/Wrappers/Python/conda-recipe/build.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-
-mkdir "$SRC_DIR/ccpi"
-cp -rv "$RECIPE_DIR/../.." "$SRC_DIR/ccpi"
-cp -rv "$RECIPE_DIR/../../../Core" "$SRC_DIR/Core"
-
-cd $SRC_DIR
-##cuda=off
-
-cmake -G "Unix Makefiles" $RECIPE_DIR/../../../ -DBUILD_PYTHON_WRAPPER=ON -DCONDA_BUILD=ON -DBUILD_CUDA=ON -DCMAKE_BUILD_TYPE="Release" -DLIBRARY_LIB=$CONDA_PREFIX/lib -DLIBRARY_INC=$CONDA_PREFIX -DCMAKE_INSTALL_PREFIX=$PREFIX
-
-
-make install
-
-#$PYTHON setup-regularisers.py build_ext
-#$PYTHON setup-regularisers.py install
-
-
diff --git a/Wrappers/Python/conda-recipe/conda_build_config.yaml b/Wrappers/Python/conda-recipe/conda_build_config.yaml
deleted file mode 100644
index fbe82dc..0000000
--- a/Wrappers/Python/conda-recipe/conda_build_config.yaml
+++ /dev/null
@@ -1,9 +0,0 @@
-python:
- - 2.7 # [not win]
- - 3.5
- - 3.6
-# - 3.7
-numpy:
- - 1.12
- - 1.14
- - 1.15
diff --git a/Wrappers/Python/conda-recipe/lena_gray_512.tif b/Wrappers/Python/conda-recipe/lena_gray_512.tif
deleted file mode 100644
index f80cafc..0000000
--- a/Wrappers/Python/conda-recipe/lena_gray_512.tif
+++ /dev/null
Binary files differ
diff --git a/Wrappers/Python/conda-recipe/meta.yaml b/Wrappers/Python/conda-recipe/meta.yaml
deleted file mode 100644
index 7435b2b..0000000
--- a/Wrappers/Python/conda-recipe/meta.yaml
+++ /dev/null
@@ -1,40 +0,0 @@
-package:
- name: ccpi-regulariser
- version: {{CIL_VERSION}}
-
-build:
- preserve_egg_dir: False
- number: 0
- script_env:
- - CIL_VERSION
-
-test:
- files:
- - lena_gray_512.tif
- requires:
- - pillow=4.1.1
-
-requirements:
- build:
- - python
- - numpy {{ numpy }}
- - setuptools
- - cython
- - vc 14 # [win and py36]
- - vc 14 # [win and py35]
- - vc 9 # [win and py27]
- - cmake
-
- run:
- - {{ pin_compatible('numpy', max_pin='x.x') }}
- - python
- - numpy
- - vc 14 # [win and py36]
- - vc 14 # [win and py35]
- - vc 9 # [win and py27]
- - libgcc-ng
-
-about:
- home: http://www.ccpi.ac.uk
- license: BSD license
- summary: 'CCPi Core Imaging Library Quantification Toolbox'
diff --git a/Wrappers/Python/conda-recipe/run_test.py b/Wrappers/Python/conda-recipe/run_test.py
deleted file mode 100755
index 21f3216..0000000
--- a/Wrappers/Python/conda-recipe/run_test.py
+++ /dev/null
@@ -1,819 +0,0 @@
-import unittest
-import numpy as np
-import os
-import timeit
-from ccpi.filters.regularisers import ROF_TV, FGP_TV, SB_TV, TGV, LLT_ROF, FGP_dTV, NDF, Diff4th
-from PIL import Image
-
-class TiffReader(object):
- def imread(self, filename):
- return np.asarray(Image.open(filename))
-###############################################################################
-def printParametersToString(pars):
- txt = r''
- for key, value in pars.items():
- if key== 'algorithm' :
- txt += "{0} = {1}".format(key, value.__name__)
- elif key == 'input':
- txt += "{0} = {1}".format(key, np.shape(value))
- elif key == 'refdata':
- txt += "{0} = {1}".format(key, np.shape(value))
- else:
- txt += "{0} = {1}".format(key, value)
- txt += '\n'
- return txt
-def nrmse(im1, im2):
- rmse = np.sqrt(np.sum((im2 - im1) ** 2) / float(im1.size))
- max_val = max(np.max(im1), np.max(im2))
- min_val = min(np.min(im1), np.min(im2))
- return 1 - (rmse / (max_val - min_val))
-
-def rmse(im1, im2):
- rmse = np.sqrt(np.sum((im1 - im2) ** 2) / float(im1.size))
- return rmse
-###############################################################################
-
-class TestRegularisers(unittest.TestCase):
-
-
- def test_ROF_TV_CPU_vs_GPU(self):
- #print ("tomas debug test function")
- print(__name__)
- filename = os.path.join("lena_gray_512.tif")
- plt = TiffReader()
- # read image
- Im = plt.imread(filename)
- Im = np.asarray(Im, dtype='float32')
-
- Im = Im/255
- perc = 0.05
- u0 = Im + np.random.normal(loc = 0 ,
- scale = perc * Im ,
- size = np.shape(Im))
- u_ref = Im + np.random.normal(loc = 0 ,
- scale = 0.01 * Im ,
- size = np.shape(Im))
-
- # map the u0 u0->u0>0
- # f = np.frompyfunc(lambda x: 0 if x < 0 else x, 1,1)
- u0 = u0.astype('float32')
- u_ref = u_ref.astype('float32')
-
- print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
- print ("____________ROF-TV bench___________________")
- print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
- # set parameters
- pars = {'algorithm': ROF_TV, \
- 'input' : u0,\
- 'regularisation_parameter':0.04,\
- 'number_of_iterations': 2500,\
- 'time_marching_parameter': 0.00002
- }
- print ("#############ROF TV CPU####################")
- start_time = timeit.default_timer()
- rof_cpu = ROF_TV(pars['input'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'],'cpu')
- rms = rmse(Im, rof_cpu)
- pars['rmse'] = rms
-
- txtstr = printParametersToString(pars)
- txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
- print (txtstr)
- print ("##############ROF TV GPU##################")
- start_time = timeit.default_timer()
- try:
- rof_gpu = ROF_TV(pars['input'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'],'gpu')
- except ValueError as ve:
- self.skipTest("Results not comparable. GPU computing error.")
-
- rms = rmse(Im, rof_gpu)
- pars['rmse'] = rms
- pars['algorithm'] = ROF_TV
- txtstr = printParametersToString(pars)
- txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
- print (txtstr)
- print ("--------Compare the results--------")
- tolerance = 1e-04
- diff_im = np.zeros(np.shape(rof_cpu))
- diff_im = abs(rof_cpu - rof_gpu)
- diff_im[diff_im > tolerance] = 1
- self.assertLessEqual(diff_im.sum() , 1)
-
- def test_FGP_TV_CPU_vs_GPU(self):
- print(__name__)
- filename = os.path.join("lena_gray_512.tif")
- plt = TiffReader()
- # read image
- Im = plt.imread(filename)
- Im = np.asarray(Im, dtype='float32')
-
- Im = Im/255
- perc = 0.05
- u0 = Im + np.random.normal(loc = 0 ,
- scale = perc * Im ,
- size = np.shape(Im))
- u_ref = Im + np.random.normal(loc = 0 ,
- scale = 0.01 * Im ,
- size = np.shape(Im))
-
- # map the u0 u0->u0>0
- # f = np.frompyfunc(lambda x: 0 if x < 0 else x, 1,1)
- u0 = u0.astype('float32')
- u_ref = u_ref.astype('float32')
-
- print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
- print ("____________FGP-TV bench___________________")
- print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-
- # set parameters
- pars = {'algorithm' : FGP_TV, \
- 'input' : u0,\
- 'regularisation_parameter':0.04, \
- 'number_of_iterations' :1200 ,\
- 'tolerance_constant':0.00001,\
- 'methodTV': 0 ,\
- 'nonneg': 0 ,\
- 'printingOut': 0
- }
-
- print ("#############FGP TV CPU####################")
- start_time = timeit.default_timer()
- fgp_cpu = FGP_TV(pars['input'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['tolerance_constant'],
- pars['methodTV'],
- pars['nonneg'],
- pars['printingOut'],'cpu')
-
-
- rms = rmse(Im, fgp_cpu)
- pars['rmse'] = rms
-
- txtstr = printParametersToString(pars)
- txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
- print (txtstr)
-
- print ("##############FGP TV GPU##################")
- start_time = timeit.default_timer()
- try:
- fgp_gpu = FGP_TV(pars['input'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['tolerance_constant'],
- pars['methodTV'],
- pars['nonneg'],
- pars['printingOut'],'gpu')
-
- except ValueError as ve:
- self.skipTest("Results not comparable. GPU computing error.")
-
- rms = rmse(Im, fgp_gpu)
- pars['rmse'] = rms
- pars['algorithm'] = FGP_TV
- txtstr = printParametersToString(pars)
- txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
- print (txtstr)
-
- print ("--------Compare the results--------")
- tolerance = 1e-05
- diff_im = np.zeros(np.shape(fgp_cpu))
- diff_im = abs(fgp_cpu - fgp_gpu)
- diff_im[diff_im > tolerance] = 1
-
- self.assertLessEqual(diff_im.sum() , 1)
-
- def test_SB_TV_CPU_vs_GPU(self):
- print(__name__)
- filename = os.path.join("lena_gray_512.tif")
- plt = TiffReader()
- # read image
- Im = plt.imread(filename)
- Im = np.asarray(Im, dtype='float32')
-
- Im = Im/255
- perc = 0.05
- u0 = Im + np.random.normal(loc = 0 ,
- scale = perc * Im ,
- size = np.shape(Im))
- u_ref = Im + np.random.normal(loc = 0 ,
- scale = 0.01 * Im ,
- size = np.shape(Im))
-
- # map the u0 u0->u0>0
- # f = np.frompyfunc(lambda x: 0 if x < 0 else x, 1,1)
- u0 = u0.astype('float32')
- u_ref = u_ref.astype('float32')
-
- print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
- print ("____________SB-TV bench___________________")
- print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-
- # set parameters
- pars = {'algorithm' : SB_TV, \
- 'input' : u0,\
- 'regularisation_parameter':0.04, \
- 'number_of_iterations' :150 ,\
- 'tolerance_constant':1e-05,\
- 'methodTV': 0 ,\
- 'printingOut': 0
- }
-
- print ("#############SB-TV CPU####################")
- start_time = timeit.default_timer()
- sb_cpu = SB_TV(pars['input'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['tolerance_constant'],
- pars['methodTV'],
- pars['printingOut'],'cpu')
-
-
- rms = rmse(Im, sb_cpu)
- pars['rmse'] = rms
-
- txtstr = printParametersToString(pars)
- txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
- print (txtstr)
-
- print ("##############SB TV GPU##################")
- start_time = timeit.default_timer()
- try:
-
- sb_gpu = SB_TV(pars['input'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['tolerance_constant'],
- pars['methodTV'],
- pars['printingOut'],'gpu')
-
- except ValueError as ve:
- self.skipTest("Results not comparable. GPU computing error.")
-
- rms = rmse(Im, sb_gpu)
- pars['rmse'] = rms
- pars['algorithm'] = SB_TV
- txtstr = printParametersToString(pars)
- txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
- print (txtstr)
- print ("--------Compare the results--------")
- tolerance = 1e-05
- diff_im = np.zeros(np.shape(sb_cpu))
- diff_im = abs(sb_cpu - sb_gpu)
- diff_im[diff_im > tolerance] = 1
- self.assertLessEqual(diff_im.sum(), 1)
-
- def test_TGV_CPU_vs_GPU(self):
- print(__name__)
- filename = os.path.join("lena_gray_512.tif")
- plt = TiffReader()
- # read image
- Im = plt.imread(filename)
- Im = np.asarray(Im, dtype='float32')
-
- Im = Im/255
- perc = 0.05
- u0 = Im + np.random.normal(loc = 0 ,
- scale = perc * Im ,
- size = np.shape(Im))
- u_ref = Im + np.random.normal(loc = 0 ,
- scale = 0.01 * Im ,
- size = np.shape(Im))
-
- # map the u0 u0->u0>0
- # f = np.frompyfunc(lambda x: 0 if x < 0 else x, 1,1)
- u0 = u0.astype('float32')
- u_ref = u_ref.astype('float32')
-
- print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
- print ("____________TGV bench___________________")
- print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-
- # set parameters
- pars = {'algorithm' : TGV, \
- 'input' : u0,\
- 'regularisation_parameter':0.04, \
- 'alpha1':1.0,\
- 'alpha0':2.0,\
- 'number_of_iterations' :250 ,\
- 'LipshitzConstant' :12 ,\
- }
-
- print ("#############TGV CPU####################")
- start_time = timeit.default_timer()
- tgv_cpu = TGV(pars['input'],
- pars['regularisation_parameter'],
- pars['alpha1'],
- pars['alpha0'],
- pars['number_of_iterations'],
- pars['LipshitzConstant'],'cpu')
-
- rms = rmse(Im, tgv_cpu)
- pars['rmse'] = rms
-
- txtstr = printParametersToString(pars)
- txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
- print (txtstr)
-
- print ("##############TGV GPU##################")
- start_time = timeit.default_timer()
- try:
- tgv_gpu = TGV(pars['input'],
- pars['regularisation_parameter'],
- pars['alpha1'],
- pars['alpha0'],
- pars['number_of_iterations'],
- pars['LipshitzConstant'],'gpu')
-
- except ValueError as ve:
- self.skipTest("Results not comparable. GPU computing error.")
-
- rms = rmse(Im, tgv_gpu)
- pars['rmse'] = rms
- pars['algorithm'] = TGV
- txtstr = printParametersToString(pars)
- txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
- print (txtstr)
- print ("--------Compare the results--------")
- tolerance = 1e-05
- diff_im = np.zeros(np.shape(tgv_gpu))
- diff_im = abs(tgv_cpu - tgv_gpu)
- diff_im[diff_im > tolerance] = 1
- self.assertLessEqual(diff_im.sum() , 1)
-
- def test_LLT_ROF_CPU_vs_GPU(self):
- print(__name__)
- filename = os.path.join("lena_gray_512.tif")
- plt = TiffReader()
- # read image
- Im = plt.imread(filename)
- Im = np.asarray(Im, dtype='float32')
-
- Im = Im/255
- perc = 0.05
- u0 = Im + np.random.normal(loc = 0 ,
- scale = perc * Im ,
- size = np.shape(Im))
- u_ref = Im + np.random.normal(loc = 0 ,
- scale = 0.01 * Im ,
- size = np.shape(Im))
-
- # map the u0 u0->u0>0
- # f = np.frompyfunc(lambda x: 0 if x < 0 else x, 1,1)
- u0 = u0.astype('float32')
- u_ref = u_ref.astype('float32')
-
- print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
- print ("____________LLT-ROF bench___________________")
- print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-
- # set parameters
- pars = {'algorithm' : LLT_ROF, \
- 'input' : u0,\
- 'regularisation_parameterROF':0.04, \
- 'regularisation_parameterLLT':0.01, \
- 'number_of_iterations' :1000 ,\
- 'time_marching_parameter' :0.0001 ,\
- }
-
- print ("#############LLT- ROF CPU####################")
- start_time = timeit.default_timer()
- lltrof_cpu = LLT_ROF(pars['input'],
- pars['regularisation_parameterROF'],
- pars['regularisation_parameterLLT'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'],'cpu')
-
- rms = rmse(Im, lltrof_cpu)
- pars['rmse'] = rms
-
- txtstr = printParametersToString(pars)
- txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
- print (txtstr)
- print ("#############LLT- ROF GPU####################")
- start_time = timeit.default_timer()
- try:
- lltrof_gpu = LLT_ROF(pars['input'],
- pars['regularisation_parameterROF'],
- pars['regularisation_parameterLLT'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'],'gpu')
-
- except ValueError as ve:
- self.skipTest("Results not comparable. GPU computing error.")
-
- rms = rmse(Im, lltrof_gpu)
- pars['rmse'] = rms
- pars['algorithm'] = LLT_ROF
- txtstr = printParametersToString(pars)
- txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
- print (txtstr)
- print ("--------Compare the results--------")
- tolerance = 1e-04
- diff_im = np.zeros(np.shape(lltrof_gpu))
- diff_im = abs(lltrof_cpu - lltrof_gpu)
- diff_im[diff_im > tolerance] = 1
- self.assertLessEqual(diff_im.sum(), 1)
-
- def test_NDF_CPU_vs_GPU(self):
- print(__name__)
- filename = os.path.join("lena_gray_512.tif")
- plt = TiffReader()
- # read image
- Im = plt.imread(filename)
- Im = np.asarray(Im, dtype='float32')
-
- Im = Im/255
- perc = 0.05
- u0 = Im + np.random.normal(loc = 0 ,
- scale = perc * Im ,
- size = np.shape(Im))
- u_ref = Im + np.random.normal(loc = 0 ,
- scale = 0.01 * Im ,
- size = np.shape(Im))
-
- # map the u0 u0->u0>0
- # f = np.frompyfunc(lambda x: 0 if x < 0 else x, 1,1)
- u0 = u0.astype('float32')
- u_ref = u_ref.astype('float32')
-
- print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
- print ("_______________NDF bench___________________")
- print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-
- # set parameters
- pars = {'algorithm' : NDF, \
- 'input' : u0,\
- 'regularisation_parameter':0.06, \
- 'edge_parameter':0.04,\
- 'number_of_iterations' :1000 ,\
- 'time_marching_parameter':0.025,\
- 'penalty_type': 1
- }
-
- print ("#############NDF CPU####################")
- start_time = timeit.default_timer()
- ndf_cpu = NDF(pars['input'],
- pars['regularisation_parameter'],
- pars['edge_parameter'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'],
- pars['penalty_type'],'cpu')
-
- rms = rmse(Im, ndf_cpu)
- pars['rmse'] = rms
-
- txtstr = printParametersToString(pars)
- txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
- print (txtstr)
-
- print ("##############NDF GPU##################")
- start_time = timeit.default_timer()
- try:
- ndf_gpu = NDF(pars['input'],
- pars['regularisation_parameter'],
- pars['edge_parameter'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'],
- pars['penalty_type'],'gpu')
-
- except ValueError as ve:
- self.skipTest("Results not comparable. GPU computing error.")
- rms = rmse(Im, ndf_gpu)
- pars['rmse'] = rms
- pars['algorithm'] = NDF
- txtstr = printParametersToString(pars)
- txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
- print (txtstr)
- print ("--------Compare the results--------")
- tolerance = 1e-05
- diff_im = np.zeros(np.shape(ndf_cpu))
- diff_im = abs(ndf_cpu - ndf_gpu)
- diff_im[diff_im > tolerance] = 1
- self.assertLessEqual(diff_im.sum(), 1)
-
-
- def test_Diff4th_CPU_vs_GPU(self):
- filename = os.path.join("lena_gray_512.tif")
- plt = TiffReader()
- # read image
- Im = plt.imread(filename)
- Im = np.asarray(Im, dtype='float32')
-
- Im = Im/255
- perc = 0.05
- u0 = Im + np.random.normal(loc = 0 ,
- scale = perc * Im ,
- size = np.shape(Im))
- u_ref = Im + np.random.normal(loc = 0 ,
- scale = 0.01 * Im ,
- size = np.shape(Im))
-
- # map the u0 u0->u0>0
- # f = np.frompyfunc(lambda x: 0 if x < 0 else x, 1,1)
- u0 = u0.astype('float32')
- u_ref = u_ref.astype('float32')
-
- print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
- print ("___Anisotropic Diffusion 4th Order (2D)____")
- print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
- # set parameters
- pars = {'algorithm' : Diff4th, \
- 'input' : u0,\
- 'regularisation_parameter':3.5, \
- 'edge_parameter':0.02,\
- 'number_of_iterations' :500 ,\
- 'time_marching_parameter':0.001
- }
-
- print ("#############Diff4th CPU####################")
- start_time = timeit.default_timer()
- diff4th_cpu = Diff4th(pars['input'],
- pars['regularisation_parameter'],
- pars['edge_parameter'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'],'cpu')
-
- rms = rmse(Im, diff4th_cpu)
- pars['rmse'] = rms
-
- txtstr = printParametersToString(pars)
- txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
- print (txtstr)
- print ("##############Diff4th GPU##################")
- start_time = timeit.default_timer()
- try:
- diff4th_gpu = Diff4th(pars['input'],
- pars['regularisation_parameter'],
- pars['edge_parameter'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'], 'gpu')
-
- except ValueError as ve:
- self.skipTest("Results not comparable. GPU computing error.")
- rms = rmse(Im, diff4th_gpu)
- pars['rmse'] = rms
- pars['algorithm'] = Diff4th
- txtstr = printParametersToString(pars)
- txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
- print (txtstr)
- print ("--------Compare the results--------")
- tolerance = 1e-05
- diff_im = np.zeros(np.shape(diff4th_cpu))
- diff_im = abs(diff4th_cpu - diff4th_gpu)
- diff_im[diff_im > tolerance] = 1
- self.assertLessEqual(diff_im.sum() , 1)
-
- def test_FDGdTV_CPU_vs_GPU(self):
- filename = os.path.join("lena_gray_512.tif")
- plt = TiffReader()
- # read image
- Im = plt.imread(filename)
- Im = np.asarray(Im, dtype='float32')
-
- Im = Im/255
- perc = 0.05
- u0 = Im + np.random.normal(loc = 0 ,
- scale = perc * Im ,
- size = np.shape(Im))
- u_ref = Im + np.random.normal(loc = 0 ,
- scale = 0.01 * Im ,
- size = np.shape(Im))
-
- # map the u0 u0->u0>0
- # f = np.frompyfunc(lambda x: 0 if x < 0 else x, 1,1)
- u0 = u0.astype('float32')
- u_ref = u_ref.astype('float32')
-
-
- print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
- print ("____________FGP-dTV bench___________________")
- print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
- # set parameters
- pars = {'algorithm' : FGP_dTV, \
- 'input' : u0,\
- 'refdata' : u_ref,\
- 'regularisation_parameter':0.04, \
- 'number_of_iterations' :1000 ,\
- 'tolerance_constant':1e-07,\
- 'eta_const':0.2,\
- 'methodTV': 0 ,\
- 'nonneg': 0 ,\
- 'printingOut': 0
- }
-
- print ("#############FGP dTV CPU####################")
- start_time = timeit.default_timer()
- fgp_dtv_cpu = FGP_dTV(pars['input'],
- pars['refdata'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['tolerance_constant'],
- pars['eta_const'],
- pars['methodTV'],
- pars['nonneg'],
- pars['printingOut'],'cpu')
-
-
- rms = rmse(Im, fgp_dtv_cpu)
- pars['rmse'] = rms
-
- txtstr = printParametersToString(pars)
- txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
- print (txtstr)
- print ("##############FGP dTV GPU##################")
- start_time = timeit.default_timer()
- try:
- fgp_dtv_gpu = FGP_dTV(pars['input'],
- pars['refdata'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['tolerance_constant'],
- pars['eta_const'],
- pars['methodTV'],
- pars['nonneg'],
- pars['printingOut'],'gpu')
- except ValueError as ve:
- self.skipTest("Results not comparable. GPU computing error.")
- rms = rmse(Im, fgp_dtv_gpu)
- pars['rmse'] = rms
- pars['algorithm'] = FGP_dTV
- txtstr = printParametersToString(pars)
- txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
- print (txtstr)
- print ("--------Compare the results--------")
- tolerance = 1e-05
- diff_im = np.zeros(np.shape(fgp_dtv_cpu))
- diff_im = abs(fgp_dtv_cpu - fgp_dtv_gpu)
- diff_im[diff_im > tolerance] = 1
- self.assertLessEqual(diff_im.sum(), 1)
-
- def test_cpu_ROF_TV(self):
- #filename = os.path.join(".." , ".." , ".." , "data" ,"testLena.npy")
-
- filename = os.path.join("lena_gray_512.tif")
-
- plt = TiffReader()
- # read image
- Im = plt.imread(filename)
- Im = np.asarray(Im, dtype='float32')
- Im = Im/255
-
- """
- # read noiseless image
- Im = plt.imread(filename)
- Im = np.asarray(Im, dtype='float32')
- """
- tolerance = 1e-05
- rms_rof_exp = 8.313131464999238e-05 #expected value for ROF model
-
- # set parameters for ROF-TV
- pars_rof_tv = {'algorithm': ROF_TV, \
- 'input' : Im,\
- 'regularisation_parameter':0.04,\
- 'number_of_iterations': 50,\
- 'time_marching_parameter': 0.00001
- }
- print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
- print ("_________testing ROF-TV (2D, CPU)__________")
- print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
- rof_cpu = ROF_TV(pars_rof_tv['input'],
- pars_rof_tv['regularisation_parameter'],
- pars_rof_tv['number_of_iterations'],
- pars_rof_tv['time_marching_parameter'],'cpu')
- rms_rof = rmse(Im, rof_cpu)
-
- # now compare obtained rms with the expected value
- self.assertLess(abs(rms_rof-rms_rof_exp) , tolerance)
- def test_cpu_FGP_TV(self):
- #filename = os.path.join(".." , ".." , ".." , "data" ,"testLena.npy")
-
- filename = os.path.join("lena_gray_512.tif")
-
- plt = TiffReader()
- # read image
- Im = plt.imread(filename)
- Im = np.asarray(Im, dtype='float32')
- Im = Im/255
- """
- # read noiseless image
- Im = plt.imread(filename)
- Im = np.asarray(Im, dtype='float32')
- """
- tolerance = 1e-05
- rms_fgp_exp = 0.019152347 #expected value for FGP model
-
- pars_fgp_tv = {'algorithm' : FGP_TV, \
- 'input' : Im,\
- 'regularisation_parameter':0.04, \
- 'number_of_iterations' :50 ,\
- 'tolerance_constant':1e-06,\
- 'methodTV': 0 ,\
- 'nonneg': 0 ,\
- 'printingOut': 0
- }
- print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
- print ("_________testing FGP-TV (2D, CPU)__________")
- print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
- fgp_cpu = FGP_TV(pars_fgp_tv['input'],
- pars_fgp_tv['regularisation_parameter'],
- pars_fgp_tv['number_of_iterations'],
- pars_fgp_tv['tolerance_constant'],
- pars_fgp_tv['methodTV'],
- pars_fgp_tv['nonneg'],
- pars_fgp_tv['printingOut'],'cpu')
- rms_fgp = rmse(Im, fgp_cpu)
- # now compare obtained rms with the expected value
- self.assertLess(abs(rms_fgp-rms_fgp_exp) , tolerance)
-
- def test_gpu_ROF(self):
- #filename = os.path.join(".." , ".." , ".." , "data" ,"testLena.npy")
- filename = os.path.join("lena_gray_512.tif")
-
- plt = TiffReader()
- # read image
- Im = plt.imread(filename)
- Im = np.asarray(Im, dtype='float32')
- Im = Im/255
-
- tolerance = 1e-05
- rms_rof_exp = 8.313131464999238e-05 #expected value for ROF model
-
- # set parameters for ROF-TV
- pars_rof_tv = {'algorithm': ROF_TV, \
- 'input' : Im,\
- 'regularisation_parameter':0.04,\
- 'number_of_iterations': 50,\
- 'time_marching_parameter': 0.00001
- }
- print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
- print ("_________testing ROF-TV (2D, GPU)__________")
- print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
- try:
- rof_gpu = ROF_TV(pars_rof_tv['input'],
- pars_rof_tv['regularisation_parameter'],
- pars_rof_tv['number_of_iterations'],
- pars_rof_tv['time_marching_parameter'],'gpu')
- except ValueError as ve:
- self.skipTest("Results not comparable. GPU computing error.")
-
- rms_rof = rmse(Im, rof_gpu)
- # now compare obtained rms with the expected value
- self.assertLess(abs(rms_rof-rms_rof_exp) , tolerance)
-
- def test_gpu_FGP(self):
- #filename = os.path.join(".." , ".." , ".." , "data" ,"testLena.npy")
- filename = os.path.join("lena_gray_512.tif")
-
- plt = TiffReader()
- # read image
- Im = plt.imread(filename)
- Im = np.asarray(Im, dtype='float32')
- Im = Im/255
- tolerance = 1e-05
-
- rms_fgp_exp = 0.019152347 #expected value for FGP model
-
- # set parameters for FGP-TV
- pars_fgp_tv = {'algorithm' : FGP_TV, \
- 'input' : Im,\
- 'regularisation_parameter':0.04, \
- 'number_of_iterations' :50 ,\
- 'tolerance_constant':1e-06,\
- 'methodTV': 0 ,\
- 'nonneg': 0 ,\
- 'printingOut': 0
- }
- print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
- print ("_________testing FGP-TV (2D, GPU)__________")
- print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
- try:
- fgp_gpu = FGP_TV(pars_fgp_tv['input'],
- pars_fgp_tv['regularisation_parameter'],
- pars_fgp_tv['number_of_iterations'],
- pars_fgp_tv['tolerance_constant'],
- pars_fgp_tv['methodTV'],
- pars_fgp_tv['nonneg'],
- pars_fgp_tv['printingOut'],'gpu')
- except ValueError as ve:
- self.skipTest("Results not comparable. GPU computing error.")
- rms_fgp = rmse(Im, fgp_gpu)
- # now compare obtained rms with the expected value
-
- self.assertLess(abs(rms_fgp-rms_fgp_exp) , tolerance)
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/Wrappers/Python/demos/demo_cpu_inpainters.py b/Wrappers/Python/demos/demo_cpu_inpainters.py
deleted file mode 100644
index c61ea50..0000000
--- a/Wrappers/Python/demos/demo_cpu_inpainters.py
+++ /dev/null
@@ -1,194 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-"""
-Demonstration of CPU inpainters
-@authors: Daniil Kazantsev, Edoardo Pasca
-"""
-
-import matplotlib.pyplot as plt
-import numpy as np
-import os
-import timeit
-from scipy import io
-from ccpi.filters.regularisers import NDF_INP, NVM_INP
-from ccpi.supp.qualitymetrics import QualityTools
-###############################################################################
-def printParametersToString(pars):
- txt = r''
- for key, value in pars.items():
- if key== 'algorithm' :
- txt += "{0} = {1}".format(key, value.__name__)
- elif key == 'input':
- txt += "{0} = {1}".format(key, np.shape(value))
- elif key == 'maskData':
- txt += "{0} = {1}".format(key, np.shape(value))
- else:
- txt += "{0} = {1}".format(key, value)
- txt += '\n'
- return txt
-###############################################################################
-
-# read sinogram and the mask
-filename = os.path.join(".." , ".." , ".." , "data" ,"SinoInpaint.mat")
-sino = io.loadmat(filename)
-sino_full = sino.get('Sinogram')
-Mask = sino.get('Mask')
-[angles_dim,detectors_dim] = sino_full.shape
-sino_full = sino_full/np.max(sino_full)
-#apply mask to sinogram
-sino_cut = sino_full*(1-Mask)
-#sino_cut_new = np.zeros((angles_dim,detectors_dim),'float32')
-#sino_cut_new = sino_cut.copy(order='c')
-#sino_cut_new[:] = sino_cut[:]
-sino_cut_new = np.ascontiguousarray(sino_cut, dtype=np.float32);
-#mask = np.zeros((angles_dim,detectors_dim),'uint8')
-#mask =Mask.copy(order='c')
-#mask[:] = Mask[:]
-mask = np.ascontiguousarray(Mask, dtype=np.uint8);
-
-plt.figure(1)
-plt.subplot(121)
-plt.imshow(sino_cut_new,vmin=0.0, vmax=1)
-plt.title('Missing Data sinogram')
-plt.subplot(122)
-plt.imshow(mask)
-plt.title('Mask')
-plt.show()
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("___Inpainting using linear diffusion (2D)__")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure(2)
-plt.suptitle('Performance of linear inpainting using the CPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Missing data sinogram')
-imgplot = plt.imshow(sino_cut_new,cmap="gray")
-
-# set parameters
-pars = {'algorithm' : NDF_INP, \
- 'input' : sino_cut_new,\
- 'maskData' : mask,\
- 'regularisation_parameter':5000,\
- 'edge_parameter':0,\
- 'number_of_iterations' :5000 ,\
- 'time_marching_parameter':0.000075,\
- 'penalty_type':0
- }
-
-start_time = timeit.default_timer()
-ndf_inp_linear = NDF_INP(pars['input'],
- pars['maskData'],
- pars['regularisation_parameter'],
- pars['edge_parameter'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'],
- pars['penalty_type'])
-
-Qtools = QualityTools(sino_full, ndf_inp_linear)
-pars['rmse'] = Qtools.rmse()
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(ndf_inp_linear, cmap="gray")
-plt.title('{}'.format('Linear diffusion inpainting results'))
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("_Inpainting using nonlinear diffusion (2D)_")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure(3)
-plt.suptitle('Performance of nonlinear diffusion inpainting using the CPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Missing data sinogram')
-imgplot = plt.imshow(sino_cut_new,cmap="gray")
-
-# set parameters
-pars = {'algorithm' : NDF_INP, \
- 'input' : sino_cut_new,\
- 'maskData' : mask,\
- 'regularisation_parameter':80,\
- 'edge_parameter':0.00009,\
- 'number_of_iterations' :1500 ,\
- 'time_marching_parameter':0.000008,\
- 'penalty_type':1
- }
-
-start_time = timeit.default_timer()
-ndf_inp_nonlinear = NDF_INP(pars['input'],
- pars['maskData'],
- pars['regularisation_parameter'],
- pars['edge_parameter'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'],
- pars['penalty_type'])
-
-
-Qtools = QualityTools(sino_full, ndf_inp_nonlinear)
-pars['rmse'] = Qtools.rmse()
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(ndf_inp_nonlinear, cmap="gray")
-plt.title('{}'.format('Nonlinear diffusion inpainting results'))
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("Inpainting using nonlocal vertical marching")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure(4)
-plt.suptitle('Performance of NVM inpainting using the CPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Missing data sinogram')
-imgplot = plt.imshow(sino_cut,cmap="gray")
-
-# set parameters
-pars = {'algorithm' : NVM_INP, \
- 'input' : sino_cut_new,\
- 'maskData' : mask,\
- 'SW_increment': 1,\
- 'number_of_iterations' : 150
- }
-
-start_time = timeit.default_timer()
-(nvm_inp, mask_upd) = NVM_INP(pars['input'],
- pars['maskData'],
- pars['SW_increment'],
- pars['number_of_iterations'])
-
-
-Qtools = QualityTools(sino_full, nvm_inp)
-pars['rmse'] = Qtools.rmse()
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(nvm_inp, cmap="gray")
-plt.title('{}'.format('Nonlocal Vertical Marching inpainting results'))
-#%%
diff --git a/Wrappers/Python/demos/demo_cpu_regularisers.py b/Wrappers/Python/demos/demo_cpu_regularisers.py
deleted file mode 100644
index b8dadf5..0000000
--- a/Wrappers/Python/demos/demo_cpu_regularisers.py
+++ /dev/null
@@ -1,572 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-"""
-Created on Thu Feb 22 11:39:43 2018
-
-Demonstration of CPU regularisers
-
-@authors: Daniil Kazantsev, Edoardo Pasca
-"""
-
-import matplotlib.pyplot as plt
-import numpy as np
-import os
-import timeit
-from ccpi.filters.regularisers import ROF_TV, FGP_TV, SB_TV, TGV, LLT_ROF, FGP_dTV, TNV, NDF, Diff4th
-from ccpi.filters.regularisers import PatchSelect, NLTV
-from ccpi.supp.qualitymetrics import QualityTools
-###############################################################################
-def printParametersToString(pars):
- txt = r''
- for key, value in pars.items():
- if key== 'algorithm' :
- txt += "{0} = {1}".format(key, value.__name__)
- elif key == 'input':
- txt += "{0} = {1}".format(key, np.shape(value))
- elif key == 'refdata':
- txt += "{0} = {1}".format(key, np.shape(value))
- else:
- txt += "{0} = {1}".format(key, value)
- txt += '\n'
- return txt
-###############################################################################
-#%%
-filename = os.path.join(".." , ".." , ".." , "data" ,"lena_gray_512.tif")
-
-# read image
-Im = plt.imread(filename)
-Im = np.asarray(Im, dtype='float32')
-
-Im = Im/255.0
-perc = 0.05
-u0 = Im + np.random.normal(loc = 0 ,
- scale = perc * Im ,
- size = np.shape(Im))
-u_ref = Im + np.random.normal(loc = 0 ,
- scale = 0.01 * Im ,
- size = np.shape(Im))
-(N,M) = np.shape(u0)
-# map the u0 u0->u0>0
-# f = np.frompyfunc(lambda x: 0 if x < 0 else x, 1,1)
-u0 = u0.astype('float32')
-u_ref = u_ref.astype('float32')
-
-# change dims to check that modules work with non-squared images
-"""
-M = M-100
-u_ref2 = np.zeros([N,M],dtype='float32')
-u_ref2[:,0:M] = u_ref[:,0:M]
-u_ref = u_ref2
-del u_ref2
-
-u02 = np.zeros([N,M],dtype='float32')
-u02[:,0:M] = u0[:,0:M]
-u0 = u02
-del u02
-
-Im2 = np.zeros([N,M],dtype='float32')
-Im2[:,0:M] = Im[:,0:M]
-Im = Im2
-del Im2
-"""
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("_______________ROF-TV (2D)_________________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of ROF-TV regulariser using the CPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(u0,cmap="gray")
-
-# set parameters
-pars = {'algorithm': ROF_TV, \
- 'input' : u0,\
- 'regularisation_parameter':0.02,\
- 'number_of_iterations': 2000,\
- 'time_marching_parameter': 0.0025
- }
-print ("#############ROF TV CPU####################")
-start_time = timeit.default_timer()
-rof_cpu = ROF_TV(pars['input'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'],'cpu')
-
-Qtools = QualityTools(Im, rof_cpu)
-pars['rmse'] = Qtools.rmse()
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(rof_cpu, cmap="gray")
-plt.title('{}'.format('CPU results'))
-
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("_______________FGP-TV (2D)__________________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of FGP-TV regulariser using the CPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(u0,cmap="gray")
-
-# set parameters
-pars = {'algorithm' : FGP_TV, \
- 'input' : u0,\
- 'regularisation_parameter':0.04, \
- 'number_of_iterations' :2000 ,\
- 'tolerance_constant':1e-06,\
- 'methodTV': 0 ,\
- 'nonneg': 0 ,\
- 'printingOut': 0
- }
-
-print ("#############FGP TV CPU####################")
-start_time = timeit.default_timer()
-fgp_cpu = FGP_TV(pars['input'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['tolerance_constant'],
- pars['methodTV'],
- pars['nonneg'],
- pars['printingOut'],'cpu')
-
-
-Qtools = QualityTools(Im, fgp_cpu)
-pars['rmse'] = Qtools.rmse()
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(fgp_cpu, cmap="gray")
-plt.title('{}'.format('CPU results'))
-
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("_______________SB-TV (2D)__________________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of SB-TV regulariser using the CPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(u0,cmap="gray")
-
-# set parameters
-pars = {'algorithm' : SB_TV, \
- 'input' : u0,\
- 'regularisation_parameter':0.04, \
- 'number_of_iterations' :150 ,\
- 'tolerance_constant':1e-06,\
- 'methodTV': 0 ,\
- 'printingOut': 0
- }
-
-print ("#############SB TV CPU####################")
-start_time = timeit.default_timer()
-sb_cpu = SB_TV(pars['input'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['tolerance_constant'],
- pars['methodTV'],
- pars['printingOut'],'cpu')
-
-Qtools = QualityTools(Im, sb_cpu)
-pars['rmse'] = Qtools.rmse()
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(sb_cpu, cmap="gray")
-plt.title('{}'.format('CPU results'))
-#%%
-
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("_____Total Generalised Variation (2D)______")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of TGV regulariser using the CPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(u0,cmap="gray")
-
-# set parameters
-pars = {'algorithm' : TGV, \
- 'input' : u0,\
- 'regularisation_parameter':0.04, \
- 'alpha1':1.0,\
- 'alpha0':2.0,\
- 'number_of_iterations' :1350 ,\
- 'LipshitzConstant' :12 ,\
- }
-
-print ("#############TGV CPU####################")
-start_time = timeit.default_timer()
-tgv_cpu = TGV(pars['input'],
- pars['regularisation_parameter'],
- pars['alpha1'],
- pars['alpha0'],
- pars['number_of_iterations'],
- pars['LipshitzConstant'],'cpu')
-
-
-Qtools = QualityTools(Im, tgv_cpu)
-pars['rmse'] = Qtools.rmse()
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(tgv_cpu, cmap="gray")
-plt.title('{}'.format('CPU results'))
-
-#%%
-
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("______________LLT- ROF (2D)________________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of LLT-ROF regulariser using the CPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(u0,cmap="gray")
-
-# set parameters
-pars = {'algorithm' : LLT_ROF, \
- 'input' : u0,\
- 'regularisation_parameterROF':0.04, \
- 'regularisation_parameterLLT':0.01, \
- 'number_of_iterations' :500 ,\
- 'time_marching_parameter' :0.0025 ,\
- }
-
-print ("#############LLT- ROF CPU####################")
-start_time = timeit.default_timer()
-lltrof_cpu = LLT_ROF(pars['input'],
- pars['regularisation_parameterROF'],
- pars['regularisation_parameterLLT'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'],'cpu')
-
-Qtools = QualityTools(Im, lltrof_cpu)
-pars['rmse'] = Qtools.rmse()
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(lltrof_cpu, cmap="gray")
-plt.title('{}'.format('CPU results'))
-
-#%%
-
-
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("________________NDF (2D)___________________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of NDF regulariser using the CPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(u0,cmap="gray")
-
-# set parameters
-pars = {'algorithm' : NDF, \
- 'input' : u0,\
- 'regularisation_parameter':0.025, \
- 'edge_parameter':0.015,\
- 'number_of_iterations' :500 ,\
- 'time_marching_parameter':0.025,\
- 'penalty_type':1
- }
-
-print ("#############NDF CPU################")
-start_time = timeit.default_timer()
-ndf_cpu = NDF(pars['input'],
- pars['regularisation_parameter'],
- pars['edge_parameter'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'],
- pars['penalty_type'],'cpu')
-
-Qtools = QualityTools(Im, ndf_cpu)
-pars['rmse'] = Qtools.rmse()
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(ndf_cpu, cmap="gray")
-plt.title('{}'.format('CPU results'))
-
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("___Anisotropic Diffusion 4th Order (2D)____")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of Diff4th regulariser using the CPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(u0,cmap="gray")
-
-# set parameters
-pars = {'algorithm' : Diff4th, \
- 'input' : u0,\
- 'regularisation_parameter':3.5, \
- 'edge_parameter':0.02,\
- 'number_of_iterations' :500 ,\
- 'time_marching_parameter':0.0015
- }
-
-print ("#############Diff4th CPU################")
-start_time = timeit.default_timer()
-diff4_cpu = Diff4th(pars['input'],
- pars['regularisation_parameter'],
- pars['edge_parameter'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'],'cpu')
-
-Qtools = QualityTools(Im, diff4_cpu)
-pars['rmse'] = Qtools.rmse()
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(diff4_cpu, cmap="gray")
-plt.title('{}'.format('CPU results'))
-
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("___Nonlocal patches pre-calculation____")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-start_time = timeit.default_timer()
-# set parameters
-pars = {'algorithm' : PatchSelect, \
- 'input' : u0,\
- 'searchwindow': 7, \
- 'patchwindow': 2,\
- 'neighbours' : 15 ,\
- 'edge_parameter':0.18}
-
-H_i, H_j, Weights = PatchSelect(pars['input'],
- pars['searchwindow'],
- pars['patchwindow'],
- pars['neighbours'],
- pars['edge_parameter'],'cpu')
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-"""
-plt.figure()
-plt.imshow(Weights[0,:,:],cmap="gray",interpolation="nearest",vmin=0, vmax=1)
-plt.show()
-"""
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("___Nonlocal Total Variation penalty____")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of NLTV regulariser using the CPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(u0,cmap="gray")
-
-pars2 = {'algorithm' : NLTV, \
- 'input' : u0,\
- 'H_i': H_i, \
- 'H_j': H_j,\
- 'H_k' : 0,\
- 'Weights' : Weights,\
- 'regularisation_parameter': 0.04,\
- 'iterations': 3
- }
-start_time = timeit.default_timer()
-nltv_cpu = NLTV(pars2['input'],
- pars2['H_i'],
- pars2['H_j'],
- pars2['H_k'],
- pars2['Weights'],
- pars2['regularisation_parameter'],
- pars2['iterations'])
-
-Qtools = QualityTools(Im, nltv_cpu)
-pars['rmse'] = Qtools.rmse()
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(nltv_cpu, cmap="gray")
-plt.title('{}'.format('CPU results'))
-
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("_____________FGP-dTV (2D)__________________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of FGP-dTV regulariser using the CPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(u0,cmap="gray")
-
-# set parameters
-pars = {'algorithm' : FGP_dTV, \
- 'input' : u0,\
- 'refdata' : u_ref,\
- 'regularisation_parameter':0.04, \
- 'number_of_iterations' :2000 ,\
- 'tolerance_constant':1e-06,\
- 'eta_const':0.2,\
- 'methodTV': 0 ,\
- 'nonneg': 0 ,\
- 'printingOut': 0
- }
-
-print ("#############FGP dTV CPU####################")
-start_time = timeit.default_timer()
-fgp_dtv_cpu = FGP_dTV(pars['input'],
- pars['refdata'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['tolerance_constant'],
- pars['eta_const'],
- pars['methodTV'],
- pars['nonneg'],
- pars['printingOut'],'cpu')
-
-Qtools = QualityTools(Im, fgp_dtv_cpu)
-pars['rmse'] = Qtools.rmse()
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(fgp_dtv_cpu, cmap="gray")
-plt.title('{}'.format('CPU results'))
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("__________Total nuclear Variation__________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of TNV regulariser using the CPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(u0,cmap="gray")
-
-channelsNo = 5
-noisyVol = np.zeros((channelsNo,N,M),dtype='float32')
-idealVol = np.zeros((channelsNo,N,M),dtype='float32')
-
-for i in range (channelsNo):
- noisyVol[i,:,:] = Im + np.random.normal(loc = 0 , scale = perc * Im , size = np.shape(Im))
- idealVol[i,:,:] = Im
-
-# set parameters
-pars = {'algorithm' : TNV, \
- 'input' : noisyVol,\
- 'regularisation_parameter': 0.04, \
- 'number_of_iterations' : 200 ,\
- 'tolerance_constant':1e-05
- }
-
-print ("#############TNV CPU#################")
-start_time = timeit.default_timer()
-tnv_cpu = TNV(pars['input'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['tolerance_constant'])
-
-Qtools = QualityTools(idealVol, tnv_cpu)
-pars['rmse'] = Qtools.rmse()
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(tnv_cpu[3,:,:], cmap="gray")
-plt.title('{}'.format('CPU results'))
diff --git a/Wrappers/Python/demos/demo_cpu_regularisers3D.py b/Wrappers/Python/demos/demo_cpu_regularisers3D.py
deleted file mode 100644
index df8af27..0000000
--- a/Wrappers/Python/demos/demo_cpu_regularisers3D.py
+++ /dev/null
@@ -1,463 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-"""
-Created on Thu Feb 22 11:39:43 2018
-
-Demonstration of 3D CPU regularisers
-
-@authors: Daniil Kazantsev, Edoardo Pasca
-"""
-
-import matplotlib.pyplot as plt
-import numpy as np
-import os
-import timeit
-from ccpi.filters.regularisers import ROF_TV, FGP_TV, SB_TV, TGV, LLT_ROF, FGP_dTV, NDF, Diff4th
-from ccpi.supp.qualitymetrics import QualityTools
-###############################################################################
-def printParametersToString(pars):
- txt = r''
- for key, value in pars.items():
- if key== 'algorithm' :
- txt += "{0} = {1}".format(key, value.__name__)
- elif key == 'input':
- txt += "{0} = {1}".format(key, np.shape(value))
- elif key == 'refdata':
- txt += "{0} = {1}".format(key, np.shape(value))
- else:
- txt += "{0} = {1}".format(key, value)
- txt += '\n'
- return txt
-###############################################################################
-#%%
-filename = os.path.join(".." , ".." , ".." , "data" ,"lena_gray_512.tif")
-
-# read image
-Im = plt.imread(filename)
-Im = np.asarray(Im, dtype='float32')
-
-Im = Im/255
-perc = 0.05
-u0 = Im + np.random.normal(loc = 0 ,
- scale = perc * Im ,
- size = np.shape(Im))
-u_ref = Im + np.random.normal(loc = 0 ,
- scale = 0.01 * Im ,
- size = np.shape(Im))
-(N,M) = np.shape(u0)
-# map the u0 u0->u0>0
-# f = np.frompyfunc(lambda x: 0 if x < 0 else x, 1,1)
-u0 = u0.astype('float32')
-u_ref = u_ref.astype('float32')
-
-# change dims to check that modules work with non-squared images
-"""
-M = M-100
-u_ref2 = np.zeros([N,M],dtype='float32')
-u_ref2[:,0:M] = u_ref[:,0:M]
-u_ref = u_ref2
-del u_ref2
-
-u02 = np.zeros([N,M],dtype='float32')
-u02[:,0:M] = u0[:,0:M]
-u0 = u02
-del u02
-
-Im2 = np.zeros([N,M],dtype='float32')
-Im2[:,0:M] = Im[:,0:M]
-Im = Im2
-del Im2
-"""
-slices = 15
-
-noisyVol = np.zeros((slices,N,M),dtype='float32')
-noisyRef = np.zeros((slices,N,M),dtype='float32')
-idealVol = np.zeros((slices,N,M),dtype='float32')
-
-for i in range (slices):
- noisyVol[i,:,:] = Im + np.random.normal(loc = 0 , scale = perc * Im , size = np.shape(Im))
- noisyRef[i,:,:] = Im + np.random.normal(loc = 0 , scale = 0.01 * Im , size = np.shape(Im))
- idealVol[i,:,:] = Im
-
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("_______________ROF-TV (3D)_________________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of ROF-TV regulariser using the CPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy 15th slice of a volume')
-imgplot = plt.imshow(noisyVol[10,:,:],cmap="gray")
-
-# set parameters
-pars = {'algorithm': ROF_TV, \
- 'input' : noisyVol,\
- 'regularisation_parameter':0.04,\
- 'number_of_iterations': 500,\
- 'time_marching_parameter': 0.0025
- }
-print ("#############ROF TV CPU####################")
-start_time = timeit.default_timer()
-rof_cpu3D = ROF_TV(pars['input'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'],'cpu')
-
-Qtools = QualityTools(idealVol, rof_cpu3D)
-pars['rmse'] = Qtools.rmse()
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(rof_cpu3D[10,:,:], cmap="gray")
-plt.title('{}'.format('Recovered volume on the CPU using ROF-TV'))
-
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("_______________FGP-TV (3D)__________________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of FGP-TV regulariser using the CPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(noisyVol[10,:,:],cmap="gray")
-
-# set parameters
-pars = {'algorithm' : FGP_TV, \
- 'input' : noisyVol,\
- 'regularisation_parameter':0.04, \
- 'number_of_iterations' :300 ,\
- 'tolerance_constant':0.00001,\
- 'methodTV': 0 ,\
- 'nonneg': 0 ,\
- 'printingOut': 0
- }
-
-print ("#############FGP TV CPU####################")
-start_time = timeit.default_timer()
-fgp_cpu3D = FGP_TV(pars['input'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['tolerance_constant'],
- pars['methodTV'],
- pars['nonneg'],
- pars['printingOut'],'cpu')
-
-Qtools = QualityTools(idealVol, fgp_cpu3D)
-pars['rmse'] = Qtools.rmse()
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(fgp_cpu3D[10,:,:], cmap="gray")
-plt.title('{}'.format('Recovered volume on the CPU using FGP-TV'))
-
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("_______________SB-TV (3D)_________________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of SB-TV regulariser using the CPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(noisyVol[10,:,:],cmap="gray")
-
-# set parameters
-pars = {'algorithm' : SB_TV, \
- 'input' : noisyVol,\
- 'regularisation_parameter':0.04, \
- 'number_of_iterations' :150 ,\
- 'tolerance_constant':0.00001,\
- 'methodTV': 0 ,\
- 'printingOut': 0
- }
-
-print ("#############SB TV CPU####################")
-start_time = timeit.default_timer()
-sb_cpu3D = SB_TV(pars['input'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['tolerance_constant'],
- pars['methodTV'],
- pars['printingOut'],'cpu')
-
-
-Qtools = QualityTools(idealVol, sb_cpu3D)
-pars['rmse'] = Qtools.rmse()
-
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(sb_cpu3D[10,:,:], cmap="gray")
-plt.title('{}'.format('Recovered volume on the CPU using SB-TV'))
-
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("_______________LLT-ROF (3D)_________________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of LLT-ROF regulariser using the CPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(noisyVol[10,:,:],cmap="gray")
-
-# set parameters
-pars = {'algorithm' : LLT_ROF, \
- 'input' : noisyVol,\
- 'regularisation_parameterROF':0.04, \
- 'regularisation_parameterLLT':0.015, \
- 'number_of_iterations' :300 ,\
- 'time_marching_parameter' :0.0025 ,\
- }
-
-print ("#############LLT ROF CPU####################")
-start_time = timeit.default_timer()
-lltrof_cpu3D = LLT_ROF(pars['input'],
- pars['regularisation_parameterROF'],
- pars['regularisation_parameterLLT'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'],'cpu')
-
-
-Qtools = QualityTools(idealVol, lltrof_cpu3D)
-pars['rmse'] = Qtools.rmse()
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(lltrof_cpu3D[10,:,:], cmap="gray")
-plt.title('{}'.format('Recovered volume on the CPU using LLT-ROF'))
-
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("_______________TGV (3D)_________________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of TGV regulariser using the CPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(noisyVol[10,:,:],cmap="gray")
-
-# set parameters
-pars = {'algorithm' : TGV, \
- 'input' : noisyVol,\
- 'regularisation_parameter':0.04, \
- 'alpha1':1.0,\
- 'alpha0':2.0,\
- 'number_of_iterations' :250 ,\
- 'LipshitzConstant' :12 ,\
- }
-
-print ("#############TGV CPU####################")
-start_time = timeit.default_timer()
-tgv_cpu3D = TGV(pars['input'],
- pars['regularisation_parameter'],
- pars['alpha1'],
- pars['alpha0'],
- pars['number_of_iterations'],
- pars['LipshitzConstant'],'cpu')
-
-
-Qtools = QualityTools(idealVol, tgv_cpu3D)
-pars['rmse'] = Qtools.rmse()
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(tgv_cpu3D[10,:,:], cmap="gray")
-plt.title('{}'.format('Recovered volume on the CPU using TGV'))
-
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("________________NDF (3D)___________________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of NDF regulariser using the CPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy volume')
-imgplot = plt.imshow(noisyVol[10,:,:],cmap="gray")
-
-# set parameters
-pars = {'algorithm' : NDF, \
- 'input' : noisyVol,\
- 'regularisation_parameter':0.025, \
- 'edge_parameter':0.015,\
- 'number_of_iterations' :500 ,\
- 'time_marching_parameter':0.025,\
- 'penalty_type': 1
- }
-
-print ("#############NDF CPU################")
-start_time = timeit.default_timer()
-ndf_cpu3D = NDF(pars['input'],
- pars['regularisation_parameter'],
- pars['edge_parameter'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'],
- pars['penalty_type'])
-
-
-Qtools = QualityTools(idealVol, ndf_cpu3D)
-pars['rmse'] = Qtools.rmse()
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(ndf_cpu3D[10,:,:], cmap="gray")
-plt.title('{}'.format('Recovered volume on the CPU using NDF iterations'))
-
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("___Anisotropic Diffusion 4th Order (2D)____")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of Diff4th regulariser using the CPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy volume')
-imgplot = plt.imshow(noisyVol[10,:,:],cmap="gray")
-
-# set parameters
-pars = {'algorithm' : Diff4th, \
- 'input' : noisyVol,\
- 'regularisation_parameter':3.5, \
- 'edge_parameter':0.02,\
- 'number_of_iterations' :300 ,\
- 'time_marching_parameter':0.0015
- }
-
-print ("#############Diff4th CPU################")
-start_time = timeit.default_timer()
-diff4th_cpu3D = Diff4th(pars['input'],
- pars['regularisation_parameter'],
- pars['edge_parameter'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'])
-
-
-Qtools = QualityTools(idealVol, diff4th_cpu3D)
-pars['rmse'] = Qtools.rmse()
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(diff4th_cpu3D[10,:,:], cmap="gray")
-plt.title('{}'.format('Recovered volume on the CPU using DIFF4th iterations'))
-
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("_______________FGP-dTV (3D)__________________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of FGP-dTV regulariser using the CPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(noisyVol[10,:,:],cmap="gray")
-
-# set parameters
-pars = {'algorithm' : FGP_dTV,\
- 'input' : noisyVol,\
- 'refdata' : noisyRef,\
- 'regularisation_parameter':0.04, \
- 'number_of_iterations' :300 ,\
- 'tolerance_constant':0.00001,\
- 'eta_const':0.2,\
- 'methodTV': 0 ,\
- 'nonneg': 0 ,\
- 'printingOut': 0
- }
-
-print ("#############FGP dTV CPU####################")
-start_time = timeit.default_timer()
-fgp_dTV_cpu3D = FGP_dTV(pars['input'],
- pars['refdata'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['tolerance_constant'],
- pars['eta_const'],
- pars['methodTV'],
- pars['nonneg'],
- pars['printingOut'],'cpu')
-
-
-Qtools = QualityTools(idealVol, fgp_dTV_cpu3D)
-pars['rmse'] = Qtools.rmse()
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(fgp_dTV_cpu3D[10,:,:], cmap="gray")
-plt.title('{}'.format('Recovered volume on the CPU using FGP-dTV'))
-#%%
diff --git a/Wrappers/Python/demos/demo_cpu_vs_gpu_regularisers.py b/Wrappers/Python/demos/demo_cpu_vs_gpu_regularisers.py
deleted file mode 100644
index 6c4ab5e..0000000
--- a/Wrappers/Python/demos/demo_cpu_vs_gpu_regularisers.py
+++ /dev/null
@@ -1,794 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-"""
-Created on Thu Feb 22 11:39:43 2018
-
-Demonstration of CPU implementation against the GPU one
-
-@authors: Daniil Kazantsev, Edoardo Pasca
-"""
-
-import matplotlib.pyplot as plt
-import numpy as np
-import os
-import timeit
-from ccpi.filters.regularisers import ROF_TV, FGP_TV, SB_TV, TGV, LLT_ROF, FGP_dTV, NDF, Diff4th
-from ccpi.filters.regularisers import PatchSelect
-from ccpi.supp.qualitymetrics import QualityTools
-###############################################################################
-def printParametersToString(pars):
- txt = r''
- for key, value in pars.items():
- if key== 'algorithm' :
- txt += "{0} = {1}".format(key, value.__name__)
- elif key == 'input':
- txt += "{0} = {1}".format(key, np.shape(value))
- elif key == 'refdata':
- txt += "{0} = {1}".format(key, np.shape(value))
- else:
- txt += "{0} = {1}".format(key, value)
- txt += '\n'
- return txt
-###############################################################################
-
-filename = os.path.join(".." , ".." , ".." , "data" ,"lena_gray_512.tif")
-
-# read image
-Im = plt.imread(filename)
-Im = np.asarray(Im, dtype='float32')
-
-Im = Im/255
-perc = 0.05
-u0 = Im + np.random.normal(loc = 0 ,
- scale = perc * Im ,
- size = np.shape(Im))
-u_ref = Im + np.random.normal(loc = 0 ,
- scale = 0.01 * Im ,
- size = np.shape(Im))
-
-# map the u0 u0->u0>0
-# f = np.frompyfunc(lambda x: 0 if x < 0 else x, 1,1)
-u0 = u0.astype('float32')
-u_ref = u_ref.astype('float32')
-
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("____________ROF-TV bench___________________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Comparison of ROF-TV regulariser using CPU and GPU implementations')
-a=fig.add_subplot(1,4,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(u0,cmap="gray")
-
-# set parameters
-pars = {'algorithm': ROF_TV, \
- 'input' : u0,\
- 'regularisation_parameter':0.04,\
- 'number_of_iterations': 4500,\
- 'time_marching_parameter': 0.00002
- }
-print ("#############ROF TV CPU####################")
-start_time = timeit.default_timer()
-rof_cpu = ROF_TV(pars['input'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'],'cpu')
-
-Qtools = QualityTools(Im, rof_cpu)
-pars['rmse'] = Qtools.rmse()
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,4,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(rof_cpu, cmap="gray")
-plt.title('{}'.format('CPU results'))
-
-print ("##############ROF TV GPU##################")
-start_time = timeit.default_timer()
-rof_gpu = ROF_TV(pars['input'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'],'gpu')
-
-Qtools = QualityTools(Im, rof_gpu)
-pars['rmse'] = Qtools.rmse()
-
-pars['algorithm'] = ROF_TV
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,4,3)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(rof_gpu, cmap="gray")
-plt.title('{}'.format('GPU results'))
-
-
-print ("--------Compare the results--------")
-tolerance = 1e-05
-diff_im = np.zeros(np.shape(rof_cpu))
-diff_im = abs(rof_cpu - rof_gpu)
-diff_im[diff_im > tolerance] = 1
-a=fig.add_subplot(1,4,4)
-imgplot = plt.imshow(diff_im, vmin=0, vmax=1, cmap="gray")
-plt.title('{}'.format('Pixels larger threshold difference'))
-if (diff_im.sum() > 1):
- print ("Arrays do not match!")
-else:
- print ("Arrays match")
-
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("____________FGP-TV bench___________________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Comparison of FGP-TV regulariser using CPU and GPU implementations')
-a=fig.add_subplot(1,4,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(u0,cmap="gray")
-
-# set parameters
-pars = {'algorithm' : FGP_TV, \
- 'input' : u0,\
- 'regularisation_parameter':0.04, \
- 'number_of_iterations' :1200 ,\
- 'tolerance_constant':0.00001,\
- 'methodTV': 0 ,\
- 'nonneg': 0 ,\
- 'printingOut': 0
- }
-
-print ("#############FGP TV CPU####################")
-start_time = timeit.default_timer()
-fgp_cpu = FGP_TV(pars['input'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['tolerance_constant'],
- pars['methodTV'],
- pars['nonneg'],
- pars['printingOut'],'cpu')
-
-
-Qtools = QualityTools(Im, fgp_cpu)
-pars['rmse'] = Qtools.rmse()
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,4,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(fgp_cpu, cmap="gray")
-plt.title('{}'.format('CPU results'))
-
-
-print ("##############FGP TV GPU##################")
-start_time = timeit.default_timer()
-fgp_gpu = FGP_TV(pars['input'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['tolerance_constant'],
- pars['methodTV'],
- pars['nonneg'],
- pars['printingOut'],'gpu')
-
-Qtools = QualityTools(Im, fgp_gpu)
-pars['rmse'] = Qtools.rmse()
-
-pars['algorithm'] = FGP_TV
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,4,3)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(fgp_gpu, cmap="gray")
-plt.title('{}'.format('GPU results'))
-
-
-print ("--------Compare the results--------")
-tolerance = 1e-05
-diff_im = np.zeros(np.shape(fgp_cpu))
-diff_im = abs(fgp_cpu - fgp_gpu)
-diff_im[diff_im > tolerance] = 1
-a=fig.add_subplot(1,4,4)
-imgplot = plt.imshow(diff_im, vmin=0, vmax=1, cmap="gray")
-plt.title('{}'.format('Pixels larger threshold difference'))
-if (diff_im.sum() > 1):
- print ("Arrays do not match!")
-else:
- print ("Arrays match")
-
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("____________SB-TV bench___________________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Comparison of SB-TV regulariser using CPU and GPU implementations')
-a=fig.add_subplot(1,4,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(u0,cmap="gray")
-
-# set parameters
-pars = {'algorithm' : SB_TV, \
- 'input' : u0,\
- 'regularisation_parameter':0.04, \
- 'number_of_iterations' :150 ,\
- 'tolerance_constant':1e-05,\
- 'methodTV': 0 ,\
- 'printingOut': 0
- }
-
-print ("#############SB-TV CPU####################")
-start_time = timeit.default_timer()
-sb_cpu = SB_TV(pars['input'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['tolerance_constant'],
- pars['methodTV'],
- pars['printingOut'],'cpu')
-
-
-Qtools = QualityTools(Im, sb_cpu)
-pars['rmse'] = Qtools.rmse()
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,4,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(sb_cpu, cmap="gray")
-plt.title('{}'.format('CPU results'))
-
-
-print ("##############SB TV GPU##################")
-start_time = timeit.default_timer()
-sb_gpu = SB_TV(pars['input'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['tolerance_constant'],
- pars['methodTV'],
- pars['printingOut'],'gpu')
-
-Qtools = QualityTools(Im, sb_gpu)
-pars['rmse'] = Qtools.rmse()
-pars['algorithm'] = SB_TV
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,4,3)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(sb_gpu, cmap="gray")
-plt.title('{}'.format('GPU results'))
-
-print ("--------Compare the results--------")
-tolerance = 1e-05
-diff_im = np.zeros(np.shape(sb_cpu))
-diff_im = abs(sb_cpu - sb_gpu)
-diff_im[diff_im > tolerance] = 1
-a=fig.add_subplot(1,4,4)
-imgplot = plt.imshow(diff_im, vmin=0, vmax=1, cmap="gray")
-plt.title('{}'.format('Pixels larger threshold difference'))
-if (diff_im.sum() > 1):
- print ("Arrays do not match!")
-else:
- print ("Arrays match")
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("____________TGV bench___________________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Comparison of TGV regulariser using CPU and GPU implementations')
-a=fig.add_subplot(1,4,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(u0,cmap="gray")
-
-# set parameters
-pars = {'algorithm' : TGV, \
- 'input' : u0,\
- 'regularisation_parameter':0.04, \
- 'alpha1':1.0,\
- 'alpha0':2.0,\
- 'number_of_iterations' :400 ,\
- 'LipshitzConstant' :12 ,\
- }
-
-print ("#############TGV CPU####################")
-start_time = timeit.default_timer()
-tgv_cpu = TGV(pars['input'],
- pars['regularisation_parameter'],
- pars['alpha1'],
- pars['alpha0'],
- pars['number_of_iterations'],
- pars['LipshitzConstant'],'cpu')
-
-Qtools = QualityTools(Im, tgv_cpu)
-pars['rmse'] = Qtools.rmse()
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,4,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(tgv_cpu, cmap="gray")
-plt.title('{}'.format('CPU results'))
-
-print ("##############TGV GPU##################")
-start_time = timeit.default_timer()
-tgv_gpu = TGV(pars['input'],
- pars['regularisation_parameter'],
- pars['alpha1'],
- pars['alpha0'],
- pars['number_of_iterations'],
- pars['LipshitzConstant'],'gpu')
-
-Qtools = QualityTools(Im, tgv_gpu)
-pars['rmse'] = Qtools.rmse()
-pars['algorithm'] = TGV
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,4,3)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(tgv_gpu, cmap="gray")
-plt.title('{}'.format('GPU results'))
-
-print ("--------Compare the results--------")
-tolerance = 1e-05
-diff_im = np.zeros(np.shape(tgv_gpu))
-diff_im = abs(tgv_cpu - tgv_gpu)
-diff_im[diff_im > tolerance] = 1
-a=fig.add_subplot(1,4,4)
-imgplot = plt.imshow(diff_im, vmin=0, vmax=1, cmap="gray")
-plt.title('{}'.format('Pixels larger threshold difference'))
-if (diff_im.sum() > 1):
- print ("Arrays do not match!")
-else:
- print ("Arrays match")
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("____________LLT-ROF bench___________________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Comparison of LLT-ROF regulariser using CPU and GPU implementations')
-a=fig.add_subplot(1,4,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(u0,cmap="gray")
-
-# set parameters
-pars = {'algorithm' : LLT_ROF, \
- 'input' : u0,\
- 'regularisation_parameterROF':0.04, \
- 'regularisation_parameterLLT':0.01, \
- 'number_of_iterations' :4500 ,\
- 'time_marching_parameter' :0.00002 ,\
- }
-
-print ("#############LLT- ROF CPU####################")
-start_time = timeit.default_timer()
-lltrof_cpu = LLT_ROF(pars['input'],
- pars['regularisation_parameterROF'],
- pars['regularisation_parameterLLT'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'],'cpu')
-
-Qtools = QualityTools(Im, lltrof_cpu)
-pars['rmse'] = Qtools.rmse()
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,4,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(lltrof_cpu, cmap="gray")
-plt.title('{}'.format('CPU results'))
-
-print ("#############LLT- ROF GPU####################")
-start_time = timeit.default_timer()
-lltrof_gpu = LLT_ROF(pars['input'],
- pars['regularisation_parameterROF'],
- pars['regularisation_parameterLLT'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'],'gpu')
-
-Qtools = QualityTools(Im, lltrof_gpu)
-pars['rmse'] = Qtools.rmse()
-
-pars['algorithm'] = LLT_ROF
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,4,3)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(lltrof_gpu, cmap="gray")
-plt.title('{}'.format('GPU results'))
-
-print ("--------Compare the results--------")
-tolerance = 1e-05
-diff_im = np.zeros(np.shape(lltrof_gpu))
-diff_im = abs(lltrof_cpu - lltrof_gpu)
-diff_im[diff_im > tolerance] = 1
-a=fig.add_subplot(1,4,4)
-imgplot = plt.imshow(diff_im, vmin=0, vmax=1, cmap="gray")
-plt.title('{}'.format('Pixels larger threshold difference'))
-if (diff_im.sum() > 1):
- print ("Arrays do not match!")
-else:
- print ("Arrays match")
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("_______________NDF bench___________________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Comparison of NDF regulariser using CPU and GPU implementations')
-a=fig.add_subplot(1,4,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(u0,cmap="gray")
-
-# set parameters
-pars = {'algorithm' : NDF, \
- 'input' : u0,\
- 'regularisation_parameter':0.06, \
- 'edge_parameter':0.04,\
- 'number_of_iterations' :1000 ,\
- 'time_marching_parameter':0.025,\
- 'penalty_type': 1
- }
-
-print ("#############NDF CPU####################")
-start_time = timeit.default_timer()
-ndf_cpu = NDF(pars['input'],
- pars['regularisation_parameter'],
- pars['edge_parameter'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'],
- pars['penalty_type'],'cpu')
-
-Qtools = QualityTools(Im, ndf_cpu)
-pars['rmse'] = Qtools.rmse()
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,4,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(ndf_cpu, cmap="gray")
-plt.title('{}'.format('CPU results'))
-
-
-print ("##############NDF GPU##################")
-start_time = timeit.default_timer()
-ndf_gpu = NDF(pars['input'],
- pars['regularisation_parameter'],
- pars['edge_parameter'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'],
- pars['penalty_type'],'gpu')
-
-Qtools = QualityTools(Im, ndf_gpu)
-pars['rmse'] = Qtools.rmse()
-pars['algorithm'] = NDF
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,4,3)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(ndf_gpu, cmap="gray")
-plt.title('{}'.format('GPU results'))
-
-print ("--------Compare the results--------")
-tolerance = 1e-05
-diff_im = np.zeros(np.shape(ndf_cpu))
-diff_im = abs(ndf_cpu - ndf_gpu)
-diff_im[diff_im > tolerance] = 1
-a=fig.add_subplot(1,4,4)
-imgplot = plt.imshow(diff_im, vmin=0, vmax=1, cmap="gray")
-plt.title('{}'.format('Pixels larger threshold difference'))
-if (diff_im.sum() > 1):
- print ("Arrays do not match!")
-else:
- print ("Arrays match")
-
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("___Anisotropic Diffusion 4th Order (2D)____")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Comparison of Diff4th regulariser using CPU and GPU implementations')
-a=fig.add_subplot(1,4,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(u0,cmap="gray")
-
-# set parameters
-pars = {'algorithm' : Diff4th, \
- 'input' : u0,\
- 'regularisation_parameter':3.5, \
- 'edge_parameter':0.02,\
- 'number_of_iterations' :500 ,\
- 'time_marching_parameter':0.001
- }
-
-print ("#############Diff4th CPU####################")
-start_time = timeit.default_timer()
-diff4th_cpu = Diff4th(pars['input'],
- pars['regularisation_parameter'],
- pars['edge_parameter'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'],'cpu')
-
-Qtools = QualityTools(Im, diff4th_cpu)
-pars['rmse'] = Qtools.rmse()
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,4,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(diff4th_cpu, cmap="gray")
-plt.title('{}'.format('CPU results'))
-
-print ("##############Diff4th GPU##################")
-start_time = timeit.default_timer()
-diff4th_gpu = Diff4th(pars['input'],
- pars['regularisation_parameter'],
- pars['edge_parameter'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'], 'gpu')
-
-Qtools = QualityTools(Im, diff4th_gpu)
-pars['rmse'] = Qtools.rmse()
-pars['algorithm'] = Diff4th
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,4,3)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(diff4th_gpu, cmap="gray")
-plt.title('{}'.format('GPU results'))
-
-print ("--------Compare the results--------")
-tolerance = 1e-05
-diff_im = np.zeros(np.shape(diff4th_cpu))
-diff_im = abs(diff4th_cpu - diff4th_gpu)
-diff_im[diff_im > tolerance] = 1
-a=fig.add_subplot(1,4,4)
-imgplot = plt.imshow(diff_im, vmin=0, vmax=1, cmap="gray")
-plt.title('{}'.format('Pixels larger threshold difference'))
-if (diff_im.sum() > 1):
- print ("Arrays do not match!")
-else:
- print ("Arrays match")
-
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("____________FGP-dTV bench___________________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Comparison of FGP-dTV regulariser using CPU and GPU implementations')
-a=fig.add_subplot(1,4,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(u0,cmap="gray")
-
-# set parameters
-pars = {'algorithm' : FGP_dTV, \
- 'input' : u0,\
- 'refdata' : u_ref,\
- 'regularisation_parameter':0.04, \
- 'number_of_iterations' :1000 ,\
- 'tolerance_constant':1e-07,\
- 'eta_const':0.2,\
- 'methodTV': 0 ,\
- 'nonneg': 0 ,\
- 'printingOut': 0
- }
-
-print ("#############FGP dTV CPU####################")
-start_time = timeit.default_timer()
-fgp_dtv_cpu = FGP_dTV(pars['input'],
- pars['refdata'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['tolerance_constant'],
- pars['eta_const'],
- pars['methodTV'],
- pars['nonneg'],
- pars['printingOut'],'cpu')
-
-Qtools = QualityTools(Im, fgp_dtv_cpu)
-pars['rmse'] = Qtools.rmse()
-
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,4,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(fgp_dtv_cpu, cmap="gray")
-plt.title('{}'.format('CPU results'))
-
-print ("##############FGP dTV GPU##################")
-start_time = timeit.default_timer()
-fgp_dtv_gpu = FGP_dTV(pars['input'],
- pars['refdata'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['tolerance_constant'],
- pars['eta_const'],
- pars['methodTV'],
- pars['nonneg'],
- pars['printingOut'],'gpu')
-Qtools = QualityTools(Im, fgp_dtv_gpu)
-pars['rmse'] = Qtools.rmse()
-pars['algorithm'] = FGP_dTV
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,4,3)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(fgp_dtv_gpu, cmap="gray")
-plt.title('{}'.format('GPU results'))
-
-
-print ("--------Compare the results--------")
-tolerance = 1e-05
-diff_im = np.zeros(np.shape(fgp_dtv_cpu))
-diff_im = abs(fgp_dtv_cpu - fgp_dtv_gpu)
-diff_im[diff_im > tolerance] = 1
-a=fig.add_subplot(1,4,4)
-imgplot = plt.imshow(diff_im, vmin=0, vmax=1, cmap="gray")
-plt.title('{}'.format('Pixels larger threshold difference'))
-if (diff_im.sum() > 1):
- print ("Arrays do not match!")
-else:
- print ("Arrays match")
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("____Non-local regularisation bench_________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Comparison of Nonlocal TV regulariser using CPU and GPU implementations')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(u0,cmap="gray")
-
-pars = {'algorithm' : PatchSelect, \
- 'input' : u0,\
- 'searchwindow': 7, \
- 'patchwindow': 2,\
- 'neighbours' : 15 ,\
- 'edge_parameter':0.18}
-
-print ("############## Nonlocal Patches on CPU##################")
-start_time = timeit.default_timer()
-H_i, H_j, WeightsCPU = PatchSelect(pars['input'],
- pars['searchwindow'],
- pars['patchwindow'],
- pars['neighbours'],
- pars['edge_parameter'],'cpu')
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-
-print ("############## Nonlocal Patches on GPU##################")
-start_time = timeit.default_timer()
-start_time = timeit.default_timer()
-H_i, H_j, WeightsGPU = PatchSelect(pars['input'],
- pars['searchwindow'],
- pars['patchwindow'],
- pars['neighbours'],
- pars['edge_parameter'],'gpu')
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-
-print ("--------Compare the results--------")
-tolerance = 1e-05
-diff_im = np.zeros(np.shape(u0))
-diff_im = abs(WeightsCPU[0,:,:] - WeightsGPU[0,:,:])
-diff_im[diff_im > tolerance] = 1
-a=fig.add_subplot(1,2,2)
-imgplot = plt.imshow(diff_im, vmin=0, vmax=1, cmap="gray")
-plt.title('{}'.format('Pixels larger threshold difference'))
-if (diff_im.sum() > 1):
- print ("Arrays do not match!")
-else:
- print ("Arrays match")
-#%% \ No newline at end of file
diff --git a/Wrappers/Python/demos/demo_gpu_regularisers.py b/Wrappers/Python/demos/demo_gpu_regularisers.py
deleted file mode 100644
index 54a1c14..0000000
--- a/Wrappers/Python/demos/demo_gpu_regularisers.py
+++ /dev/null
@@ -1,512 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-"""
-Created on Thu Feb 22 11:39:43 2018
-
-Demonstration of GPU regularisers
-
-@authors: Daniil Kazantsev, Edoardo Pasca
-"""
-
-import matplotlib.pyplot as plt
-import numpy as np
-import os
-import timeit
-from ccpi.filters.regularisers import ROF_TV, FGP_TV, SB_TV, TGV, LLT_ROF, FGP_dTV, NDF, Diff4th
-from ccpi.filters.regularisers import PatchSelect, NLTV
-from ccpi.supp.qualitymetrics import QualityTools
-###############################################################################
-def printParametersToString(pars):
- txt = r''
- for key, value in pars.items():
- if key== 'algorithm' :
- txt += "{0} = {1}".format(key, value.__name__)
- elif key == 'input':
- txt += "{0} = {1}".format(key, np.shape(value))
- elif key == 'refdata':
- txt += "{0} = {1}".format(key, np.shape(value))
- else:
- txt += "{0} = {1}".format(key, value)
- txt += '\n'
- return txt
-###############################################################################
-#%%
-filename = os.path.join(".." , ".." , ".." , "data" ,"lena_gray_512.tif")
-
-# read image
-Im = plt.imread(filename)
-Im = np.asarray(Im, dtype='float32')
-
-Im = Im/255
-perc = 0.05
-u0 = Im + np.random.normal(loc = 0 ,
- scale = perc * Im ,
- size = np.shape(Im))
-u_ref = Im + np.random.normal(loc = 0 ,
- scale = 0.01 * Im ,
- size = np.shape(Im))
-(N,M) = np.shape(u0)
-# map the u0 u0->u0>0
-# f = np.frompyfunc(lambda x: 0 if x < 0 else x, 1,1)
-u0 = u0.astype('float32')
-u_ref = u_ref.astype('float32')
-"""
-M = M-100
-u_ref2 = np.zeros([N,M],dtype='float32')
-u_ref2[:,0:M] = u_ref[:,0:M]
-u_ref = u_ref2
-del u_ref2
-
-u02 = np.zeros([N,M],dtype='float32')
-u02[:,0:M] = u0[:,0:M]
-u0 = u02
-del u02
-
-Im2 = np.zeros([N,M],dtype='float32')
-Im2[:,0:M] = Im[:,0:M]
-Im = Im2
-del Im2
-"""
-#%%
-
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("____________ROF-TV regulariser_____________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of the ROF-TV regulariser using the GPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(u0,cmap="gray")
-
-# set parameters
-pars = {'algorithm': ROF_TV, \
- 'input' : u0,\
- 'regularisation_parameter':0.04,\
- 'number_of_iterations': 1200,\
- 'time_marching_parameter': 0.0025
- }
-print ("##############ROF TV GPU##################")
-start_time = timeit.default_timer()
-rof_gpu = ROF_TV(pars['input'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'],'gpu')
-
-Qtools = QualityTools(Im, rof_gpu)
-pars['rmse'] = Qtools.rmse()
-pars['algorithm'] = ROF_TV
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(rof_gpu, cmap="gray")
-plt.title('{}'.format('GPU results'))
-
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("____________FGP-TV regulariser_____________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of the FGP-TV regulariser using the GPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(u0,cmap="gray")
-
-# set parameters
-pars = {'algorithm' : FGP_TV, \
- 'input' : u0,\
- 'regularisation_parameter':0.04, \
- 'number_of_iterations' :1200 ,\
- 'tolerance_constant':1e-06,\
- 'methodTV': 0 ,\
- 'nonneg': 0 ,\
- 'printingOut': 0
- }
-
-print ("##############FGP TV GPU##################")
-start_time = timeit.default_timer()
-fgp_gpu = FGP_TV(pars['input'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['tolerance_constant'],
- pars['methodTV'],
- pars['nonneg'],
- pars['printingOut'],'gpu')
-Qtools = QualityTools(Im, fgp_gpu)
-pars['rmse'] = Qtools.rmse()
-pars['algorithm'] = FGP_TV
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(fgp_gpu, cmap="gray")
-plt.title('{}'.format('GPU results'))
-
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("____________SB-TV regulariser______________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of the SB-TV regulariser using the GPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(u0,cmap="gray")
-
-# set parameters
-pars = {'algorithm' : SB_TV, \
- 'input' : u0,\
- 'regularisation_parameter':0.04, \
- 'number_of_iterations' :150 ,\
- 'tolerance_constant':1e-06,\
- 'methodTV': 0 ,\
- 'printingOut': 0
- }
-
-print ("##############SB TV GPU##################")
-start_time = timeit.default_timer()
-sb_gpu = SB_TV(pars['input'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['tolerance_constant'],
- pars['methodTV'],
- pars['printingOut'],'gpu')
-
-Qtools = QualityTools(Im, sb_gpu)
-pars['rmse'] = Qtools.rmse()
-pars['algorithm'] = SB_TV
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(sb_gpu, cmap="gray")
-plt.title('{}'.format('GPU results'))
-#%%
-
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("_____Total Generalised Variation (2D)______")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of TGV regulariser using the GPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(u0,cmap="gray")
-
-# set parameters
-pars = {'algorithm' : TGV, \
- 'input' : u0,\
- 'regularisation_parameter':0.04, \
- 'alpha1':1.0,\
- 'alpha0':2.0,\
- 'number_of_iterations' :1250 ,\
- 'LipshitzConstant' :12 ,\
- }
-
-print ("#############TGV CPU####################")
-start_time = timeit.default_timer()
-tgv_gpu = TGV(pars['input'],
- pars['regularisation_parameter'],
- pars['alpha1'],
- pars['alpha0'],
- pars['number_of_iterations'],
- pars['LipshitzConstant'],'gpu')
-
-Qtools = QualityTools(Im, tgv_gpu)
-pars['rmse'] = Qtools.rmse()
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(tgv_gpu, cmap="gray")
-plt.title('{}'.format('GPU results'))
-
-#%%
-
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("______________LLT- ROF (2D)________________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of LLT-ROF regulariser using the GPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(u0,cmap="gray")
-
-# set parameters
-pars = {'algorithm' : LLT_ROF, \
- 'input' : u0,\
- 'regularisation_parameterROF':0.04, \
- 'regularisation_parameterLLT':0.01, \
- 'number_of_iterations' :500 ,\
- 'time_marching_parameter' :0.0025 ,\
- }
-
-print ("#############LLT- ROF GPU####################")
-start_time = timeit.default_timer()
-lltrof_gpu = LLT_ROF(pars['input'],
- pars['regularisation_parameterROF'],
- pars['regularisation_parameterLLT'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'],'gpu')
-
-Qtools = QualityTools(Im, lltrof_gpu)
-pars['rmse'] = Qtools.rmse()
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(lltrof_gpu, cmap="gray")
-plt.title('{}'.format('GPU results'))
-
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("_______________NDF regulariser_____________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of the NDF regulariser using the GPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(u0,cmap="gray")
-
-# set parameters
-pars = {'algorithm' : NDF, \
- 'input' : u0,\
- 'regularisation_parameter':0.025, \
- 'edge_parameter':0.015,\
- 'number_of_iterations' :500 ,\
- 'time_marching_parameter':0.025,\
- 'penalty_type': 1
- }
-
-print ("##############NDF GPU##################")
-start_time = timeit.default_timer()
-ndf_gpu = NDF(pars['input'],
- pars['regularisation_parameter'],
- pars['edge_parameter'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'],
- pars['penalty_type'],'gpu')
-
-Qtools = QualityTools(Im, ndf_gpu)
-pars['rmse'] = Qtools.rmse()
-pars['algorithm'] = NDF
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(ndf_gpu, cmap="gray")
-plt.title('{}'.format('GPU results'))
-
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("___Anisotropic Diffusion 4th Order (2D)____")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of Diff4th regulariser using the GPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(u0,cmap="gray")
-
-# set parameters
-pars = {'algorithm' : Diff4th, \
- 'input' : u0,\
- 'regularisation_parameter':3.5, \
- 'edge_parameter':0.02,\
- 'number_of_iterations' :500 ,\
- 'time_marching_parameter':0.0015
- }
-
-print ("#############DIFF4th CPU################")
-start_time = timeit.default_timer()
-diff4_gpu = Diff4th(pars['input'],
- pars['regularisation_parameter'],
- pars['edge_parameter'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'],'gpu')
-
-Qtools = QualityTools(Im, diff4_gpu)
-pars['algorithm'] = Diff4th
-pars['rmse'] = Qtools.rmse()
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(diff4_gpu, cmap="gray")
-plt.title('{}'.format('GPU results'))
-
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("___Nonlocal patches pre-calculation____")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-start_time = timeit.default_timer()
-# set parameters
-pars = {'algorithm' : PatchSelect, \
- 'input' : u0,\
- 'searchwindow': 7, \
- 'patchwindow': 2,\
- 'neighbours' : 15 ,\
- 'edge_parameter':0.18}
-
-H_i, H_j, Weights = PatchSelect(pars['input'],
- pars['searchwindow'],
- pars['patchwindow'],
- pars['neighbours'],
- pars['edge_parameter'],'gpu')
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-"""
-plt.figure()
-plt.imshow(Weights[0,:,:],cmap="gray",interpolation="nearest",vmin=0, vmax=1)
-plt.show()
-"""
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("___Nonlocal Total Variation penalty____")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of NLTV regulariser using the CPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(u0,cmap="gray")
-
-pars2 = {'algorithm' : NLTV, \
- 'input' : u0,\
- 'H_i': H_i, \
- 'H_j': H_j,\
- 'H_k' : 0,\
- 'Weights' : Weights,\
- 'regularisation_parameter': 0.02,\
- 'iterations': 3
- }
-start_time = timeit.default_timer()
-nltv_cpu = NLTV(pars2['input'],
- pars2['H_i'],
- pars2['H_j'],
- pars2['H_k'],
- pars2['Weights'],
- pars2['regularisation_parameter'],
- pars2['iterations'])
-
-Qtools = QualityTools(Im, nltv_cpu)
-pars['rmse'] = Qtools.rmse()
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(nltv_cpu, cmap="gray")
-plt.title('{}'.format('CPU results'))
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("____________FGP-dTV bench___________________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of the FGP-dTV regulariser using the GPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(u0,cmap="gray")
-
-# set parameters
-pars = {'algorithm' : FGP_dTV, \
- 'input' : u0,\
- 'refdata' : u_ref,\
- 'regularisation_parameter':0.04, \
- 'number_of_iterations' :2000 ,\
- 'tolerance_constant':1e-06,\
- 'eta_const':0.2,\
- 'methodTV': 0 ,\
- 'nonneg': 0 ,\
- 'printingOut': 0
- }
-
-print ("##############FGP dTV GPU##################")
-start_time = timeit.default_timer()
-fgp_dtv_gpu = FGP_dTV(pars['input'],
- pars['refdata'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['tolerance_constant'],
- pars['eta_const'],
- pars['methodTV'],
- pars['nonneg'],
- pars['printingOut'],'gpu')
-
-Qtools = QualityTools(Im, fgp_dtv_gpu)
-pars['rmse'] = Qtools.rmse()
-pars['algorithm'] = FGP_dTV
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(fgp_dtv_gpu, cmap="gray")
-plt.title('{}'.format('GPU results'))
diff --git a/Wrappers/Python/demos/demo_gpu_regularisers3D.py b/Wrappers/Python/demos/demo_gpu_regularisers3D.py
deleted file mode 100644
index d50c08e..0000000
--- a/Wrappers/Python/demos/demo_gpu_regularisers3D.py
+++ /dev/null
@@ -1,455 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-"""
-Created on Thu Feb 22 11:39:43 2018
-
-Demonstration of GPU regularisers
-
-@authors: Daniil Kazantsev, Edoardo Pasca
-"""
-
-import matplotlib.pyplot as plt
-import numpy as np
-import os
-import timeit
-from ccpi.filters.regularisers import ROF_TV, FGP_TV, SB_TV, TGV, LLT_ROF, FGP_dTV, NDF, Diff4th
-from ccpi.supp.qualitymetrics import QualityTools
-###############################################################################
-def printParametersToString(pars):
- txt = r''
- for key, value in pars.items():
- if key== 'algorithm' :
- txt += "{0} = {1}".format(key, value.__name__)
- elif key == 'input':
- txt += "{0} = {1}".format(key, np.shape(value))
- elif key == 'refdata':
- txt += "{0} = {1}".format(key, np.shape(value))
- else:
- txt += "{0} = {1}".format(key, value)
- txt += '\n'
- return txt
-###############################################################################
-#%%
-filename = os.path.join(".." , ".." , ".." , "data" ,"lena_gray_512.tif")
-
-# read image
-Im = plt.imread(filename)
-Im = np.asarray(Im, dtype='float32')
-
-Im = Im/255
-perc = 0.05
-u0 = Im + np.random.normal(loc = 0 ,
- scale = perc * Im ,
- size = np.shape(Im))
-u_ref = Im + np.random.normal(loc = 0 ,
- scale = 0.01 * Im ,
- size = np.shape(Im))
-(N,M) = np.shape(u0)
-# map the u0 u0->u0>0
-# f = np.frompyfunc(lambda x: 0 if x < 0 else x, 1,1)
-u0 = u0.astype('float32')
-u_ref = u_ref.astype('float32')
-"""
-M = M-100
-u_ref2 = np.zeros([N,M],dtype='float32')
-u_ref2[:,0:M] = u_ref[:,0:M]
-u_ref = u_ref2
-del u_ref2
-
-u02 = np.zeros([N,M],dtype='float32')
-u02[:,0:M] = u0[:,0:M]
-u0 = u02
-del u02
-
-Im2 = np.zeros([N,M],dtype='float32')
-Im2[:,0:M] = Im[:,0:M]
-Im = Im2
-del Im2
-"""
-
-
-slices = 20
-
-filename = os.path.join(".." , ".." , ".." , "data" ,"lena_gray_512.tif")
-Im = plt.imread(filename)
-Im = np.asarray(Im, dtype='float32')
-
-Im = Im/255
-perc = 0.05
-
-noisyVol = np.zeros((slices,N,N),dtype='float32')
-noisyRef = np.zeros((slices,N,N),dtype='float32')
-idealVol = np.zeros((slices,N,N),dtype='float32')
-
-for i in range (slices):
- noisyVol[i,:,:] = Im + np.random.normal(loc = 0 , scale = perc * Im , size = np.shape(Im))
- noisyRef[i,:,:] = Im + np.random.normal(loc = 0 , scale = 0.01 * Im , size = np.shape(Im))
- idealVol[i,:,:] = Im
-
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("_______________ROF-TV (3D)_________________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of ROF-TV regulariser using the GPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy 15th slice of a volume')
-imgplot = plt.imshow(noisyVol[10,:,:],cmap="gray")
-
-# set parameters
-pars = {'algorithm': ROF_TV, \
- 'input' : noisyVol,\
- 'regularisation_parameter':0.04,\
- 'number_of_iterations': 500,\
- 'time_marching_parameter': 0.0025
- }
-print ("#############ROF TV GPU####################")
-start_time = timeit.default_timer()
-rof_gpu3D = ROF_TV(pars['input'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'],'gpu')
-
-Qtools = QualityTools(idealVol, rof_gpu3D)
-pars['rmse'] = Qtools.rmse()
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(rof_gpu3D[10,:,:], cmap="gray")
-plt.title('{}'.format('Recovered volume on the GPU using ROF-TV'))
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("_______________FGP-TV (3D)__________________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of FGP-TV regulariser using the GPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(noisyVol[10,:,:],cmap="gray")
-
-# set parameters
-pars = {'algorithm' : FGP_TV, \
- 'input' : noisyVol,\
- 'regularisation_parameter':0.04, \
- 'number_of_iterations' :300 ,\
- 'tolerance_constant':0.00001,\
- 'methodTV': 0 ,\
- 'nonneg': 0 ,\
- 'printingOut': 0
- }
-
-print ("#############FGP TV GPU####################")
-start_time = timeit.default_timer()
-fgp_gpu3D = FGP_TV(pars['input'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['tolerance_constant'],
- pars['methodTV'],
- pars['nonneg'],
- pars['printingOut'],'gpu')
-
-Qtools = QualityTools(idealVol, fgp_gpu3D)
-pars['rmse'] = Qtools.rmse()
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(fgp_gpu3D[10,:,:], cmap="gray")
-plt.title('{}'.format('Recovered volume on the GPU using FGP-TV'))
-
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("_______________SB-TV (3D)__________________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of SB-TV regulariser using the GPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(noisyVol[10,:,:],cmap="gray")
-
-# set parameters
-pars = {'algorithm' : SB_TV, \
- 'input' : noisyVol,\
- 'regularisation_parameter':0.04, \
- 'number_of_iterations' :100 ,\
- 'tolerance_constant':1e-05,\
- 'methodTV': 0 ,\
- 'printingOut': 0
- }
-
-print ("#############SB TV GPU####################")
-start_time = timeit.default_timer()
-sb_gpu3D = SB_TV(pars['input'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['tolerance_constant'],
- pars['methodTV'],
- pars['printingOut'],'gpu')
-
-Qtools = QualityTools(idealVol, sb_gpu3D)
-pars['rmse'] = Qtools.rmse()
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(sb_gpu3D[10,:,:], cmap="gray")
-plt.title('{}'.format('Recovered volume on the GPU using SB-TV'))
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("_______________LLT-ROF (3D)_________________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of LLT-ROF regulariser using the GPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(noisyVol[10,:,:],cmap="gray")
-
-# set parameters
-pars = {'algorithm' : LLT_ROF, \
- 'input' : noisyVol,\
- 'regularisation_parameterROF':0.04, \
- 'regularisation_parameterLLT':0.015, \
- 'number_of_iterations' :300 ,\
- 'time_marching_parameter' :0.0025 ,\
- }
-
-print ("#############LLT ROF CPU####################")
-start_time = timeit.default_timer()
-lltrof_gpu3D = LLT_ROF(pars['input'],
- pars['regularisation_parameterROF'],
- pars['regularisation_parameterLLT'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'],'gpu')
-
-Qtools = QualityTools(idealVol, lltrof_gpu3D)
-pars['rmse'] = Qtools.rmse()
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(lltrof_gpu3D[10,:,:], cmap="gray")
-plt.title('{}'.format('Recovered volume on the GPU using LLT-ROF'))
-
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("_______________TGV (3D)_________________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of TGV regulariser using the GPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(noisyVol[10,:,:],cmap="gray")
-
-# set parameters
-pars = {'algorithm' : TGV, \
- 'input' : noisyVol,\
- 'regularisation_parameter':0.04, \
- 'alpha1':1.0,\
- 'alpha0':2.0,\
- 'number_of_iterations' :600 ,\
- 'LipshitzConstant' :12 ,\
- }
-
-print ("#############TGV GPU####################")
-start_time = timeit.default_timer()
-tgv_gpu3D = TGV(pars['input'],
- pars['regularisation_parameter'],
- pars['alpha1'],
- pars['alpha0'],
- pars['number_of_iterations'],
- pars['LipshitzConstant'],'gpu')
-
-Qtools = QualityTools(idealVol, tgv_gpu3D)
-pars['rmse'] = Qtools.rmse()
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(tgv_gpu3D[10,:,:], cmap="gray")
-plt.title('{}'.format('Recovered volume on the GPU using TGV'))
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("_______________NDF-TV (3D)_________________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of NDF regulariser using the GPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(noisyVol[10,:,:],cmap="gray")
-
-# set parameters
-pars = {'algorithm' : NDF, \
- 'input' : noisyVol,\
- 'regularisation_parameter':0.025, \
- 'edge_parameter':0.015,\
- 'number_of_iterations' :500 ,\
- 'time_marching_parameter':0.025,\
- 'penalty_type': 1
- }
-
-print ("#############NDF GPU####################")
-start_time = timeit.default_timer()
-ndf_gpu3D = NDF(pars['input'],
- pars['regularisation_parameter'],
- pars['edge_parameter'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'],
- pars['penalty_type'],'gpu')
-
-Qtools = QualityTools(idealVol, ndf_gpu3D)
-pars['rmse'] = Qtools.rmse()
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(ndf_gpu3D[10,:,:], cmap="gray")
-plt.title('{}'.format('Recovered volume on the GPU using NDF'))
-
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("___Anisotropic Diffusion 4th Order (3D)____")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of DIFF4th regulariser using the GPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(noisyVol[10,:,:],cmap="gray")
-
-# set parameters
-pars = {'algorithm' : Diff4th, \
- 'input' : noisyVol,\
- 'regularisation_parameter':3.5, \
- 'edge_parameter':0.02,\
- 'number_of_iterations' :300 ,\
- 'time_marching_parameter':0.0015
- }
-
-print ("#############DIFF4th CPU################")
-start_time = timeit.default_timer()
-diff4_gpu3D = Diff4th(pars['input'],
- pars['regularisation_parameter'],
- pars['edge_parameter'],
- pars['number_of_iterations'],
- pars['time_marching_parameter'],'gpu')
-
-Qtools = QualityTools(idealVol, diff4_gpu3D)
-pars['rmse'] = Qtools.rmse()
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(diff4_gpu3D[10,:,:], cmap="gray")
-plt.title('{}'.format('GPU results'))
-
-#%%
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("_______________FGP-dTV (3D)________________")
-print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-
-## plot
-fig = plt.figure()
-plt.suptitle('Performance of FGP-dTV regulariser using the GPU')
-a=fig.add_subplot(1,2,1)
-a.set_title('Noisy Image')
-imgplot = plt.imshow(noisyVol[10,:,:],cmap="gray")
-
-# set parameters
-pars = {'algorithm' : FGP_dTV, \
- 'input' : noisyVol,\
- 'refdata' : noisyRef,\
- 'regularisation_parameter':0.04, \
- 'number_of_iterations' :300 ,\
- 'tolerance_constant':0.00001,\
- 'eta_const':0.2,\
- 'methodTV': 0 ,\
- 'nonneg': 0 ,\
- 'printingOut': 0
- }
-
-print ("#############FGP TV GPU####################")
-start_time = timeit.default_timer()
-fgp_dTV_gpu3D = FGP_dTV(pars['input'],
- pars['refdata'],
- pars['regularisation_parameter'],
- pars['number_of_iterations'],
- pars['tolerance_constant'],
- pars['eta_const'],
- pars['methodTV'],
- pars['nonneg'],
- pars['printingOut'],'gpu')
-
-Qtools = QualityTools(idealVol, fgp_dTV_gpu3D)
-pars['rmse'] = Qtools.rmse()
-
-txtstr = printParametersToString(pars)
-txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
-print (txtstr)
-a=fig.add_subplot(1,2,2)
-
-# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
-# place a text box in upper left in axes coords
-a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14,
- verticalalignment='top', bbox=props)
-imgplot = plt.imshow(fgp_dTV_gpu3D[10,:,:], cmap="gray")
-plt.title('{}'.format('Recovered volume on the GPU using FGP-dTV'))
-#%%
diff --git a/Wrappers/Python/setup-regularisers.py.in b/Wrappers/Python/setup-regularisers.py.in
deleted file mode 100644
index 16fb380..0000000
--- a/Wrappers/Python/setup-regularisers.py.in
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/usr/bin/env python
-
-import setuptools
-from distutils.core import setup
-from distutils.extension import Extension
-from Cython.Distutils import build_ext
-
-import os
-import sys
-import numpy
-import platform
-
-cil_version=os.environ['CIL_VERSION']
-if cil_version == '':
- print("Please set the environmental variable CIL_VERSION")
- sys.exit(1)
-
-library_include_path = ""
-library_lib_path = ""
-try:
- library_include_path = os.environ['LIBRARY_INC']
- library_lib_path = os.environ['LIBRARY_LIB']
-except:
- library_include_path = os.environ['PREFIX']+'/include'
- pass
-
-extra_include_dirs = [numpy.get_include(), library_include_path]
-#extra_library_dirs = [os.path.join(library_include_path, "..", "lib")]
-extra_compile_args = []
-extra_library_dirs = [library_lib_path]
-extra_compile_args = []
-extra_link_args = []
-extra_libraries = ['cilreg']
-
-print ("extra_library_dirs " , extra_library_dirs)
-
-extra_include_dirs += [os.path.join(".." , ".." , "Core"),
- os.path.join(".." , ".." , "Core", "regularisers_CPU"),
- os.path.join(".." , ".." , "Core", "inpainters_CPU"),
- os.path.join(".." , ".." , "Core", "regularisers_GPU" , "TV_FGP" ) ,
- os.path.join(".." , ".." , "Core", "regularisers_GPU" , "TV_ROF" ) ,
- os.path.join(".." , ".." , "Core", "regularisers_GPU" , "TV_SB" ) ,
- os.path.join(".." , ".." , "Core", "regularisers_GPU" , "TGV" ) ,
- os.path.join(".." , ".." , "Core", "regularisers_GPU" , "LLTROF" ) ,
- os.path.join(".." , ".." , "Core", "regularisers_GPU" , "NDF" ) ,
- os.path.join(".." , ".." , "Core", "regularisers_GPU" , "dTV_FGP" ) ,
- os.path.join(".." , ".." , "Core", "regularisers_GPU" , "DIFF4th" ) ,
- os.path.join(".." , ".." , "Core", "regularisers_GPU" , "PatchSelect" ) ,
- "."]
-
-if platform.system() == 'Windows':
- extra_compile_args[0:] = ['/DWIN32','/EHsc','/DBOOST_ALL_NO_LIB' , '/openmp' ]
-else:
- extra_compile_args = ['-fopenmp','-O2', '-funsigned-char', '-Wall', '-std=c++0x']
- extra_libraries += [@EXTRA_OMP_LIB@]
-
-setup(
- name='ccpi',
- description='CCPi Core Imaging Library - Image regularisers',
- version=cil_version,
- cmdclass = {'build_ext': build_ext},
- ext_modules = [Extension("ccpi.filters.cpu_regularisers",
- sources=[os.path.join("." , "src", "cpu_regularisers.pyx" ) ],
- include_dirs=extra_include_dirs,
- library_dirs=extra_library_dirs,
- extra_compile_args=extra_compile_args,
- libraries=extra_libraries ),
-
- ],
- zip_safe = False,
- packages = {'ccpi','ccpi.filters', 'ccpi.supp'},
-)
-
-
-@SETUP_GPU_WRAPPERS@
diff --git a/Wrappers/Python/src/cpu_regularisers.pyx b/Wrappers/Python/src/cpu_regularisers.pyx
deleted file mode 100644
index 11a0617..0000000
--- a/Wrappers/Python/src/cpu_regularisers.pyx
+++ /dev/null
@@ -1,685 +0,0 @@
-# distutils: language=c++
-"""
-Copyright 2018 CCPi
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Author: Edoardo Pasca, Daniil Kazantsev
-"""
-
-import cython
-import numpy as np
-cimport numpy as np
-
-cdef extern float TV_ROF_CPU_main(float *Input, float *Output, float lambdaPar, int iterationsNumb, float tau, int dimX, int dimY, int dimZ);
-cdef extern float TV_FGP_CPU_main(float *Input, float *Output, float lambdaPar, int iterationsNumb, float epsil, int methodTV, int nonneg, int printM, int dimX, int dimY, int dimZ);
-cdef extern float SB_TV_CPU_main(float *Input, float *Output, float lambdaPar, int iterationsNumb, float epsil, int methodTV, int printM, int dimX, int dimY, int dimZ);
-cdef extern float LLT_ROF_CPU_main(float *Input, float *Output, float lambdaROF, float lambdaLLT, int iterationsNumb, float tau, int dimX, int dimY, int dimZ);
-cdef extern float TGV_main(float *Input, float *Output, float lambdaPar, float alpha1, float alpha0, int iterationsNumb, float L2, int dimX, int dimY, int dimZ);
-cdef extern float Diffusion_CPU_main(float *Input, float *Output, float lambdaPar, float sigmaPar, int iterationsNumb, float tau, int penaltytype, int dimX, int dimY, int dimZ);
-cdef extern float Diffus4th_CPU_main(float *Input, float *Output, float lambdaPar, float sigmaPar, int iterationsNumb, float tau, int dimX, int dimY, int dimZ);
-cdef extern float TNV_CPU_main(float *Input, float *u, float lambdaPar, int maxIter, float tol, int dimX, int dimY, int dimZ);
-cdef extern float dTV_FGP_CPU_main(float *Input, float *InputRef, float *Output, float lambdaPar, int iterationsNumb, float epsil, float eta, int methodTV, int nonneg, int printM, int dimX, int dimY, int dimZ);
-cdef extern float PatchSelect_CPU_main(float *Input, unsigned short *H_i, unsigned short *H_j, unsigned short *H_k, float *Weights, int dimX, int dimY, int dimZ, int SearchWindow, int SimilarWin, int NumNeighb, float h, int switchM);
-cdef extern float Nonlocal_TV_CPU_main(float *A_orig, float *Output, unsigned short *H_i, unsigned short *H_j, unsigned short *H_k, float *Weights, int dimX, int dimY, int dimZ, int NumNeighb, float lambdaReg, int IterNumb);
-
-cdef extern float Diffusion_Inpaint_CPU_main(float *Input, unsigned char *Mask, float *Output, float lambdaPar, float sigmaPar, int iterationsNumb, float tau, int penaltytype, int dimX, int dimY, int dimZ);
-cdef extern float NonlocalMarching_Inpaint_main(float *Input, unsigned char *M, float *Output, unsigned char *M_upd, int SW_increment, int iterationsNumb, int trigger, int dimX, int dimY, int dimZ);
-cdef extern float TV_energy2D(float *U, float *U0, float *E_val, float lambdaPar, int type, int dimX, int dimY);
-cdef extern float TV_energy3D(float *U, float *U0, float *E_val, float lambdaPar, int type, int dimX, int dimY, int dimZ);
-#****************************************************************#
-#********************** Total-variation ROF *********************#
-#****************************************************************#
-def TV_ROF_CPU(inputData, regularisation_parameter, iterationsNumb, marching_step_parameter):
- if inputData.ndim == 2:
- return TV_ROF_2D(inputData, regularisation_parameter, iterationsNumb, marching_step_parameter)
- elif inputData.ndim == 3:
- return TV_ROF_3D(inputData, regularisation_parameter, iterationsNumb, marching_step_parameter)
-
-def TV_ROF_2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData,
- float regularisation_parameter,
- int iterationsNumb,
- float marching_step_parameter):
- cdef long dims[2]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
-
- cdef np.ndarray[np.float32_t, ndim=2, mode="c"] outputData = \
- np.zeros([dims[0],dims[1]], dtype='float32')
-
- # Run ROF iterations for 2D data
- TV_ROF_CPU_main(&inputData[0,0], &outputData[0,0], regularisation_parameter, iterationsNumb, marching_step_parameter, dims[1], dims[0], 1)
-
- return outputData
-
-def TV_ROF_3D(np.ndarray[np.float32_t, ndim=3, mode="c"] inputData,
- float regularisation_parameter,
- int iterationsNumb,
- float marching_step_parameter):
- cdef long dims[3]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
- dims[2] = inputData.shape[2]
-
- cdef np.ndarray[np.float32_t, ndim=3, mode="c"] outputData = \
- np.zeros([dims[0],dims[1],dims[2]], dtype='float32')
-
- # Run ROF iterations for 3D data
- TV_ROF_CPU_main(&inputData[0,0,0], &outputData[0,0,0], regularisation_parameter, iterationsNumb, marching_step_parameter, dims[2], dims[1], dims[0])
-
- return outputData
-
-#****************************************************************#
-#********************** Total-variation FGP *********************#
-#****************************************************************#
-#******** Total-variation Fast-Gradient-Projection (FGP)*********#
-def TV_FGP_CPU(inputData, regularisation_parameter, iterationsNumb, tolerance_param, methodTV, nonneg, printM):
- if inputData.ndim == 2:
- return TV_FGP_2D(inputData, regularisation_parameter, iterationsNumb, tolerance_param, methodTV, nonneg, printM)
- elif inputData.ndim == 3:
- return TV_FGP_3D(inputData, regularisation_parameter, iterationsNumb, tolerance_param, methodTV, nonneg, printM)
-
-def TV_FGP_2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData,
- float regularisation_parameter,
- int iterationsNumb,
- float tolerance_param,
- int methodTV,
- int nonneg,
- int printM):
-
- cdef long dims[2]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
-
- cdef np.ndarray[np.float32_t, ndim=2, mode="c"] outputData = \
- np.zeros([dims[0],dims[1]], dtype='float32')
-
- #/* Run FGP-TV iterations for 2D data */
- TV_FGP_CPU_main(&inputData[0,0], &outputData[0,0], regularisation_parameter,
- iterationsNumb,
- tolerance_param,
- methodTV,
- nonneg,
- printM,
- dims[1],dims[0],1)
-
- return outputData
-
-def TV_FGP_3D(np.ndarray[np.float32_t, ndim=3, mode="c"] inputData,
- float regularisation_parameter,
- int iterationsNumb,
- float tolerance_param,
- int methodTV,
- int nonneg,
- int printM):
- cdef long dims[3]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
- dims[2] = inputData.shape[2]
-
- cdef np.ndarray[np.float32_t, ndim=3, mode="c"] outputData = \
- np.zeros([dims[0], dims[1], dims[2]], dtype='float32')
-
- #/* Run FGP-TV iterations for 3D data */
- TV_FGP_CPU_main(&inputData[0,0,0], &outputData[0,0,0], regularisation_parameter,
- iterationsNumb,
- tolerance_param,
- methodTV,
- nonneg,
- printM,
- dims[2], dims[1], dims[0])
- return outputData
-
-#***************************************************************#
-#********************** Total-variation SB *********************#
-#***************************************************************#
-#*************** Total-variation Split Bregman (SB)*************#
-def TV_SB_CPU(inputData, regularisation_parameter, iterationsNumb, tolerance_param, methodTV, printM):
- if inputData.ndim == 2:
- return TV_SB_2D(inputData, regularisation_parameter, iterationsNumb, tolerance_param, methodTV, printM)
- elif inputData.ndim == 3:
- return TV_SB_3D(inputData, regularisation_parameter, iterationsNumb, tolerance_param, methodTV, printM)
-
-def TV_SB_2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData,
- float regularisation_parameter,
- int iterationsNumb,
- float tolerance_param,
- int methodTV,
- int printM):
-
- cdef long dims[2]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
-
- cdef np.ndarray[np.float32_t, ndim=2, mode="c"] outputData = \
- np.zeros([dims[0],dims[1]], dtype='float32')
-
- #/* Run SB-TV iterations for 2D data */
- SB_TV_CPU_main(&inputData[0,0], &outputData[0,0], regularisation_parameter,
- iterationsNumb,
- tolerance_param,
- methodTV,
- printM,
- dims[1],dims[0],1)
-
- return outputData
-
-def TV_SB_3D(np.ndarray[np.float32_t, ndim=3, mode="c"] inputData,
- float regularisation_parameter,
- int iterationsNumb,
- float tolerance_param,
- int methodTV,
- int printM):
- cdef long dims[3]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
- dims[2] = inputData.shape[2]
-
- cdef np.ndarray[np.float32_t, ndim=3, mode="c"] outputData = \
- np.zeros([dims[0], dims[1], dims[2]], dtype='float32')
-
- #/* Run SB-TV iterations for 3D data */
- SB_TV_CPU_main(&inputData[0,0,0], &outputData[0,0,0], regularisation_parameter,
- iterationsNumb,
- tolerance_param,
- methodTV,
- printM,
- dims[2], dims[1], dims[0])
- return outputData
-
-#***************************************************************#
-#***************** Total Generalised Variation *****************#
-#***************************************************************#
-def TGV_CPU(inputData, regularisation_parameter, alpha1, alpha0, iterations, LipshitzConst):
- if inputData.ndim == 2:
- return TGV_2D(inputData, regularisation_parameter, alpha1, alpha0,
- iterations, LipshitzConst)
- elif inputData.ndim == 3:
- return TGV_3D(inputData, regularisation_parameter, alpha1, alpha0,
- iterations, LipshitzConst)
-
-def TGV_2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData,
- float regularisation_parameter,
- float alpha1,
- float alpha0,
- int iterationsNumb,
- float LipshitzConst):
-
- cdef long dims[2]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
-
- cdef np.ndarray[np.float32_t, ndim=2, mode="c"] outputData = \
- np.zeros([dims[0],dims[1]], dtype='float32')
-
- #/* Run TGV iterations for 2D data */
- TGV_main(&inputData[0,0], &outputData[0,0], regularisation_parameter,
- alpha1,
- alpha0,
- iterationsNumb,
- LipshitzConst,
- dims[1],dims[0],1)
- return outputData
-def TGV_3D(np.ndarray[np.float32_t, ndim=3, mode="c"] inputData,
- float regularisation_parameter,
- float alpha1,
- float alpha0,
- int iterationsNumb,
- float LipshitzConst):
-
- cdef long dims[3]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
- dims[2] = inputData.shape[2]
-
- cdef np.ndarray[np.float32_t, ndim=3, mode="c"] outputData = \
- np.zeros([dims[0], dims[1], dims[2]], dtype='float32')
-
- #/* Run TGV iterations for 3D data */
- TGV_main(&inputData[0,0,0], &outputData[0,0,0], regularisation_parameter,
- alpha1,
- alpha0,
- iterationsNumb,
- LipshitzConst,
- dims[2], dims[1], dims[0])
- return outputData
-
-#***************************************************************#
-#******************* ROF - LLT regularisation ******************#
-#***************************************************************#
-def LLT_ROF_CPU(inputData, regularisation_parameterROF, regularisation_parameterLLT, iterations, time_marching_parameter):
- if inputData.ndim == 2:
- return LLT_ROF_2D(inputData, regularisation_parameterROF, regularisation_parameterLLT, iterations, time_marching_parameter)
- elif inputData.ndim == 3:
- return LLT_ROF_3D(inputData, regularisation_parameterROF, regularisation_parameterLLT, iterations, time_marching_parameter)
-
-def LLT_ROF_2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData,
- float regularisation_parameterROF,
- float regularisation_parameterLLT,
- int iterations,
- float time_marching_parameter):
-
- cdef long dims[2]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
-
- cdef np.ndarray[np.float32_t, ndim=2, mode="c"] outputData = \
- np.zeros([dims[0],dims[1]], dtype='float32')
-
- #/* Run ROF-LLT iterations for 2D data */
- LLT_ROF_CPU_main(&inputData[0,0], &outputData[0,0], regularisation_parameterROF, regularisation_parameterLLT, iterations, time_marching_parameter, dims[1],dims[0],1)
- return outputData
-
-def LLT_ROF_3D(np.ndarray[np.float32_t, ndim=3, mode="c"] inputData,
- float regularisation_parameterROF,
- float regularisation_parameterLLT,
- int iterations,
- float time_marching_parameter):
-
- cdef long dims[3]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
- dims[2] = inputData.shape[2]
-
- cdef np.ndarray[np.float32_t, ndim=3, mode="c"] outputData = \
- np.zeros([dims[0], dims[1], dims[2]], dtype='float32')
-
- #/* Run ROF-LLT iterations for 3D data */
- LLT_ROF_CPU_main(&inputData[0,0,0], &outputData[0,0,0], regularisation_parameterROF, regularisation_parameterLLT, iterations, time_marching_parameter, dims[2], dims[1], dims[0])
- return outputData
-
-#****************************************************************#
-#**************Directional Total-variation FGP ******************#
-#****************************************************************#
-#******** Directional TV Fast-Gradient-Projection (FGP)*********#
-def dTV_FGP_CPU(inputData, refdata, regularisation_parameter, iterationsNumb, tolerance_param, eta_const, methodTV, nonneg, printM):
- if inputData.ndim == 2:
- return dTV_FGP_2D(inputData, refdata, regularisation_parameter, iterationsNumb, tolerance_param, eta_const, methodTV, nonneg, printM)
- elif inputData.ndim == 3:
- return dTV_FGP_3D(inputData, refdata, regularisation_parameter, iterationsNumb, tolerance_param, eta_const, methodTV, nonneg, printM)
-
-def dTV_FGP_2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData,
- np.ndarray[np.float32_t, ndim=2, mode="c"] refdata,
- float regularisation_parameter,
- int iterationsNumb,
- float tolerance_param,
- float eta_const,
- int methodTV,
- int nonneg,
- int printM):
-
- cdef long dims[2]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
-
- cdef np.ndarray[np.float32_t, ndim=2, mode="c"] outputData = \
- np.zeros([dims[0],dims[1]], dtype='float32')
-
- #/* Run FGP-dTV iterations for 2D data */
- dTV_FGP_CPU_main(&inputData[0,0], &refdata[0,0], &outputData[0,0], regularisation_parameter,
- iterationsNumb,
- tolerance_param,
- eta_const,
- methodTV,
- nonneg,
- printM,
- dims[1], dims[0], 1)
-
- return outputData
-
-def dTV_FGP_3D(np.ndarray[np.float32_t, ndim=3, mode="c"] inputData,
- np.ndarray[np.float32_t, ndim=3, mode="c"] refdata,
- float regularisation_parameter,
- int iterationsNumb,
- float tolerance_param,
- float eta_const,
- int methodTV,
- int nonneg,
- int printM):
- cdef long dims[3]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
- dims[2] = inputData.shape[2]
-
- cdef np.ndarray[np.float32_t, ndim=3, mode="c"] outputData = \
- np.zeros([dims[0], dims[1], dims[2]], dtype='float32')
-
- #/* Run FGP-dTV iterations for 3D data */
- dTV_FGP_CPU_main(&inputData[0,0,0], &refdata[0,0,0], &outputData[0,0,0], regularisation_parameter,
- iterationsNumb,
- tolerance_param,
- eta_const,
- methodTV,
- nonneg,
- printM,
- dims[2], dims[1], dims[0])
- return outputData
-
-#****************************************************************#
-#*********************Total Nuclear Variation********************#
-#****************************************************************#
-def TNV_CPU(inputData, regularisation_parameter, iterationsNumb, tolerance_param):
- if inputData.ndim == 2:
- return
- elif inputData.ndim == 3:
- return TNV_3D(inputData, regularisation_parameter, iterationsNumb, tolerance_param)
-
-def TNV_3D(np.ndarray[np.float32_t, ndim=3, mode="c"] inputData,
- float regularisation_parameter,
- int iterationsNumb,
- float tolerance_param):
- cdef long dims[3]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
- dims[2] = inputData.shape[2]
-
- cdef np.ndarray[np.float32_t, ndim=3, mode="c"] outputData = \
- np.zeros([dims[0],dims[1],dims[2]], dtype='float32')
-
- # Run TNV iterations for 3D (X,Y,Channels) data
- TNV_CPU_main(&inputData[0,0,0], &outputData[0,0,0], regularisation_parameter, iterationsNumb, tolerance_param, dims[2], dims[1], dims[0])
- return outputData
-#****************************************************************#
-#***************Nonlinear (Isotropic) Diffusion******************#
-#****************************************************************#
-def NDF_CPU(inputData, regularisation_parameter, edge_parameter, iterationsNumb,time_marching_parameter, penalty_type):
- if inputData.ndim == 2:
- return NDF_2D(inputData, regularisation_parameter, edge_parameter, iterationsNumb, time_marching_parameter, penalty_type)
- elif inputData.ndim == 3:
- return NDF_3D(inputData, regularisation_parameter, edge_parameter, iterationsNumb, time_marching_parameter, penalty_type)
-
-def NDF_2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData,
- float regularisation_parameter,
- float edge_parameter,
- int iterationsNumb,
- float time_marching_parameter,
- int penalty_type):
- cdef long dims[2]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
-
- cdef np.ndarray[np.float32_t, ndim=2, mode="c"] outputData = \
- np.zeros([dims[0],dims[1]], dtype='float32')
-
- # Run Nonlinear Diffusion iterations for 2D data
- Diffusion_CPU_main(&inputData[0,0], &outputData[0,0], regularisation_parameter, edge_parameter, iterationsNumb, time_marching_parameter, penalty_type, dims[1], dims[0], 1)
- return outputData
-
-def NDF_3D(np.ndarray[np.float32_t, ndim=3, mode="c"] inputData,
- float regularisation_parameter,
- float edge_parameter,
- int iterationsNumb,
- float time_marching_parameter,
- int penalty_type):
- cdef long dims[3]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
- dims[2] = inputData.shape[2]
-
- cdef np.ndarray[np.float32_t, ndim=3, mode="c"] outputData = \
- np.zeros([dims[0],dims[1],dims[2]], dtype='float32')
-
- # Run Nonlinear Diffusion iterations for 3D data
- Diffusion_CPU_main(&inputData[0,0,0], &outputData[0,0,0], regularisation_parameter, edge_parameter, iterationsNumb, time_marching_parameter, penalty_type, dims[2], dims[1], dims[0])
-
- return outputData
-
-#****************************************************************#
-#*************Anisotropic Fourth-Order diffusion*****************#
-#****************************************************************#
-def Diff4th_CPU(inputData, regularisation_parameter, edge_parameter, iterationsNumb, time_marching_parameter):
- if inputData.ndim == 2:
- return Diff4th_2D(inputData, regularisation_parameter, edge_parameter, iterationsNumb, time_marching_parameter)
- elif inputData.ndim == 3:
- return Diff4th_3D(inputData, regularisation_parameter, edge_parameter, iterationsNumb, time_marching_parameter)
-
-def Diff4th_2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData,
- float regularisation_parameter,
- float edge_parameter,
- int iterationsNumb,
- float time_marching_parameter):
- cdef long dims[2]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
-
- cdef np.ndarray[np.float32_t, ndim=2, mode="c"] outputData = \
- np.zeros([dims[0],dims[1]], dtype='float32')
-
- # Run Anisotropic Fourth-Order diffusion for 2D data
- Diffus4th_CPU_main(&inputData[0,0], &outputData[0,0], regularisation_parameter, edge_parameter, iterationsNumb, time_marching_parameter, dims[1], dims[0], 1)
- return outputData
-
-def Diff4th_3D(np.ndarray[np.float32_t, ndim=3, mode="c"] inputData,
- float regularisation_parameter,
- float edge_parameter,
- int iterationsNumb,
- float time_marching_parameter):
- cdef long dims[3]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
- dims[2] = inputData.shape[2]
-
- cdef np.ndarray[np.float32_t, ndim=3, mode="c"] outputData = \
- np.zeros([dims[0],dims[1],dims[2]], dtype='float32')
-
- # Run Anisotropic Fourth-Order diffusion for 3D data
- Diffus4th_CPU_main(&inputData[0,0,0], &outputData[0,0,0], regularisation_parameter, edge_parameter, iterationsNumb, time_marching_parameter, dims[2], dims[1], dims[0])
-
- return outputData
-
-#****************************************************************#
-#***************Patch-based weights calculation******************#
-#****************************************************************#
-def PATCHSEL_CPU(inputData, searchwindow, patchwindow, neighbours, edge_parameter):
- if inputData.ndim == 2:
- return PatchSel_2D(inputData, searchwindow, patchwindow, neighbours, edge_parameter)
- elif inputData.ndim == 3:
- return 1
-def PatchSel_2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData,
- int searchwindow,
- int patchwindow,
- int neighbours,
- float edge_parameter):
- cdef long dims[3]
- dims[0] = neighbours
- dims[1] = inputData.shape[0]
- dims[2] = inputData.shape[1]
-
-
- cdef np.ndarray[np.float32_t, ndim=3, mode="c"] Weights = \
- np.zeros([dims[0], dims[1],dims[2]], dtype='float32')
-
- cdef np.ndarray[np.uint16_t, ndim=3, mode="c"] H_i = \
- np.zeros([dims[0], dims[1],dims[2]], dtype='uint16')
-
- cdef np.ndarray[np.uint16_t, ndim=3, mode="c"] H_j = \
- np.zeros([dims[0], dims[1],dims[2]], dtype='uint16')
-
- # Run patch-based weight selection function
- PatchSelect_CPU_main(&inputData[0,0], &H_j[0,0,0], &H_i[0,0,0], &H_i[0,0,0], &Weights[0,0,0], dims[2], dims[1], 0, searchwindow, patchwindow, neighbours, edge_parameter, 1)
- return H_i, H_j, Weights
-"""
-def PatchSel_3D(np.ndarray[np.float32_t, ndim=3, mode="c"] inputData,
- int searchwindow,
- int patchwindow,
- int neighbours,
- float edge_parameter):
- cdef long dims[4]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
- dims[2] = inputData.shape[2]
- dims[3] = neighbours
-
- cdef np.ndarray[np.float32_t, ndim=4, mode="c"] Weights = \
- np.zeros([dims[3],dims[0],dims[1],dims[2]], dtype='float32')
-
- cdef np.ndarray[np.uint16_t, ndim=4, mode="c"] H_i = \
- np.zeros([dims[3],dims[0],dims[1],dims[2]], dtype='uint16')
-
- cdef np.ndarray[np.uint16_t, ndim=4, mode="c"] H_j = \
- np.zeros([dims[3],dims[0],dims[1],dims[2]], dtype='uint16')
-
- cdef np.ndarray[np.uint16_t, ndim=4, mode="c"] H_k = \
- np.zeros([dims[3],dims[0],dims[1],dims[2]], dtype='uint16')
-
- # Run patch-based weight selection function
- PatchSelect_CPU_main(&inputData[0,0,0], &H_i[0,0,0,0], &H_j[0,0,0,0], &H_k[0,0,0,0], &Weights[0,0,0,0], dims[2], dims[1], dims[0], searchwindow, patchwindow, neighbours, edge_parameter, 1)
- return H_i, H_j, H_k, Weights
-"""
-
-#****************************************************************#
-#***************Non-local Total Variation******************#
-#****************************************************************#
-def NLTV_CPU(inputData, H_i, H_j, H_k, Weights, regularisation_parameter, iterations):
- if inputData.ndim == 2:
- return NLTV_2D(inputData, H_i, H_j, Weights, regularisation_parameter, iterations)
- elif inputData.ndim == 3:
- return 1
-def NLTV_2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData,
- np.ndarray[np.uint16_t, ndim=3, mode="c"] H_i,
- np.ndarray[np.uint16_t, ndim=3, mode="c"] H_j,
- np.ndarray[np.float32_t, ndim=3, mode="c"] Weights,
- float regularisation_parameter,
- int iterations):
-
- cdef long dims[2]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
- neighbours = H_i.shape[0]
-
- cdef np.ndarray[np.float32_t, ndim=2, mode="c"] outputData = \
- np.zeros([dims[0],dims[1]], dtype='float32')
-
- # Run nonlocal TV regularisation
- Nonlocal_TV_CPU_main(&inputData[0,0], &outputData[0,0], &H_i[0,0,0], &H_j[0,0,0], &H_i[0,0,0], &Weights[0,0,0], dims[1], dims[0], 0, neighbours, regularisation_parameter, iterations)
- return outputData
-
-#*********************Inpainting WITH****************************#
-#***************Nonlinear (Isotropic) Diffusion******************#
-#****************************************************************#
-def NDF_INPAINT_CPU(inputData, maskData, regularisation_parameter, edge_parameter, iterationsNumb, time_marching_parameter, penalty_type):
- if inputData.ndim == 2:
- return NDF_INP_2D(inputData, maskData, regularisation_parameter, edge_parameter, iterationsNumb, time_marching_parameter, penalty_type)
- elif inputData.ndim == 3:
- return NDF_INP_3D(inputData, maskData, regularisation_parameter, edge_parameter, iterationsNumb, time_marching_parameter, penalty_type)
-
-def NDF_INP_2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData,
- np.ndarray[np.uint8_t, ndim=2, mode="c"] maskData,
- float regularisation_parameter,
- float edge_parameter,
- int iterationsNumb,
- float time_marching_parameter,
- int penalty_type):
-
- cdef long dims[2]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
-
-
- cdef np.ndarray[np.float32_t, ndim=2, mode="c"] outputData = \
- np.zeros([dims[0],dims[1]], dtype='float32')
-
- # Run Inpaiting by Diffusion iterations for 2D data
- Diffusion_Inpaint_CPU_main(&inputData[0,0], &maskData[0,0], &outputData[0,0], regularisation_parameter, edge_parameter, iterationsNumb, time_marching_parameter, penalty_type, dims[1], dims[0], 1)
- return outputData
-
-def NDF_INP_3D(np.ndarray[np.float32_t, ndim=3, mode="c"] inputData,
- np.ndarray[np.uint8_t, ndim=3, mode="c"] maskData,
- float regularisation_parameter,
- float edge_parameter,
- int iterationsNumb,
- float time_marching_parameter,
- int penalty_type):
- cdef long dims[3]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
- dims[2] = inputData.shape[2]
-
- cdef np.ndarray[np.float32_t, ndim=3, mode="c"] outputData = \
- np.zeros([dims[0],dims[1],dims[2]], dtype='float32')
-
- # Run Inpaiting by Diffusion iterations for 3D data
- Diffusion_Inpaint_CPU_main(&inputData[0,0,0], &maskData[0,0,0], &outputData[0,0,0], regularisation_parameter, edge_parameter, iterationsNumb, time_marching_parameter, penalty_type, dims[2], dims[1], dims[0])
-
- return outputData
-#*********************Inpainting WITH****************************#
-#***************Nonlocal Vertical Marching method****************#
-#****************************************************************#
-def NVM_INPAINT_CPU(inputData, maskData, SW_increment, iterationsNumb):
- if inputData.ndim == 2:
- return NVM_INP_2D(inputData, maskData, SW_increment, iterationsNumb)
- elif inputData.ndim == 3:
- return
-
-def NVM_INP_2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData,
- np.ndarray[np.uint8_t, ndim=2, mode="c"] maskData,
- int SW_increment,
- int iterationsNumb):
- cdef long dims[2]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
-
- cdef np.ndarray[np.float32_t, ndim=2, mode="c"] outputData = \
- np.zeros([dims[0],dims[1]], dtype='float32')
-
- cdef np.ndarray[np.uint8_t, ndim=2, mode="c"] maskData_upd = \
- np.zeros([dims[0],dims[1]], dtype='uint8')
-
- # Run Inpaiting by Nonlocal vertical marching method for 2D data
- NonlocalMarching_Inpaint_main(&inputData[0,0], &maskData[0,0], &outputData[0,0],
- &maskData_upd[0,0],
- SW_increment, iterationsNumb, 1, dims[1], dims[0], 1)
-
- return (outputData, maskData_upd)
-
-
-#****************************************************************#
-#***************Calculation of TV-energy functional**************#
-#****************************************************************#
-def TV_ENERGY(inputData, inputData0, regularisation_parameter, typeFunctional):
- if inputData.ndim == 2:
- return TV_ENERGY_2D(inputData, inputData0, regularisation_parameter, typeFunctional)
- elif inputData.ndim == 3:
- return TV_ENERGY_3D(inputData, inputData0, regularisation_parameter, typeFunctional)
-
-def TV_ENERGY_2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData,
- np.ndarray[np.float32_t, ndim=2, mode="c"] inputData0,
- float regularisation_parameter,
- int typeFunctional):
-
- cdef long dims[2]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
-
- cdef np.ndarray[np.float32_t, ndim=1, mode="c"] outputData = \
- np.zeros([1], dtype='float32')
-
- # run function
- TV_energy2D(&inputData[0,0], &inputData0[0,0], &outputData[0], regularisation_parameter, typeFunctional, dims[1], dims[0])
-
- return outputData
-
-def TV_ENERGY_3D(np.ndarray[np.float32_t, ndim=3, mode="c"] inputData,
- np.ndarray[np.float32_t, ndim=3, mode="c"] inputData0,
- float regularisation_parameter,
- int typeFunctional):
-
- cdef long dims[3]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
- dims[2] = inputData.shape[2]
-
- cdef np.ndarray[np.float32_t, ndim=1, mode="c"] outputData = \
- np.zeros([1], dtype='float32')
-
- # Run function
- TV_energy3D(&inputData[0,0,0], &inputData0[0,0,0], &outputData[0], regularisation_parameter, typeFunctional, dims[2], dims[1], dims[0])
-
- return outputData
diff --git a/Wrappers/Python/src/gpu_regularisers.pyx b/Wrappers/Python/src/gpu_regularisers.pyx
deleted file mode 100644
index b52f669..0000000
--- a/Wrappers/Python/src/gpu_regularisers.pyx
+++ /dev/null
@@ -1,640 +0,0 @@
-# distutils: language=c++
-"""
-Copyright 2018 CCPi
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Author: Edoardo Pasca, Daniil Kazantsev
-"""
-
-import cython
-import numpy as np
-cimport numpy as np
-
-CUDAErrorMessage = 'CUDA error'
-
-cdef extern int TV_ROF_GPU_main(float* Input, float* Output, float lambdaPar, int iter, float tau, int N, int M, int Z);
-cdef extern int TV_FGP_GPU_main(float *Input, float *Output, float lambdaPar, int iter, float epsil, int methodTV, int nonneg, int printM, int N, int M, int Z);
-cdef extern int TV_SB_GPU_main(float *Input, float *Output, float lambdaPar, int iter, float epsil, int methodTV, int printM, int N, int M, int Z);
-cdef extern int TGV_GPU_main(float *Input, float *Output, float lambdaPar, float alpha1, float alpha0, int iterationsNumb, float L2, int dimX, int dimY, int dimZ);
-cdef extern int LLT_ROF_GPU_main(float *Input, float *Output, float lambdaROF, float lambdaLLT, int iterationsNumb, float tau, int N, int M, int Z);
-cdef extern int NonlDiff_GPU_main(float *Input, float *Output, float lambdaPar, float sigmaPar, int iterationsNumb, float tau, int penaltytype, int N, int M, int Z);
-cdef extern int dTV_FGP_GPU_main(float *Input, float *InputRef, float *Output, float lambdaPar, int iterationsNumb, float epsil, float eta, int methodTV, int nonneg, int printM, int N, int M, int Z);
-cdef extern int Diffus4th_GPU_main(float *Input, float *Output, float lambdaPar, float sigmaPar, int iterationsNumb, float tau, int N, int M, int Z);
-cdef extern int PatchSelect_GPU_main(float *Input, unsigned short *H_i, unsigned short *H_j, float *Weights, int N, int M, int SearchWindow, int SimilarWin, int NumNeighb, float h);
-
-# Total-variation Rudin-Osher-Fatemi (ROF)
-def TV_ROF_GPU(inputData,
- regularisation_parameter,
- iterations,
- time_marching_parameter):
- if inputData.ndim == 2:
- return ROFTV2D(inputData,
- regularisation_parameter,
- iterations,
- time_marching_parameter)
- elif inputData.ndim == 3:
- return ROFTV3D(inputData,
- regularisation_parameter,
- iterations,
- time_marching_parameter)
-
-# Total-variation Fast-Gradient-Projection (FGP)
-def TV_FGP_GPU(inputData,
- regularisation_parameter,
- iterations,
- tolerance_param,
- methodTV,
- nonneg,
- printM):
- if inputData.ndim == 2:
- return FGPTV2D(inputData,
- regularisation_parameter,
- iterations,
- tolerance_param,
- methodTV,
- nonneg,
- printM)
- elif inputData.ndim == 3:
- return FGPTV3D(inputData,
- regularisation_parameter,
- iterations,
- tolerance_param,
- methodTV,
- nonneg,
- printM)
-# Total-variation Split Bregman (SB)
-def TV_SB_GPU(inputData,
- regularisation_parameter,
- iterations,
- tolerance_param,
- methodTV,
- printM):
- if inputData.ndim == 2:
- return SBTV2D(inputData,
- regularisation_parameter,
- iterations,
- tolerance_param,
- methodTV,
- printM)
- elif inputData.ndim == 3:
- return SBTV3D(inputData,
- regularisation_parameter,
- iterations,
- tolerance_param,
- methodTV,
- printM)
-# LLT-ROF model
-def LLT_ROF_GPU(inputData, regularisation_parameterROF, regularisation_parameterLLT, iterations, time_marching_parameter):
- if inputData.ndim == 2:
- return LLT_ROF_GPU2D(inputData, regularisation_parameterROF, regularisation_parameterLLT, iterations, time_marching_parameter)
- elif inputData.ndim == 3:
- return LLT_ROF_GPU3D(inputData, regularisation_parameterROF, regularisation_parameterLLT, iterations, time_marching_parameter)
-# Total Generilised Variation (TGV)
-def TGV_GPU(inputData, regularisation_parameter, alpha1, alpha0, iterations, LipshitzConst):
- if inputData.ndim == 2:
- return TGV2D(inputData, regularisation_parameter, alpha1, alpha0, iterations, LipshitzConst)
- elif inputData.ndim == 3:
- return TGV3D(inputData, regularisation_parameter, alpha1, alpha0, iterations, LipshitzConst)
-# Directional Total-variation Fast-Gradient-Projection (FGP)
-def dTV_FGP_GPU(inputData,
- refdata,
- regularisation_parameter,
- iterations,
- tolerance_param,
- eta_const,
- methodTV,
- nonneg,
- printM):
- if inputData.ndim == 2:
- return FGPdTV2D(inputData,
- refdata,
- regularisation_parameter,
- iterations,
- tolerance_param,
- eta_const,
- methodTV,
- nonneg,
- printM)
- elif inputData.ndim == 3:
- return FGPdTV3D(inputData,
- refdata,
- regularisation_parameter,
- iterations,
- tolerance_param,
- eta_const,
- methodTV,
- nonneg,
- printM)
-# Nonlocal Isotropic Diffusion (NDF)
-def NDF_GPU(inputData,
- regularisation_parameter,
- edge_parameter,
- iterations,
- time_marching_parameter,
- penalty_type):
- if inputData.ndim == 2:
- return NDF_GPU_2D(inputData,
- regularisation_parameter,
- edge_parameter,
- iterations,
- time_marching_parameter,
- penalty_type)
- elif inputData.ndim == 3:
- return NDF_GPU_3D(inputData,
- regularisation_parameter,
- edge_parameter,
- iterations,
- time_marching_parameter,
- penalty_type)
-# Anisotropic Fourth-Order diffusion
-def Diff4th_GPU(inputData,
- regularisation_parameter,
- edge_parameter,
- iterations,
- time_marching_parameter):
- if inputData.ndim == 2:
- return Diff4th_2D(inputData,
- regularisation_parameter,
- edge_parameter,
- iterations,
- time_marching_parameter)
- elif inputData.ndim == 3:
- return Diff4th_3D(inputData,
- regularisation_parameter,
- edge_parameter,
- iterations,
- time_marching_parameter)
-
-#****************************************************************#
-#********************** Total-variation ROF *********************#
-#****************************************************************#
-def ROFTV2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData,
- float regularisation_parameter,
- int iterations,
- float time_marching_parameter):
-
- cdef long dims[2]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
-
- cdef np.ndarray[np.float32_t, ndim=2, mode="c"] outputData = \
- np.zeros([dims[0],dims[1]], dtype='float32')
-
- # Running CUDA code here
- if (TV_ROF_GPU_main(
- &inputData[0,0], &outputData[0,0],
- regularisation_parameter,
- iterations ,
- time_marching_parameter,
- dims[1], dims[0], 1)==0):
- return outputData;
- else:
- raise ValueError(CUDAErrorMessage);
-
-def ROFTV3D(np.ndarray[np.float32_t, ndim=3, mode="c"] inputData,
- float regularisation_parameter,
- int iterations,
- float time_marching_parameter):
-
- cdef long dims[3]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
- dims[2] = inputData.shape[2]
-
- cdef np.ndarray[np.float32_t, ndim=3, mode="c"] outputData = \
- np.zeros([dims[0],dims[1],dims[2]], dtype='float32')
-
- # Running CUDA code here
- if (TV_ROF_GPU_main(
- &inputData[0,0,0], &outputData[0,0,0],
- regularisation_parameter,
- iterations ,
- time_marching_parameter,
- dims[2], dims[1], dims[0])==0):
- return outputData;
- else:
- raise ValueError(CUDAErrorMessage);
-#****************************************************************#
-#********************** Total-variation FGP *********************#
-#****************************************************************#
-#******** Total-variation Fast-Gradient-Projection (FGP)*********#
-def FGPTV2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData,
- float regularisation_parameter,
- int iterations,
- float tolerance_param,
- int methodTV,
- int nonneg,
- int printM):
-
- cdef long dims[2]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
-
- cdef np.ndarray[np.float32_t, ndim=2, mode="c"] outputData = \
- np.zeros([dims[0],dims[1]], dtype='float32')
-
- # Running CUDA code here
- if (TV_FGP_GPU_main(&inputData[0,0], &outputData[0,0],
- regularisation_parameter,
- iterations,
- tolerance_param,
- methodTV,
- nonneg,
- printM,
- dims[1], dims[0], 1)==0):
- return outputData;
- else:
- raise ValueError(CUDAErrorMessage);
-
-
-def FGPTV3D(np.ndarray[np.float32_t, ndim=3, mode="c"] inputData,
- float regularisation_parameter,
- int iterations,
- float tolerance_param,
- int methodTV,
- int nonneg,
- int printM):
-
- cdef long dims[3]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
- dims[2] = inputData.shape[2]
-
- cdef np.ndarray[np.float32_t, ndim=3, mode="c"] outputData = \
- np.zeros([dims[0],dims[1],dims[2]], dtype='float32')
-
- # Running CUDA code here
- if (TV_FGP_GPU_main(&inputData[0,0,0], &outputData[0,0,0],
- regularisation_parameter ,
- iterations,
- tolerance_param,
- methodTV,
- nonneg,
- printM,
- dims[2], dims[1], dims[0])==0):
- return outputData;
- else:
- raise ValueError(CUDAErrorMessage);
-
-#***************************************************************#
-#********************** Total-variation SB *********************#
-#***************************************************************#
-#*************** Total-variation Split Bregman (SB)*************#
-def SBTV2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData,
- float regularisation_parameter,
- int iterations,
- float tolerance_param,
- int methodTV,
- int printM):
-
- cdef long dims[2]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
-
- cdef np.ndarray[np.float32_t, ndim=2, mode="c"] outputData = \
- np.zeros([dims[0],dims[1]], dtype='float32')
-
- # Running CUDA code here
- if (TV_SB_GPU_main(&inputData[0,0], &outputData[0,0],
- regularisation_parameter,
- iterations,
- tolerance_param,
- methodTV,
- printM,
- dims[1], dims[0], 1)==0):
- return outputData;
- else:
- raise ValueError(CUDAErrorMessage);
-
-
-def SBTV3D(np.ndarray[np.float32_t, ndim=3, mode="c"] inputData,
- float regularisation_parameter,
- int iterations,
- float tolerance_param,
- int methodTV,
- int printM):
-
- cdef long dims[3]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
- dims[2] = inputData.shape[2]
-
- cdef np.ndarray[np.float32_t, ndim=3, mode="c"] outputData = \
- np.zeros([dims[0],dims[1],dims[2]], dtype='float32')
-
- # Running CUDA code here
- if (TV_SB_GPU_main(&inputData[0,0,0], &outputData[0,0,0],
- regularisation_parameter ,
- iterations,
- tolerance_param,
- methodTV,
- printM,
- dims[2], dims[1], dims[0])==0):
- return outputData;
- else:
- raise ValueError(CUDAErrorMessage);
-
-
-#***************************************************************#
-#************************ LLT-ROF model ************************#
-#***************************************************************#
-#************Joint LLT-ROF model for higher order **************#
-def LLT_ROF_GPU2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData,
- float regularisation_parameterROF,
- float regularisation_parameterLLT,
- int iterations,
- float time_marching_parameter):
-
- cdef long dims[2]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
-
- cdef np.ndarray[np.float32_t, ndim=2, mode="c"] outputData = \
- np.zeros([dims[0],dims[1]], dtype='float32')
-
- # Running CUDA code here
- if (LLT_ROF_GPU_main(&inputData[0,0], &outputData[0,0],regularisation_parameterROF, regularisation_parameterLLT, iterations, time_marching_parameter, dims[1],dims[0],1)==0):
- return outputData;
- else:
- raise ValueError(CUDAErrorMessage);
-
-
-def LLT_ROF_GPU3D(np.ndarray[np.float32_t, ndim=3, mode="c"] inputData,
- float regularisation_parameterROF,
- float regularisation_parameterLLT,
- int iterations,
- float time_marching_parameter):
-
- cdef long dims[3]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
- dims[2] = inputData.shape[2]
-
- cdef np.ndarray[np.float32_t, ndim=3, mode="c"] outputData = \
- np.zeros([dims[0],dims[1],dims[2]], dtype='float32')
-
- # Running CUDA code here
- if (LLT_ROF_GPU_main(&inputData[0,0,0], &outputData[0,0,0], regularisation_parameterROF, regularisation_parameterLLT, iterations, time_marching_parameter, dims[2], dims[1], dims[0])==0):
- return outputData;
- else:
- raise ValueError(CUDAErrorMessage);
-
-
-#***************************************************************#
-#***************** Total Generalised Variation *****************#
-#***************************************************************#
-def TGV2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData,
- float regularisation_parameter,
- float alpha1,
- float alpha0,
- int iterationsNumb,
- float LipshitzConst):
-
- cdef long dims[2]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
-
- cdef np.ndarray[np.float32_t, ndim=2, mode="c"] outputData = \
- np.zeros([dims[0],dims[1]], dtype='float32')
-
- #/* Run TGV iterations for 2D data */
- if (TGV_GPU_main(&inputData[0,0], &outputData[0,0], regularisation_parameter,
- alpha1,
- alpha0,
- iterationsNumb,
- LipshitzConst,
- dims[1],dims[0], 1)==0):
- return outputData
- else:
- raise ValueError(CUDAErrorMessage);
-
-def TGV3D(np.ndarray[np.float32_t, ndim=3, mode="c"] inputData,
- float regularisation_parameter,
- float alpha1,
- float alpha0,
- int iterationsNumb,
- float LipshitzConst):
-
- cdef long dims[3]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
- dims[2] = inputData.shape[2]
-
- cdef np.ndarray[np.float32_t, ndim=3, mode="c"] outputData = \
- np.zeros([dims[0],dims[1],dims[2]], dtype='float32')
-
- # Running CUDA code here
- if (TGV_GPU_main(
- &inputData[0,0,0], &outputData[0,0,0], regularisation_parameter,
- alpha1,
- alpha0,
- iterationsNumb,
- LipshitzConst,
- dims[2], dims[1], dims[0])==0):
- return outputData;
- else:
- raise ValueError(CUDAErrorMessage);
-
-
-#****************************************************************#
-#**************Directional Total-variation FGP ******************#
-#****************************************************************#
-#******** Directional TV Fast-Gradient-Projection (FGP)*********#
-def FGPdTV2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData,
- np.ndarray[np.float32_t, ndim=2, mode="c"] refdata,
- float regularisation_parameter,
- int iterations,
- float tolerance_param,
- float eta_const,
- int methodTV,
- int nonneg,
- int printM):
-
- cdef long dims[2]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
-
- cdef np.ndarray[np.float32_t, ndim=2, mode="c"] outputData = \
- np.zeros([dims[0],dims[1]], dtype='float32')
-
- # Running CUDA code here
- if (dTV_FGP_GPU_main(&inputData[0,0], &refdata[0,0], &outputData[0,0],
- regularisation_parameter,
- iterations,
- tolerance_param,
- eta_const,
- methodTV,
- nonneg,
- printM,
- dims[1], dims[0], 1)==0):
- return outputData
- else:
- raise ValueError(CUDAErrorMessage);
-
-
-def FGPdTV3D(np.ndarray[np.float32_t, ndim=3, mode="c"] inputData,
- np.ndarray[np.float32_t, ndim=3, mode="c"] refdata,
- float regularisation_parameter,
- int iterations,
- float tolerance_param,
- float eta_const,
- int methodTV,
- int nonneg,
- int printM):
-
- cdef long dims[3]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
- dims[2] = inputData.shape[2]
-
- cdef np.ndarray[np.float32_t, ndim=3, mode="c"] outputData = \
- np.zeros([dims[0],dims[1],dims[2]], dtype='float32')
-
- # Running CUDA code here
- if (dTV_FGP_GPU_main(&inputData[0,0,0], &refdata[0,0,0], &outputData[0,0,0],
- regularisation_parameter ,
- iterations,
- tolerance_param,
- eta_const,
- methodTV,
- nonneg,
- printM,
- dims[2], dims[1], dims[0])==0):
- return outputData;
- else:
- raise ValueError(CUDAErrorMessage);
-
-
-#****************************************************************#
-#***************Nonlinear (Isotropic) Diffusion******************#
-#****************************************************************#
-def NDF_GPU_2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData,
- float regularisation_parameter,
- float edge_parameter,
- int iterationsNumb,
- float time_marching_parameter,
- int penalty_type):
- cdef long dims[2]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
-
- cdef np.ndarray[np.float32_t, ndim=2, mode="c"] outputData = \
- np.zeros([dims[0],dims[1]], dtype='float32')
-
- #rangecheck = penalty_type < 1 and penalty_type > 3
- #if not rangecheck:
-# raise ValueError('Choose penalty type as 1 for Huber, 2 - Perona-Malik, 3 - Tukey Biweight')
-
- # Run Nonlinear Diffusion iterations for 2D data
- # Running CUDA code here
- if (NonlDiff_GPU_main(&inputData[0,0], &outputData[0,0], regularisation_parameter, edge_parameter, iterationsNumb, time_marching_parameter, penalty_type, dims[1], dims[0], 1)==0):
- return outputData;
- else:
- raise ValueError(CUDAErrorMessage);
-
-
-def NDF_GPU_3D(np.ndarray[np.float32_t, ndim=3, mode="c"] inputData,
- float regularisation_parameter,
- float edge_parameter,
- int iterationsNumb,
- float time_marching_parameter,
- int penalty_type):
- cdef long dims[3]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
- dims[2] = inputData.shape[2]
-
- cdef np.ndarray[np.float32_t, ndim=3, mode="c"] outputData = \
- np.zeros([dims[0],dims[1],dims[2]], dtype='float32')
-
- # Run Nonlinear Diffusion iterations for 3D data
- # Running CUDA code here
- if (NonlDiff_GPU_main(&inputData[0,0,0], &outputData[0,0,0], regularisation_parameter, edge_parameter, iterationsNumb, time_marching_parameter, penalty_type, dims[2], dims[1], dims[0])==0):
- return outputData;
- else:
- raise ValueError(CUDAErrorMessage);
-
-#****************************************************************#
-#************Anisotropic Fourth-Order diffusion******************#
-#****************************************************************#
-def Diff4th_2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData,
- float regularisation_parameter,
- float edge_parameter,
- int iterationsNumb,
- float time_marching_parameter):
- cdef long dims[2]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
-
- cdef np.ndarray[np.float32_t, ndim=2, mode="c"] outputData = \
- np.zeros([dims[0],dims[1]], dtype='float32')
-
- # Run Anisotropic Fourth-Order diffusion for 2D data
- # Running CUDA code here
- if (Diffus4th_GPU_main(&inputData[0,0], &outputData[0,0], regularisation_parameter, edge_parameter, iterationsNumb, time_marching_parameter, dims[1], dims[0], 1)==0):
- return outputData
- else:
- raise ValueError(CUDAErrorMessage);
-
-
-def Diff4th_3D(np.ndarray[np.float32_t, ndim=3, mode="c"] inputData,
- float regularisation_parameter,
- float edge_parameter,
- int iterationsNumb,
- float time_marching_parameter):
- cdef long dims[3]
- dims[0] = inputData.shape[0]
- dims[1] = inputData.shape[1]
- dims[2] = inputData.shape[2]
-
- cdef np.ndarray[np.float32_t, ndim=3, mode="c"] outputData = \
- np.zeros([dims[0],dims[1],dims[2]], dtype='float32')
-
- # Run Anisotropic Fourth-Order diffusion for 3D data
- # Running CUDA code here
- if (Diffus4th_GPU_main(&inputData[0,0,0], &outputData[0,0,0], regularisation_parameter, edge_parameter, iterationsNumb, time_marching_parameter, dims[2], dims[1], dims[0])==0):
- return outputData;
- else:
- raise ValueError(CUDAErrorMessage);
-
-#****************************************************************#
-#************Patch-based weights pre-selection******************#
-#****************************************************************#
-def PATCHSEL_GPU(inputData, searchwindow, patchwindow, neighbours, edge_parameter):
- if inputData.ndim == 2:
- return PatchSel_2D(inputData, searchwindow, patchwindow, neighbours, edge_parameter)
- elif inputData.ndim == 3:
- return 1
-def PatchSel_2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData,
- int searchwindow,
- int patchwindow,
- int neighbours,
- float edge_parameter):
- cdef long dims[3]
- dims[0] = neighbours
- dims[1] = inputData.shape[0]
- dims[2] = inputData.shape[1]
-
- cdef np.ndarray[np.float32_t, ndim=3, mode="c"] Weights = \
- np.zeros([dims[0], dims[1],dims[2]], dtype='float32')
-
- cdef np.ndarray[np.uint16_t, ndim=3, mode="c"] H_i = \
- np.zeros([dims[0], dims[1],dims[2]], dtype='uint16')
-
- cdef np.ndarray[np.uint16_t, ndim=3, mode="c"] H_j = \
- np.zeros([dims[0], dims[1],dims[2]], dtype='uint16')
-
- # Run patch-based weight selection function
- if (PatchSelect_GPU_main(&inputData[0,0], &H_j[0,0,0], &H_i[0,0,0], &Weights[0,0,0], dims[2], dims[1], searchwindow, patchwindow, neighbours, edge_parameter)==0):
- return H_i, H_j, Weights;
- else:
- raise ValueError(CUDAErrorMessage);
-