From 824fafc9d39bfd3a27ffdb29c37f873e6097c3f7 Mon Sep 17 00:00:00 2001 From: algol Date: Fri, 4 May 2018 09:38:13 +0100 Subject: demos for Diff4thO --- Wrappers/Python/demos/demo_cpu_regularisers.py | 2 +- Wrappers/Python/demos/demo_cpu_regularisers3D.py | 9 +++------ Wrappers/Python/demos/demo_cpu_vs_gpu_regularisers.py | 8 ++++---- Wrappers/Python/demos/demo_gpu_regularisers.py | 2 +- Wrappers/Python/demos/demo_gpu_regularisers3D.py | 2 +- Wrappers/Python/src/cpu_regularisers.pyx | 4 ++-- 6 files changed, 12 insertions(+), 15 deletions(-) (limited to 'Wrappers/Python') diff --git a/Wrappers/Python/demos/demo_cpu_regularisers.py b/Wrappers/Python/demos/demo_cpu_regularisers.py index 51e7fb5..ff500ae 100644 --- a/Wrappers/Python/demos/demo_cpu_regularisers.py +++ b/Wrappers/Python/demos/demo_cpu_regularisers.py @@ -271,7 +271,7 @@ pars = {'algorithm' : DIFF4th, \ 'regularisation_parameter':3.5, \ 'edge_parameter':0.02,\ 'number_of_iterations' :500 ,\ - 'time_marching_parameter':0.005 + 'time_marching_parameter':0.0015 } print ("#############DIFF4th CPU################") diff --git a/Wrappers/Python/demos/demo_cpu_regularisers3D.py b/Wrappers/Python/demos/demo_cpu_regularisers3D.py index 0f47ea9..8ee157e 100644 --- a/Wrappers/Python/demos/demo_cpu_regularisers3D.py +++ b/Wrappers/Python/demos/demo_cpu_regularisers3D.py @@ -12,7 +12,7 @@ import matplotlib.pyplot as plt import numpy as np import os import timeit -from ccpi.filters.regularisers import ROF_TV, FGP_TV, SB_TV, FGP_dTV, TNV, NDF, DIFF4th +from ccpi.filters.regularisers import ROF_TV, FGP_TV, SB_TV, FGP_dTV, NDF, DIFF4th from qualitymetrics import rmse ############################################################################### def printParametersToString(pars): @@ -68,9 +68,6 @@ Im2[:,0:M] = Im[:,0:M] Im = Im2 del Im2 """ - -# Uncomment to test 3D regularisation performance -#%% slices = 20 noisyVol = np.zeros((slices,N,M),dtype='float32') @@ -82,7 +79,7 @@ for i in range (slices): 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 ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%") @@ -283,7 +280,7 @@ pars = {'algorithm' : DIFF4th, \ 'regularisation_parameter':3.5, \ 'edge_parameter':0.02,\ 'number_of_iterations' :300 ,\ - 'time_marching_parameter':0.005 + 'time_marching_parameter':0.0015 } print ("#############DIFF4th CPU################") diff --git a/Wrappers/Python/demos/demo_cpu_vs_gpu_regularisers.py b/Wrappers/Python/demos/demo_cpu_vs_gpu_regularisers.py index 2910c65..4611522 100644 --- a/Wrappers/Python/demos/demo_cpu_vs_gpu_regularisers.py +++ b/Wrappers/Python/demos/demo_cpu_vs_gpu_regularisers.py @@ -408,12 +408,12 @@ pars = {'algorithm' : DIFF4th, \ 'regularisation_parameter':3.5, \ 'edge_parameter':0.02,\ 'number_of_iterations' :500 ,\ - 'time_marching_parameter':0.005 + 'time_marching_parameter':0.001 } print ("#############Diff4th CPU####################") start_time = timeit.default_timer() -diff4th_cpu = Diff4th(pars['input'], +diff4th_cpu = DIFF4th(pars['input'], pars['regularisation_parameter'], pars['edge_parameter'], pars['number_of_iterations'], @@ -437,7 +437,7 @@ plt.title('{}'.format('CPU results')) print ("##############Diff4th GPU##################") start_time = timeit.default_timer() -diff4th_gpu = Diff4th(pars['input'], +diff4th_gpu = DIFF4th(pars['input'], pars['regularisation_parameter'], pars['edge_parameter'], pars['number_of_iterations'], @@ -445,7 +445,7 @@ diff4th_gpu = Diff4th(pars['input'], rms = rmse(Im, diff4th_gpu) pars['rmse'] = rms -pars['algorithm'] = Diff4th +pars['algorithm'] = DIFF4th txtstr = printParametersToString(pars) txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time) print (txtstr) diff --git a/Wrappers/Python/demos/demo_gpu_regularisers.py b/Wrappers/Python/demos/demo_gpu_regularisers.py index 8432696..3179428 100644 --- a/Wrappers/Python/demos/demo_gpu_regularisers.py +++ b/Wrappers/Python/demos/demo_gpu_regularisers.py @@ -269,7 +269,7 @@ pars = {'algorithm' : DIFF4th, \ 'regularisation_parameter':3.5, \ 'edge_parameter':0.02,\ 'number_of_iterations' :500 ,\ - 'time_marching_parameter':0.005 + 'time_marching_parameter':0.0015 } print ("#############DIFF4th CPU################") diff --git a/Wrappers/Python/demos/demo_gpu_regularisers3D.py b/Wrappers/Python/demos/demo_gpu_regularisers3D.py index 022df95..13c4e7b 100644 --- a/Wrappers/Python/demos/demo_gpu_regularisers3D.py +++ b/Wrappers/Python/demos/demo_gpu_regularisers3D.py @@ -285,7 +285,7 @@ pars = {'algorithm' : DIFF4th, \ 'regularisation_parameter':3.5, \ 'edge_parameter':0.02,\ 'number_of_iterations' :300 ,\ - 'time_marching_parameter':0.005 + 'time_marching_parameter':0.0015 } print ("#############DIFF4th CPU################") diff --git a/Wrappers/Python/src/cpu_regularisers.pyx b/Wrappers/Python/src/cpu_regularisers.pyx index 7dc3396..549b046 100644 --- a/Wrappers/Python/src/cpu_regularisers.pyx +++ b/Wrappers/Python/src/cpu_regularisers.pyx @@ -328,9 +328,9 @@ def NDF_3D(np.ndarray[np.float32_t, ndim=3, mode="c"] inputData, #****************************************************************# 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, penalty_type) + 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, penalty_type) + 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, -- cgit v1.2.3