summaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
authorDaniil Kazantsev <dkazanc@hotmail.com>2019-03-10 22:23:22 +0000
committerDaniil Kazantsev <dkazanc@hotmail.com>2019-03-10 22:23:22 +0000
commite2208bfc2ed540065bef2e8e12d914d873464da7 (patch)
tree36f91247b169ad423ff40a5850b19524f85d1f3e /demos
parent49761c3730e2ddf2ec40c84952572c43e9334ccb (diff)
downloadregularization-e2208bfc2ed540065bef2e8e12d914d873464da7.tar.gz
regularization-e2208bfc2ed540065bef2e8e12d914d873464da7.tar.bz2
regularization-e2208bfc2ed540065bef2e8e12d914d873464da7.tar.xz
regularization-e2208bfc2ed540065bef2e8e12d914d873464da7.zip
all python code updated
Diffstat (limited to 'demos')
-rw-r--r--demos/SoftwareX_supp/Demo_VolumeDenoise.py55
-rw-r--r--demos/demoMatlab_denoise.m39
-rw-r--r--demos/demo_cpu_regularisers.py66
-rw-r--r--demos/demo_cpu_regularisers3D.py60
-rw-r--r--demos/demo_cpu_vs_gpu_regularisers.py250
-rw-r--r--demos/demo_gpu_regularisers.py56
-rw-r--r--demos/demo_gpu_regularisers3D.py58
7 files changed, 298 insertions, 286 deletions
diff --git a/demos/SoftwareX_supp/Demo_VolumeDenoise.py b/demos/SoftwareX_supp/Demo_VolumeDenoise.py
index 6e7ea46..07e3133 100644
--- a/demos/SoftwareX_supp/Demo_VolumeDenoise.py
+++ b/demos/SoftwareX_supp/Demo_VolumeDenoise.py
@@ -29,7 +29,7 @@ from ccpi.filters.regularisers import ROF_TV, FGP_TV, SB_TV, LLT_ROF, NDF, Diff4
#%%
print ("Building 3D phantom using TomoPhantom software")
tic=timeit.default_timer()
-model = 9 # select a model number from the library
+model = 16 # select a model number from the library
N_size = 256 # Define phantom dimensions using a scalar value (cubic phantom)
path = os.path.dirname(tomophantom.__file__)
path_library3D = os.path.join(path, "Phantom3DLibrary.dat")
@@ -66,16 +66,18 @@ print ("#############ROF TV CPU####################")
# set parameters
pars = {'algorithm': ROF_TV, \
'input' : phantom_noise,\
- 'regularisation_parameter':0.04,\
- 'number_of_iterations': 600,\
- 'time_marching_parameter': 0.0025
- }
+ 'regularisation_parameter':0.02,\
+ 'number_of_iterations': 1000,\
+ 'time_marching_parameter': 0.001,\
+ 'tolerance_constant':0.0}
tic=timeit.default_timer()
-rof_cpu3D = ROF_TV(pars['input'],
+(rof_cpu3D, infcpu) = ROF_TV(pars['input'],
pars['regularisation_parameter'],
pars['number_of_iterations'],
- pars['time_marching_parameter'],'cpu')
+ pars['time_marching_parameter'],
+ pars['tolerance_constant'],'cpu')
+
toc=timeit.default_timer()
Run_time_rof = toc - tic
@@ -94,28 +96,47 @@ print ("#############ROF TV GPU####################")
# set parameters
pars = {'algorithm': ROF_TV, \
'input' : phantom_noise,\
- 'regularisation_parameter':0.04,\
- 'number_of_iterations': 600,\
- 'time_marching_parameter': 0.0025
- }
+ 'regularisation_parameter':0.06,\
+ 'number_of_iterations': 10000,\
+ 'time_marching_parameter': 0.00025,\
+ 'tolerance_constant':1e-06}
tic=timeit.default_timer()
-rof_gpu3D = ROF_TV(pars['input'],
+(rof_gpu3D, infogpu) = ROF_TV(pars['input'],
pars['regularisation_parameter'],
pars['number_of_iterations'],
- pars['time_marching_parameter'],'gpu')
+ pars['time_marching_parameter'],
+ pars['tolerance_constant'],'gpu')
+
toc=timeit.default_timer()
Run_time_rof = toc - tic
Qtools = QualityTools(phantom_tm, rof_gpu3D)
RMSE_rof = Qtools.rmse()
+sliceNo = 128
# SSIM measure
-Qtools = QualityTools(phantom_tm[128,:,:]*255, rof_gpu3D[128,:,:]*235)
+Qtools = QualityTools(phantom_tm[sliceNo,:,:]*255, rof_gpu3D[sliceNo,:,:]*235)
win = np.array([gaussian(11, 1.5)])
win2d = win * (win.T)
ssim_rof = Qtools.ssim(win2d)
+sliceSel = int(0.5*N_size)
+#plt.gray()
+plt.figure()
+plt.subplot(131)
+plt.imshow(rof_gpu3D[sliceSel,:,:],vmin=0, vmax=1.4)
+plt.title('3D ROF-TV, axial view')
+
+plt.subplot(132)
+plt.imshow(rof_gpu3D[:,sliceSel,:],vmin=0, vmax=1.4)
+plt.title('3D ROF-TV, coronal view')
+
+plt.subplot(133)
+plt.imshow(rof_gpu3D[:,:,sliceSel],vmin=0, vmax=1.4)
+plt.title('3D ROF-TV, sagittal view')
+plt.show()
+
print("ROF-TV (gpu) ____ RMSE: {}, MMSIM: {}, run time: {} sec".format(RMSE_rof,ssim_rof[0],Run_time_rof))
#%%
print ("#############FGP TV CPU####################")
@@ -154,13 +175,13 @@ print ("#############FGP TV GPU####################")
pars = {'algorithm' : FGP_TV, \
'input' : phantom_noise,\
'regularisation_parameter':0.05, \
- 'number_of_iterations' :80 ,\
- 'tolerance_constant':1e-04,\
+ 'number_of_iterations' :1500 ,\
+ 'tolerance_constant':1e-06,\
'methodTV': 0 ,\
'nonneg': 0}
tic=timeit.default_timer()
-(fgp_gpu3D) = FGP_TV(pars['input'],
+(fgp_gpu3D,infogpu) = FGP_TV(pars['input'],
pars['regularisation_parameter'],
pars['number_of_iterations'],
pars['tolerance_constant'],
diff --git a/demos/demoMatlab_denoise.m b/demos/demoMatlab_denoise.m
index fa81f6d..a22b40a 100644
--- a/demos/demoMatlab_denoise.m
+++ b/demos/demoMatlab_denoise.m
@@ -2,11 +2,9 @@
clear; close all
fsep = '/';
-%Path1 = sprintf(['..' fsep 'src' fsep 'Matlab' fsep 'mex_compile' fsep 'installed'], 1i);
-Path1 = ('/home/kjy41806/Documents/SOFT/CCPi-Regularisation-Toolkit/src/Matlab/mex_compile/installed');
+Path1 = sprintf(['..' fsep 'src' fsep 'Matlab' fsep 'mex_compile' fsep 'installed'], 1i);
Path2 = sprintf(['data' fsep], 1i);
-%Path3 = sprintf(['..' filesep 'src' filesep 'Matlab' filesep 'supp'], 1i);
-Path3 = '/home/kjy41806/Documents/SOFT/CCPi-Regularisation-Toolkit/src/Matlab/supp';
+Path3 = sprintf(['..' fsep 'src' fsep 'Matlab' fsep 'supp'], 1i);
addpath(Path1);
addpath(Path2);
addpath(Path3);
@@ -14,14 +12,14 @@ 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
+lambda_reg = 0.02; % regularsation parameter for all methods
+iter_rof = 2000; % number of ROF iterations
+tau_rof = 0.001; % time-marching constant
+epsil_tol = 0.0; % tolerance
+tic; [u_rof,infovec] = ROF_TV(single(u0), lambda_reg, iter_rof, tau_rof, epsil_tol); 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);
@@ -29,16 +27,14 @@ 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;
+% tic; u_rofG = ROF_TV_GPU(single(u0), lambda_reg, iter_rof, tau_rof, epsil_tol); 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 = 200; % number of FGP iterations
-epsil_tol = 1.0e-05; % tolerance
-tic; u_fgp = FGP_TV(single(u0), lambda_reg, iter_fgp, epsil_tol); toc;
+lambda_reg = 0.02;
+iter_fgp = 500; % number of FGP iterations
+epsil_tol = 1.0e-06; % tolerance
+tic; [u_fgp,infovec] = 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);
@@ -47,15 +43,14 @@ 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;
+lambda_reg = 0.03;
+iter_sb = 300; % number of SB iterations
+epsil_tol = 1.0e-06; % tolerance
+tic; [u_sb,infovec] = 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);
diff --git a/demos/demo_cpu_regularisers.py b/demos/demo_cpu_regularisers.py
index f2d2f33..8655623 100644
--- a/demos/demo_cpu_regularisers.py
+++ b/demos/demo_cpu_regularisers.py
@@ -31,8 +31,7 @@ def printParametersToString(pars):
return txt
###############################################################################
-#filename = os.path.join( "data" ,"lena_gray_512.tif")
-filename = "/home/algol/Documents/DEV/CCPi-Regularisation-Toolkit/test/lena_gray_512.tif"
+filename = os.path.join( "data" ,"lena_gray_512.tif")
# read image
Im = plt.imread(filename)
@@ -86,7 +85,7 @@ imgplot = plt.imshow(u0,cmap="gray")
pars = {'algorithm': ROF_TV, \
'input' : u0,\
'regularisation_parameter':0.02,\
- 'number_of_iterations': 1000,\
+ 'number_of_iterations': 4000,\
'time_marching_parameter': 0.001,\
'tolerance_constant':1e-06}
@@ -265,23 +264,23 @@ imgplot = plt.imshow(u0,cmap="gray")
# set parameters
pars = {'algorithm' : TGV, \
'input' : u0,\
- 'regularisation_parameter':0.04, \
+ 'regularisation_parameter':0.02, \
'alpha1':1.0,\
'alpha0':2.0,\
- 'number_of_iterations' :1350 ,\
+ 'number_of_iterations' :1000 ,\
'LipshitzConstant' :12 ,\
- }
-
+ 'tolerance_constant':1e-06}
+
print ("#############TGV CPU####################")
start_time = timeit.default_timer()
-tgv_cpu = TGV(pars['input'],
+(tgv_cpu,info_vec_cpu) = TGV(pars['input'],
pars['regularisation_parameter'],
pars['alpha1'],
pars['alpha0'],
pars['number_of_iterations'],
- pars['LipshitzConstant'],'cpu')
-
-
+ pars['LipshitzConstant'],
+ pars['tolerance_constant'], 'cpu')
+
Qtools = QualityTools(Im, tgv_cpu)
pars['rmse'] = Qtools.rmse()
@@ -299,8 +298,6 @@ imgplot = plt.imshow(tgv_cpu, cmap="gray")
plt.title('{}'.format('CPU results'))
#%%
-
-
print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
print ("________________NDF (2D)___________________")
print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
@@ -315,21 +312,22 @@ 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
- }
+ 'regularisation_parameter':0.02, \
+ 'edge_parameter':0.017,\
+ 'number_of_iterations' :1500 ,\
+ 'time_marching_parameter':0.01,\
+ 'penalty_type':1,\
+ 'tolerance_constant':1e-06}
print ("#############NDF CPU################")
start_time = timeit.default_timer()
-ndf_cpu = NDF(pars['input'],
+(ndf_cpu,info_vec_cpu) = NDF(pars['input'],
pars['regularisation_parameter'],
pars['edge_parameter'],
pars['number_of_iterations'],
pars['time_marching_parameter'],
- pars['penalty_type'],'cpu')
+ pars['penalty_type'],
+ pars['tolerance_constant'],'cpu')
Qtools = QualityTools(Im, ndf_cpu)
pars['rmse'] = Qtools.rmse()
@@ -362,19 +360,20 @@ imgplot = plt.imshow(u0,cmap="gray")
# set parameters
pars = {'algorithm' : Diff4th, \
'input' : u0,\
- 'regularisation_parameter':3.5, \
+ 'regularisation_parameter':0.8, \
'edge_parameter':0.02,\
- 'number_of_iterations' :500 ,\
- 'time_marching_parameter':0.0015
- }
+ 'number_of_iterations' :5500 ,\
+ 'time_marching_parameter':0.001,\
+ 'tolerance_constant':1e-06}
print ("#############Diff4th CPU################")
start_time = timeit.default_timer()
-diff4_cpu = Diff4th(pars['input'],
+(diff4_cpu,info_vec_cpu) = Diff4th(pars['input'],
pars['regularisation_parameter'],
pars['edge_parameter'],
pars['number_of_iterations'],
- pars['time_marching_parameter'],'cpu')
+ pars['time_marching_parameter'],
+ pars['tolerance_constant'],'cpu')
Qtools = QualityTools(Im, diff4_cpu)
pars['rmse'] = Qtools.rmse()
@@ -480,26 +479,23 @@ imgplot = plt.imshow(u0,cmap="gray")
pars = {'algorithm' : FGP_dTV, \
'input' : u0,\
'refdata' : u_ref,\
- 'regularisation_parameter':0.04, \
- 'number_of_iterations' :2000 ,\
+ 'regularisation_parameter':0.02, \
+ 'number_of_iterations' :500 ,\
'tolerance_constant':1e-06,\
'eta_const':0.2,\
'methodTV': 0 ,\
- 'nonneg': 0 ,\
- 'printingOut': 0
- }
+ 'nonneg': 0}
print ("#############FGP dTV CPU####################")
start_time = timeit.default_timer()
-fgp_dtv_cpu = FGP_dTV(pars['input'],
+(fgp_dtv_cpu,info_vec_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')
+ pars['nonneg'],'cpu')
Qtools = QualityTools(Im, fgp_dtv_cpu)
pars['rmse'] = Qtools.rmse()
diff --git a/demos/demo_cpu_regularisers3D.py b/demos/demo_cpu_regularisers3D.py
index 0f9cd1a..fc1e8e6 100644
--- a/demos/demo_cpu_regularisers3D.py
+++ b/demos/demo_cpu_regularisers3D.py
@@ -277,22 +277,23 @@ imgplot = plt.imshow(noisyVol[10,:,:],cmap="gray")
# set parameters
pars = {'algorithm' : TGV, \
'input' : noisyVol,\
- 'regularisation_parameter':0.04, \
+ 'regularisation_parameter':0.02, \
'alpha1':1.0,\
'alpha0':2.0,\
- 'number_of_iterations' :250 ,\
+ 'number_of_iterations' :500 ,\
'LipshitzConstant' :12 ,\
- }
+ 'tolerance_constant':1e-06}
print ("#############TGV CPU####################")
start_time = timeit.default_timer()
-tgv_cpu3D = TGV(pars['input'],
+(tgv_cpu3D,info_vec_cpu) = TGV(pars['input'],
pars['regularisation_parameter'],
pars['alpha1'],
pars['alpha0'],
pars['number_of_iterations'],
- pars['LipshitzConstant'],'cpu')
-
+ pars['LipshitzConstant'],
+ pars['tolerance_constant'],'cpu')
+
Qtools = QualityTools(idealVol, tgv_cpu3D)
pars['rmse'] = Qtools.rmse()
@@ -325,21 +326,22 @@ imgplot = plt.imshow(noisyVol[10,:,:],cmap="gray")
# set parameters
pars = {'algorithm' : NDF, \
'input' : noisyVol,\
- 'regularisation_parameter':0.025, \
+ 'regularisation_parameter':0.02, \
'edge_parameter':0.015,\
- 'number_of_iterations' :500 ,\
- 'time_marching_parameter':0.025,\
- 'penalty_type': 1
- }
-
+ 'number_of_iterations' :700 ,\
+ 'time_marching_parameter':0.01,\
+ 'penalty_type': 1,\
+ 'tolerance_constant':1e-06}
+
print ("#############NDF CPU################")
start_time = timeit.default_timer()
-ndf_cpu3D = NDF(pars['input'],
+(ndf_cpu3D,info_vec_cpu) = NDF(pars['input'],
pars['regularisation_parameter'],
pars['edge_parameter'],
pars['number_of_iterations'],
pars['time_marching_parameter'],
- pars['penalty_type'])
+ pars['penalty_type'],
+ pars['tolerance_constant'], 'cpu')
Qtools = QualityTools(idealVol, ndf_cpu3D)
@@ -373,19 +375,20 @@ imgplot = plt.imshow(noisyVol[10,:,:],cmap="gray")
# set parameters
pars = {'algorithm' : Diff4th, \
'input' : noisyVol,\
- 'regularisation_parameter':3.5, \
+ 'regularisation_parameter':0.8, \
'edge_parameter':0.02,\
- 'number_of_iterations' :300 ,\
- 'time_marching_parameter':0.0015
- }
-
+ 'number_of_iterations' :500 ,\
+ 'time_marching_parameter':0.001,\
+ 'tolerance_constant':1e-06}
+
print ("#############Diff4th CPU################")
start_time = timeit.default_timer()
-diff4th_cpu3D = Diff4th(pars['input'],
+(diff4th_cpu3D,info_vec_cpu) = Diff4th(pars['input'],
pars['regularisation_parameter'],
pars['edge_parameter'],
pars['number_of_iterations'],
- pars['time_marching_parameter'])
+ pars['time_marching_parameter'],
+ pars['tolerance_constant'],'cpu')
Qtools = QualityTools(idealVol, diff4th_cpu3D)
@@ -420,26 +423,23 @@ imgplot = plt.imshow(noisyVol[10,:,:],cmap="gray")
pars = {'algorithm' : FGP_dTV,\
'input' : noisyVol,\
'refdata' : noisyRef,\
- 'regularisation_parameter':0.04, \
- 'number_of_iterations' :300 ,\
- 'tolerance_constant':0.00001,\
+ 'regularisation_parameter':0.02, \
+ 'number_of_iterations' :500 ,\
+ 'tolerance_constant':1e-06,\
'eta_const':0.2,\
'methodTV': 0 ,\
- 'nonneg': 0 ,\
- 'printingOut': 0
- }
+ 'nonneg': 0}
print ("#############FGP dTV CPU####################")
start_time = timeit.default_timer()
-fgp_dTV_cpu3D = FGP_dTV(pars['input'],
+(fgp_dTV_cpu3D,info_vec_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')
+ pars['nonneg'],'cpu')
Qtools = QualityTools(idealVol, fgp_dTV_cpu3D)
diff --git a/demos/demo_cpu_vs_gpu_regularisers.py b/demos/demo_cpu_vs_gpu_regularisers.py
index e1eb91f..21e3899 100644
--- a/demos/demo_cpu_vs_gpu_regularisers.py
+++ b/demos/demo_cpu_vs_gpu_regularisers.py
@@ -66,16 +66,18 @@ 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
- }
+ 'regularisation_parameter':0.02,\
+ 'number_of_iterations': 1000,\
+ 'time_marching_parameter': 0.001,\
+ 'tolerance_constant':0.0}
+
print ("#############ROF TV CPU####################")
start_time = timeit.default_timer()
-rof_cpu = ROF_TV(pars['input'],
+(rof_cpu, infocpu) = ROF_TV(pars['input'],
pars['regularisation_parameter'],
pars['number_of_iterations'],
- pars['time_marching_parameter'],'cpu')
+ pars['time_marching_parameter'],
+ pars['tolerance_constant'],'cpu')
Qtools = QualityTools(Im, rof_cpu)
pars['rmse'] = Qtools.rmse()
@@ -95,10 +97,11 @@ 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')
+(rof_gpu, infgpu) = ROF_TV(pars['input'],
+ pars['regularisation_parameter'],
+ pars['number_of_iterations'],
+ pars['time_marching_parameter'],
+ pars['tolerance_constant'],'gpu')
Qtools = QualityTools(Im, rof_gpu)
pars['rmse'] = Qtools.rmse()
@@ -130,7 +133,6 @@ if (diff_im.sum() > 1):
print ("Arrays do not match!")
else:
print ("Arrays match")
-
#%%
print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
print ("____________FGP-TV bench___________________")
@@ -146,24 +148,20 @@ 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,\
+ 'regularisation_parameter':0.02, \
+ 'number_of_iterations' :400 ,\
+ 'tolerance_constant':0.0,\
'methodTV': 0 ,\
- 'nonneg': 0 ,\
- 'printingOut': 0
- }
+ 'nonneg': 0}
print ("#############FGP TV CPU####################")
start_time = timeit.default_timer()
-fgp_cpu = FGP_TV(pars['input'],
+(fgp_cpu,infocpu) = FGP_TV(pars['input'],
pars['regularisation_parameter'],
pars['number_of_iterations'],
pars['tolerance_constant'],
pars['methodTV'],
- pars['nonneg'],
- pars['printingOut'],'cpu')
-
+ pars['nonneg'],'cpu')
Qtools = QualityTools(Im, fgp_cpu)
pars['rmse'] = Qtools.rmse()
@@ -184,13 +182,12 @@ plt.title('{}'.format('CPU results'))
print ("##############FGP TV GPU##################")
start_time = timeit.default_timer()
-fgp_gpu = FGP_TV(pars['input'],
+(fgp_gpu,infogpu) = FGP_TV(pars['input'],
pars['regularisation_parameter'],
pars['number_of_iterations'],
pars['tolerance_constant'],
pars['methodTV'],
- pars['nonneg'],
- pars['printingOut'],'gpu')
+ pars['nonneg'],'gpu')
Qtools = QualityTools(Im, fgp_gpu)
pars['rmse'] = Qtools.rmse()
@@ -238,21 +235,18 @@ 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
- }
+ 'regularisation_parameter':0.02, \
+ 'number_of_iterations' :250 ,\
+ 'tolerance_constant':0.0,\
+ 'methodTV': 0}
print ("#############SB-TV CPU####################")
start_time = timeit.default_timer()
-sb_cpu = SB_TV(pars['input'],
+(sb_cpu, info_vec_cpu) = SB_TV(pars['input'],
pars['regularisation_parameter'],
pars['number_of_iterations'],
pars['tolerance_constant'],
- pars['methodTV'],
- pars['printingOut'],'cpu')
+ pars['methodTV'], 'cpu')
Qtools = QualityTools(Im, sb_cpu)
@@ -274,12 +268,11 @@ plt.title('{}'.format('CPU results'))
print ("##############SB TV GPU##################")
start_time = timeit.default_timer()
-sb_gpu = SB_TV(pars['input'],
+(sb_gpu, info_vec_gpu) = SB_TV(pars['input'],
pars['regularisation_parameter'],
pars['number_of_iterations'],
pars['tolerance_constant'],
- pars['methodTV'],
- pars['printingOut'],'gpu')
+ pars['methodTV'], 'gpu')
Qtools = QualityTools(Im, sb_gpu)
pars['rmse'] = Qtools.rmse()
@@ -311,36 +304,36 @@ else:
print ("Arrays match")
#%%
print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("____________TGV bench___________________")
+print ("____________LLT-ROF bench___________________")
print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
## plot
fig = plt.figure()
-plt.suptitle('Comparison of TGV regulariser using CPU and GPU implementations')
+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' : TGV, \
+pars = {'algorithm' : LLT_ROF, \
'input' : u0,\
- 'regularisation_parameter':0.04, \
- 'alpha1':1.0,\
- 'alpha0':2.0,\
- 'number_of_iterations' :400 ,\
- 'LipshitzConstant' :12 ,\
- }
-
-print ("#############TGV CPU####################")
+ 'regularisation_parameterROF':0.01, \
+ 'regularisation_parameterLLT':0.0085, \
+ 'number_of_iterations' : 1000 ,\
+ 'time_marching_parameter' :0.0001 ,\
+ 'tolerance_constant':0.0}
+
+
+print ("#############LLT- ROF CPU####################")
start_time = timeit.default_timer()
-tgv_cpu = TGV(pars['input'],
- pars['regularisation_parameter'],
- pars['alpha1'],
- pars['alpha0'],
+(lltrof_cpu, info_vec_cpu) = LLT_ROF(pars['input'],
+ pars['regularisation_parameterROF'],
+ pars['regularisation_parameterLLT'],
pars['number_of_iterations'],
- pars['LipshitzConstant'],'cpu')
-
-Qtools = QualityTools(Im, tgv_cpu)
+ pars['time_marching_parameter'],
+ pars['tolerance_constant'], 'cpu')
+
+Qtools = QualityTools(Im, lltrof_cpu)
pars['rmse'] = Qtools.rmse()
txtstr = printParametersToString(pars)
@@ -353,21 +346,22 @@ 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")
+imgplot = plt.imshow(lltrof_cpu, cmap="gray")
plt.title('{}'.format('CPU results'))
-print ("##############TGV GPU##################")
+print ("#############LLT- ROF GPU####################")
start_time = timeit.default_timer()
-tgv_gpu = TGV(pars['input'],
- pars['regularisation_parameter'],
- pars['alpha1'],
- pars['alpha0'],
+(lltrof_gpu, info_vec_gpu) = LLT_ROF(pars['input'],
+ pars['regularisation_parameterROF'],
+ pars['regularisation_parameterLLT'],
pars['number_of_iterations'],
- pars['LipshitzConstant'],'gpu')
-
-Qtools = QualityTools(Im, tgv_gpu)
+ pars['time_marching_parameter'],
+ pars['tolerance_constant'], 'gpu')
+
+Qtools = QualityTools(Im, lltrof_gpu)
pars['rmse'] = Qtools.rmse()
-pars['algorithm'] = TGV
+
+pars['algorithm'] = LLT_ROF
txtstr = printParametersToString(pars)
txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
print (txtstr)
@@ -378,13 +372,13 @@ 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")
+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(tgv_gpu))
-diff_im = abs(tgv_cpu - tgv_gpu)
+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")
@@ -395,34 +389,37 @@ else:
print ("Arrays match")
#%%
print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
-print ("____________LLT-ROF bench___________________")
+print ("____________TGV bench___________________")
print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
## plot
fig = plt.figure()
-plt.suptitle('Comparison of LLT-ROF regulariser using CPU and GPU implementations')
+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' : LLT_ROF, \
+pars = {'algorithm' : TGV, \
'input' : u0,\
- 'regularisation_parameterROF':0.04, \
- 'regularisation_parameterLLT':0.01, \
- 'number_of_iterations' :4500 ,\
- 'time_marching_parameter' :0.00002 ,\
- }
+ 'regularisation_parameter':0.02, \
+ 'alpha1':1.0,\
+ 'alpha0':2.0,\
+ 'number_of_iterations' :1000 ,\
+ 'LipshitzConstant' :12 ,\
+ 'tolerance_constant':0.0}
-print ("#############LLT- ROF CPU####################")
+print ("#############TGV CPU####################")
start_time = timeit.default_timer()
-lltrof_cpu = LLT_ROF(pars['input'],
- pars['regularisation_parameterROF'],
- pars['regularisation_parameterLLT'],
+(tgv_cpu, info_vec_cpu) = TGV(pars['input'],
+ pars['regularisation_parameter'],
+ pars['alpha1'],
+ pars['alpha0'],
pars['number_of_iterations'],
- pars['time_marching_parameter'],'cpu')
-
-Qtools = QualityTools(Im, lltrof_cpu)
+ pars['LipshitzConstant'],
+ pars['tolerance_constant'],'cpu')
+
+Qtools = QualityTools(Im, tgv_cpu)
pars['rmse'] = Qtools.rmse()
txtstr = printParametersToString(pars)
@@ -435,21 +432,22 @@ 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")
+imgplot = plt.imshow(tgv_cpu, cmap="gray")
plt.title('{}'.format('CPU results'))
-print ("#############LLT- ROF GPU####################")
+print ("##############TGV GPU##################")
start_time = timeit.default_timer()
-lltrof_gpu = LLT_ROF(pars['input'],
- pars['regularisation_parameterROF'],
- pars['regularisation_parameterLLT'],
+(tgv_gpu, info_vec_gpu) = TGV(pars['input'],
+ pars['regularisation_parameter'],
+ pars['alpha1'],
+ pars['alpha0'],
pars['number_of_iterations'],
- pars['time_marching_parameter'],'gpu')
-
-Qtools = QualityTools(Im, lltrof_gpu)
+ pars['LipshitzConstant'],
+ pars['tolerance_constant'],'gpu')
+
+Qtools = QualityTools(Im, tgv_gpu)
pars['rmse'] = Qtools.rmse()
-
-pars['algorithm'] = LLT_ROF
+pars['algorithm'] = TGV
txtstr = printParametersToString(pars)
txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
print (txtstr)
@@ -460,13 +458,13 @@ 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")
+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(lltrof_gpu))
-diff_im = abs(lltrof_cpu - lltrof_gpu)
+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")
@@ -490,21 +488,22 @@ 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
- }
-
+ 'regularisation_parameter':0.02, \
+ 'edge_parameter':0.017,\
+ 'number_of_iterations' :1500 ,\
+ 'time_marching_parameter':0.01,\
+ 'penalty_type':1,\
+ 'tolerance_constant':0.0}
+
print ("#############NDF CPU####################")
start_time = timeit.default_timer()
-ndf_cpu = NDF(pars['input'],
+(ndf_cpu,info_vec_cpu) = NDF(pars['input'],
pars['regularisation_parameter'],
pars['edge_parameter'],
pars['number_of_iterations'],
pars['time_marching_parameter'],
- pars['penalty_type'],'cpu')
+ pars['penalty_type'],
+ pars['tolerance_constant'],'cpu')
Qtools = QualityTools(Im, ndf_cpu)
pars['rmse'] = Qtools.rmse()
@@ -525,12 +524,13 @@ plt.title('{}'.format('CPU results'))
print ("##############NDF GPU##################")
start_time = timeit.default_timer()
-ndf_gpu = NDF(pars['input'],
+(ndf_gpu,info_vec_gpu) = NDF(pars['input'],
pars['regularisation_parameter'],
pars['edge_parameter'],
pars['number_of_iterations'],
pars['time_marching_parameter'],
- pars['penalty_type'],'gpu')
+ pars['penalty_type'],
+ pars['tolerance_constant'],'gpu')
Qtools = QualityTools(Im, ndf_gpu)
pars['rmse'] = Qtools.rmse()
@@ -576,19 +576,20 @@ imgplot = plt.imshow(u0,cmap="gray")
# set parameters
pars = {'algorithm' : Diff4th, \
'input' : u0,\
- 'regularisation_parameter':3.5, \
+ 'regularisation_parameter':0.8, \
'edge_parameter':0.02,\
- 'number_of_iterations' :500 ,\
- 'time_marching_parameter':0.001
- }
+ 'number_of_iterations' :1500 ,\
+ 'time_marching_parameter':0.001,\
+ 'tolerance_constant':0.0}
print ("#############Diff4th CPU####################")
start_time = timeit.default_timer()
-diff4th_cpu = Diff4th(pars['input'],
+(diff4th_cpu,info_vec_cpu) = Diff4th(pars['input'],
pars['regularisation_parameter'],
pars['edge_parameter'],
pars['number_of_iterations'],
- pars['time_marching_parameter'],'cpu')
+ pars['time_marching_parameter'],
+ pars['tolerance_constant'],'cpu')
Qtools = QualityTools(Im, diff4th_cpu)
pars['rmse'] = Qtools.rmse()
@@ -608,11 +609,12 @@ plt.title('{}'.format('CPU results'))
print ("##############Diff4th GPU##################")
start_time = timeit.default_timer()
-diff4th_gpu = Diff4th(pars['input'],
+(diff4th_gpu,info_vec_gpu) = Diff4th(pars['input'],
pars['regularisation_parameter'],
pars['edge_parameter'],
pars['number_of_iterations'],
- pars['time_marching_parameter'], 'gpu')
+ pars['time_marching_parameter'],
+ pars['tolerance_constant'],'gpu')
Qtools = QualityTools(Im, diff4th_gpu)
pars['rmse'] = Qtools.rmse()
@@ -659,26 +661,23 @@ imgplot = plt.imshow(u0,cmap="gray")
pars = {'algorithm' : FGP_dTV, \
'input' : u0,\
'refdata' : u_ref,\
- 'regularisation_parameter':0.04, \
- 'number_of_iterations' :1000 ,\
- 'tolerance_constant':1e-07,\
+ 'regularisation_parameter':0.02, \
+ 'number_of_iterations' :500 ,\
+ 'tolerance_constant':0.0,\
'eta_const':0.2,\
'methodTV': 0 ,\
- 'nonneg': 0 ,\
- 'printingOut': 0
- }
+ 'nonneg': 0}
print ("#############FGP dTV CPU####################")
start_time = timeit.default_timer()
-fgp_dtv_cpu = FGP_dTV(pars['input'],
+(fgp_dtv_cpu,info_vec_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')
+ pars['nonneg'],'cpu')
Qtools = QualityTools(Im, fgp_dtv_cpu)
pars['rmse'] = Qtools.rmse()
@@ -699,15 +698,14 @@ plt.title('{}'.format('CPU results'))
print ("##############FGP dTV GPU##################")
start_time = timeit.default_timer()
-fgp_dtv_gpu = FGP_dTV(pars['input'],
+(fgp_dtv_gpu,info_vec_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')
+ pars['nonneg'],'gpu')
Qtools = QualityTools(Im, fgp_dtv_gpu)
pars['rmse'] = Qtools.rmse()
pars['algorithm'] = FGP_dTV
diff --git a/demos/demo_gpu_regularisers.py b/demos/demo_gpu_regularisers.py
index 6aec283..3efcfce 100644
--- a/demos/demo_gpu_regularisers.py
+++ b/demos/demo_gpu_regularisers.py
@@ -84,7 +84,7 @@ imgplot = plt.imshow(u0,cmap="gray")
pars = {'algorithm': ROF_TV, \
'input' : u0,\
'regularisation_parameter':0.02,\
- 'number_of_iterations': 6000,\
+ 'number_of_iterations': 4000,\
'time_marching_parameter': 0.001,\
'tolerance_constant':1e-06}
@@ -261,21 +261,22 @@ imgplot = plt.imshow(u0,cmap="gray")
# set parameters
pars = {'algorithm' : TGV, \
'input' : u0,\
- 'regularisation_parameter':0.04, \
+ 'regularisation_parameter':0.02, \
'alpha1':1.0,\
'alpha0':2.0,\
- 'number_of_iterations' :1250 ,\
+ 'number_of_iterations' :1000 ,\
'LipshitzConstant' :12 ,\
- }
+ 'tolerance_constant':1e-06}
print ("#############TGV CPU####################")
start_time = timeit.default_timer()
-tgv_gpu = TGV(pars['input'],
+(tgv_gpu, info_vec_gpu) = TGV(pars['input'],
pars['regularisation_parameter'],
pars['alpha1'],
pars['alpha0'],
pars['number_of_iterations'],
- pars['LipshitzConstant'],'gpu')
+ pars['LipshitzConstant'],
+ pars['tolerance_constant'],'gpu')
Qtools = QualityTools(Im, tgv_gpu)
pars['rmse'] = Qtools.rmse()
@@ -307,21 +308,22 @@ 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
- }
+ 'regularisation_parameter':0.02, \
+ 'edge_parameter':0.017,\
+ 'number_of_iterations' :1500 ,\
+ 'time_marching_parameter':0.01,\
+ 'penalty_type':1,\
+ 'tolerance_constant':1e-06}
print ("##############NDF GPU##################")
start_time = timeit.default_timer()
-ndf_gpu = NDF(pars['input'],
+(ndf_gpu,info_vec_gpu) = NDF(pars['input'],
pars['regularisation_parameter'],
pars['edge_parameter'],
pars['number_of_iterations'],
pars['time_marching_parameter'],
- pars['penalty_type'],'gpu')
+ pars['penalty_type'],
+ pars['tolerance_constant'],'gpu')
Qtools = QualityTools(Im, ndf_gpu)
pars['rmse'] = Qtools.rmse()
@@ -354,19 +356,20 @@ imgplot = plt.imshow(u0,cmap="gray")
# set parameters
pars = {'algorithm' : Diff4th, \
'input' : u0,\
- 'regularisation_parameter':3.5, \
+ 'regularisation_parameter':0.8, \
'edge_parameter':0.02,\
- 'number_of_iterations' :500 ,\
- 'time_marching_parameter':0.0015
- }
+ 'number_of_iterations' :5500 ,\
+ 'time_marching_parameter':0.001,\
+ 'tolerance_constant':1e-06}
print ("#############DIFF4th CPU################")
start_time = timeit.default_timer()
-diff4_gpu = Diff4th(pars['input'],
+(diff4_gpu,info_vec_gpu) = Diff4th(pars['input'],
pars['regularisation_parameter'],
pars['edge_parameter'],
pars['number_of_iterations'],
- pars['time_marching_parameter'],'gpu')
+ pars['time_marching_parameter'],
+ pars['tolerance_constant'],'gpu')
Qtools = QualityTools(Im, diff4_gpu)
pars['algorithm'] = Diff4th
@@ -470,26 +473,23 @@ imgplot = plt.imshow(u0,cmap="gray")
pars = {'algorithm' : FGP_dTV, \
'input' : u0,\
'refdata' : u_ref,\
- 'regularisation_parameter':0.04, \
- 'number_of_iterations' :2000 ,\
+ 'regularisation_parameter':0.02, \
+ 'number_of_iterations' :500 ,\
'tolerance_constant':1e-06,\
'eta_const':0.2,\
'methodTV': 0 ,\
- 'nonneg': 0 ,\
- 'printingOut': 0
- }
+ 'nonneg': 0}
print ("##############FGP dTV GPU##################")
start_time = timeit.default_timer()
-fgp_dtv_gpu = FGP_dTV(pars['input'],
+(fgp_dtv_gpu,info_vec_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')
+ pars['nonneg'],'gpu')
Qtools = QualityTools(Im, fgp_dtv_gpu)
pars['rmse'] = Qtools.rmse()
diff --git a/demos/demo_gpu_regularisers3D.py b/demos/demo_gpu_regularisers3D.py
index 1a13c86..ccf9694 100644
--- a/demos/demo_gpu_regularisers3D.py
+++ b/demos/demo_gpu_regularisers3D.py
@@ -277,21 +277,22 @@ imgplot = plt.imshow(noisyVol[10,:,:],cmap="gray")
# set parameters
pars = {'algorithm' : TGV, \
'input' : noisyVol,\
- 'regularisation_parameter':0.04, \
+ 'regularisation_parameter':0.02, \
'alpha1':1.0,\
'alpha0':2.0,\
- 'number_of_iterations' :600 ,\
+ 'number_of_iterations' :500 ,\
'LipshitzConstant' :12 ,\
- }
+ 'tolerance_constant':1e-06}
print ("#############TGV GPU####################")
start_time = timeit.default_timer()
-tgv_gpu3D = TGV(pars['input'],
+(tgv_gpu3D,info_vec_gpu) = TGV(pars['input'],
pars['regularisation_parameter'],
pars['alpha1'],
pars['alpha0'],
pars['number_of_iterations'],
- pars['LipshitzConstant'],'gpu')
+ pars['LipshitzConstant'],
+ pars['tolerance_constant'],'gpu')
Qtools = QualityTools(idealVol, tgv_gpu3D)
pars['rmse'] = Qtools.rmse()
@@ -322,21 +323,23 @@ imgplot = plt.imshow(noisyVol[10,:,:],cmap="gray")
# set parameters
pars = {'algorithm' : NDF, \
'input' : noisyVol,\
- 'regularisation_parameter':0.025, \
+ 'regularisation_parameter':0.02, \
'edge_parameter':0.015,\
- 'number_of_iterations' :500 ,\
- 'time_marching_parameter':0.025,\
- 'penalty_type': 1
- }
+ 'number_of_iterations' :700 ,\
+ 'time_marching_parameter':0.01,\
+ 'penalty_type': 1,\
+ 'tolerance_constant':1e-06}
+
print ("#############NDF GPU####################")
start_time = timeit.default_timer()
-ndf_gpu3D = NDF(pars['input'],
+(ndf_gpu3D,info_vec_gpu) = NDF(pars['input'],
pars['regularisation_parameter'],
pars['edge_parameter'],
pars['number_of_iterations'],
pars['time_marching_parameter'],
- pars['penalty_type'],'gpu')
+ pars['penalty_type'],
+ pars['tolerance_constant'], 'gpu')
Qtools = QualityTools(idealVol, ndf_gpu3D)
pars['rmse'] = Qtools.rmse()
@@ -368,19 +371,20 @@ imgplot = plt.imshow(noisyVol[10,:,:],cmap="gray")
# set parameters
pars = {'algorithm' : Diff4th, \
'input' : noisyVol,\
- 'regularisation_parameter':3.5, \
+ 'regularisation_parameter':0.8, \
'edge_parameter':0.02,\
- 'number_of_iterations' :300 ,\
- 'time_marching_parameter':0.0015
- }
+ 'number_of_iterations' :500 ,\
+ 'time_marching_parameter':0.001,\
+ 'tolerance_constant':1e-06}
print ("#############DIFF4th CPU################")
start_time = timeit.default_timer()
-diff4_gpu3D = Diff4th(pars['input'],
+(diff4_gpu3D,info_vec_gpu) = Diff4th(pars['input'],
pars['regularisation_parameter'],
pars['edge_parameter'],
pars['number_of_iterations'],
- pars['time_marching_parameter'],'gpu')
+ pars['time_marching_parameter'],
+ pars['tolerance_constant'],'gpu')
Qtools = QualityTools(idealVol, diff4_gpu3D)
pars['rmse'] = Qtools.rmse()
@@ -410,29 +414,27 @@ a.set_title('Noisy Image')
imgplot = plt.imshow(noisyVol[10,:,:],cmap="gray")
# set parameters
-pars = {'algorithm' : FGP_dTV, \
+pars = {'algorithm' : FGP_dTV,\
'input' : noisyVol,\
'refdata' : noisyRef,\
- 'regularisation_parameter':0.04, \
- 'number_of_iterations' :300 ,\
- 'tolerance_constant':0.00001,\
+ 'regularisation_parameter':0.02,
+ 'number_of_iterations' :500 ,\
+ 'tolerance_constant':1e-06,\
'eta_const':0.2,\
'methodTV': 0 ,\
- 'nonneg': 0 ,\
- 'printingOut': 0
- }
+ 'nonneg': 0}
print ("#############FGP TV GPU####################")
start_time = timeit.default_timer()
-fgp_dTV_gpu3D = FGP_dTV(pars['input'],
+(fgp_dTV_gpu3D,info_vec_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')
+ pars['nonneg'],'gpu')
+
Qtools = QualityTools(idealVol, fgp_dTV_gpu3D)
pars['rmse'] = Qtools.rmse()