From 39baef90c4b209090f006e5308653cb0a3348c4e Mon Sep 17 00:00:00 2001 From: dkazanc Date: Wed, 6 Mar 2019 15:13:58 +0000 Subject: tol work --- demos/SoftwareX_supp/Demo_VolumeDenoise.py | 62 +++++++++++++++++++++++++++++- demos/demoMatlab_denoise.m | 12 +++--- demos/demo_cpu_regularisers.py | 16 ++++---- 3 files changed, 75 insertions(+), 15 deletions(-) (limited to 'demos') diff --git a/demos/SoftwareX_supp/Demo_VolumeDenoise.py b/demos/SoftwareX_supp/Demo_VolumeDenoise.py index 2387e94..17cdf4d 100644 --- a/demos/SoftwareX_supp/Demo_VolumeDenoise.py +++ b/demos/SoftwareX_supp/Demo_VolumeDenoise.py @@ -60,13 +60,14 @@ plt.title('3D Phantom, sagittal view') plt.show() #%% print ("____________________Applying regularisers_______________________") +print ("________________________________________________________________") print ("#############ROF TV CPU####################") # set parameters pars = {'algorithm': ROF_TV, \ 'input' : phantom_noise,\ 'regularisation_parameter':0.04,\ - 'number_of_iterations': 100,\ + 'number_of_iterations': 600,\ 'time_marching_parameter': 0.0025 } @@ -116,6 +117,65 @@ win2d = win * (win.T) ssim_rof = Qtools.ssim(win2d) print("ROF-TV (gpu) ____ RMSE: {}, MMSIM: {}, run time: {} sec".format(RMSE_rof,ssim_rof[0],Run_time_rof)) +#%% +print ("#############FGP TV CPU####################") +# set parameters +pars = {'algorithm':FGP_TV, \ + 'input' : phantom_noise,\ + 'regularisation_parameter':0.04,\ + 'number_of_iterations': 300,\ + 'time_marching_parameter': 0.0025,\ + 'tolerance_constant':1e-05,\ + } + +tic=timeit.default_timer() +fgp_cpu3D = FGP_TV(pars['input'], + pars['regularisation_parameter'], + pars['number_of_iterations'], + pars['time_marching_parameter'],'cpu') +toc=timeit.default_timer() + +Run_time_fgp = toc - tic +Qtools = QualityTools(phantom_tm, fgp_cpu3D) +RMSE_rof = Qtools.rmse() + +# SSIM measure +Qtools = QualityTools(phantom_tm[128,:,:]*255, fgp_cpu3D[128,:,:]*235) +win = np.array([gaussian(11, 1.5)]) +win2d = win * (win.T) +ssim_fgp = Qtools.ssim(win2d) + +print("FGP-TV (cpu) ____ RMSE: {}, MMSIM: {}, run time: {} sec".format(RMSE_rof,ssim_fgp[0],Run_time_fgp)) +#%% +print ("#############FGP TV GPU####################") +# set parameters +pars = {'algorithm':FGP_TV, \ + 'input' : phantom_noise,\ + 'regularisation_parameter':0.04,\ + 'number_of_iterations': 300,\ + 'time_marching_parameter': 0.0025,\ + 'tolerance_constant':1e-05,\ + } +tic=timeit.default_timer() +fgp_gpu3D = FGP_TV(pars['input'], + pars['regularisation_parameter'], + pars['number_of_iterations'], + pars['time_marching_parameter'],'gpu') +toc=timeit.default_timer() + +Run_time_fgp = toc - tic +Qtools = QualityTools(phantom_tm, fgp_gpu3D) +RMSE_rof = Qtools.rmse() + +# SSIM measure +Qtools = QualityTools(phantom_tm[128,:,:]*255, fgp_gpu3D[128,:,:]*235) +win = np.array([gaussian(11, 1.5)]) +win2d = win * (win.T) +ssim_fgp = Qtools.ssim(win2d) + +print("FGP-TV (gpu) ____ RMSE: {}, MMSIM: {}, run time: {} sec".format(RMSE_rof,ssim_fgp[0],Run_time_fgp)) #%% + + diff --git a/demos/demoMatlab_denoise.m b/demos/demoMatlab_denoise.m index 5e92ee1..fa81f6d 100644 --- a/demos/demoMatlab_denoise.m +++ b/demos/demoMatlab_denoise.m @@ -2,9 +2,11 @@ clear; close all fsep = '/'; -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); +%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'); +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'; addpath(Path1); addpath(Path2); addpath(Path3); @@ -34,8 +36,8 @@ figure; imshow(u_rof, [0 1]); title('ROF-TV denoised image (CPU)'); %% 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 +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; energyfunc_val_fgp = TV_energy(single(u_fgp),single(u0),lambda_reg, 1); % get energy function value rmseFGP = (RMSE(u_fgp(:),Im(:))); diff --git a/demos/demo_cpu_regularisers.py b/demos/demo_cpu_regularisers.py index d34607a..e58ed2f 100644 --- a/demos/demo_cpu_regularisers.py +++ b/demos/demo_cpu_regularisers.py @@ -30,8 +30,9 @@ def printParametersToString(pars): txt += '\n' return txt ############################################################################### -#%% -filename = os.path.join( "data" ,"lena_gray_512.tif") + +# filename = os.path.join( "data" ,"lena_gray_512.tif") +filename = "/home/kjy41806/Documents/SOFT/CCPi-Regularisation-Toolkit/test/lena_gray_512.tif" # read image Im = plt.imread(filename) @@ -127,23 +128,20 @@ imgplot = plt.imshow(u0,cmap="gray") pars = {'algorithm' : FGP_TV, \ 'input' : u0,\ 'regularisation_parameter':0.04, \ - 'number_of_iterations' :2000 ,\ + 'number_of_iterations' :200 ,\ 'tolerance_constant':1e-06,\ '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,info_vec = 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() -- cgit v1.2.3