summaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
authordkazanc <dkazanc@hotmail.com>2019-11-26 14:51:34 +0000
committerdkazanc <dkazanc@hotmail.com>2019-11-26 14:51:34 +0000
commit494a857b830fce5e786dfc058f68bf78d9673ba6 (patch)
treee2f2156457848c6cd8ba4fc28c4ad5eac7fd893d /demos
parent5e7b28053dfe06008657bcdb68462dc3d84b8a22 (diff)
downloadregularization-494a857b830fce5e786dfc058f68bf78d9673ba6.tar.gz
regularization-494a857b830fce5e786dfc058f68bf78d9673ba6.tar.bz2
regularization-494a857b830fce5e786dfc058f68bf78d9673ba6.tar.xz
regularization-494a857b830fce5e786dfc058f68bf78d9673ba6.zip
PDTV 3D verision
Diffstat (limited to 'demos')
-rw-r--r--demos/demo_cpu_regularisers.py2
-rw-r--r--demos/demo_cpu_regularisers3D.py51
2 files changed, 49 insertions, 4 deletions
diff --git a/demos/demo_cpu_regularisers.py b/demos/demo_cpu_regularisers.py
index d0bbe63..9888743 100644
--- a/demos/demo_cpu_regularisers.py
+++ b/demos/demo_cpu_regularisers.py
@@ -179,7 +179,7 @@ pars = {'algorithm' : PD_TV, \
'tolerance_constant':1e-06,\
'methodTV': 0 ,\
'nonneg': 1,
- 'lipschitz_const' : 12}
+ 'lipschitz_const' : 6}
print ("#############PD TV CPU####################")
start_time = timeit.default_timer()
diff --git a/demos/demo_cpu_regularisers3D.py b/demos/demo_cpu_regularisers3D.py
index fc1e8e6..349300f 100644
--- a/demos/demo_cpu_regularisers3D.py
+++ b/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, TGV, LLT_ROF, FGP_dTV, NDF, Diff4th
+from ccpi.filters.regularisers import ROF_TV, FGP_TV, PD_TV, SB_TV, TGV, LLT_ROF, FGP_dTV, NDF, Diff4th
from ccpi.supp.qualitymetrics import QualityTools
###############################################################################
def printParametersToString(pars):
@@ -30,8 +30,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)
@@ -169,7 +168,53 @@ 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 ("_______________PD-TV (3D)__________________")
+print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
+
+## plot
+fig = plt.figure()
+plt.suptitle('Performance of PD-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' : PD_TV, \
+ 'input' : noisyVol,\
+ 'regularisation_parameter':0.02, \
+ 'number_of_iterations' :1000 ,\
+ 'tolerance_constant': 1e-06,\
+ 'methodTV': 0 ,\
+ 'lipschitz_const' : 12,\
+ 'nonneg': 0}
+
+print ("#############FGP TV GPU####################")
+start_time = timeit.default_timer()
+(pd_cpu3D,info_vec_cpu) = PD_TV(pars['input'],
+ pars['regularisation_parameter'],
+ pars['number_of_iterations'],
+ pars['tolerance_constant'],
+ pars['methodTV'],
+ pars['nonneg'],
+ pars['lipschitz_const'], 'cpu')
+
+Qtools = QualityTools(idealVol, pd_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(pd_cpu3D[10,:,:], cmap="gray")
+plt.title('{}'.format('Recovered volume on the CPU using PD-TV'))
#%%
print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
print ("_______________SB-TV (3D)_________________")