summaryrefslogtreecommitdiffstats
path: root/Wrappers/Python/demos
diff options
context:
space:
mode:
authorDaniil Kazantsev <dkazanc@hotmail.com>2018-05-01 15:16:49 +0100
committerDaniil Kazantsev <dkazanc@hotmail.com>2018-05-01 15:16:49 +0100
commit42a10faa06bd56bff3f0f1804ddcdf1a3e1283cd (patch)
treeb3246b624c4bfa5b07623e2eae8a00f3b28a75cd /Wrappers/Python/demos
parent033c2030a05c7aa4c832e7a5e9fd13346d05e33d (diff)
downloadregularization-42a10faa06bd56bff3f0f1804ddcdf1a3e1283cd.tar.gz
regularization-42a10faa06bd56bff3f0f1804ddcdf1a3e1283cd.tar.bz2
regularization-42a10faa06bd56bff3f0f1804ddcdf1a3e1283cd.tar.xz
regularization-42a10faa06bd56bff3f0f1804ddcdf1a3e1283cd.zip
inpaint NVM added
Diffstat (limited to 'Wrappers/Python/demos')
-rw-r--r--Wrappers/Python/demos/demo_cpu_inpainters.py45
1 files changed, 43 insertions, 2 deletions
diff --git a/Wrappers/Python/demos/demo_cpu_inpainters.py b/Wrappers/Python/demos/demo_cpu_inpainters.py
index b067b11..ab7ed2f 100644
--- a/Wrappers/Python/demos/demo_cpu_inpainters.py
+++ b/Wrappers/Python/demos/demo_cpu_inpainters.py
@@ -10,7 +10,7 @@ import numpy as np
import os
import timeit
from scipy import io
-from ccpi.filters.regularisers import NDF_INP
+from ccpi.filters.regularisers import NDF_INP, NVM_INP
from qualitymetrics import rmse
###############################################################################
def printParametersToString(pars):
@@ -146,4 +146,45 @@ 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'))
-#%% \ No newline at end of file
+#%%
+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' :20
+ }
+
+start_time = timeit.default_timer()
+nvm_inp = NVM_INP(pars['input'],
+ pars['maskData'],
+ pars['SW_increment'],
+ pars['number_of_iterations'])
+
+rms = rmse(sino_full, nvm_inp)
+pars['rmse'] = rms
+
+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'))
+#%%