summaryrefslogtreecommitdiffstats
path: root/Wrappers/Python/test
diff options
context:
space:
mode:
authorDaniil Kazantsev <dkazanc@hotmail.com>2018-02-09 16:11:04 +0000
committerEdoardo Pasca <edo.paskino@gmail.com>2018-02-09 16:24:47 +0000
commitd57b398a39d64e2ed8ab7bbc65be5e04f013d5ea (patch)
treefe57ed1f63ce07eefe7f979acc175caa641d6f9f /Wrappers/Python/test
parent821c37c37c60dd76a102867d7a8e8c0d6e06af70 (diff)
downloadregularization-d57b398a39d64e2ed8ab7bbc65be5e04f013d5ea.tar.gz
regularization-d57b398a39d64e2ed8ab7bbc65be5e04f013d5ea.tar.bz2
regularization-d57b398a39d64e2ed8ab7bbc65be5e04f013d5ea.tar.xz
regularization-d57b398a39d64e2ed8ab7bbc65be5e04f013d5ea.zip
GPU regularizers fixed, the demo runs smoothly
Diffstat (limited to 'Wrappers/Python/test')
-rw-r--r--Wrappers/Python/test/test_gpu_regularizers.py54
1 files changed, 29 insertions, 25 deletions
diff --git a/Wrappers/Python/test/test_gpu_regularizers.py b/Wrappers/Python/test/test_gpu_regularizers.py
index 18fbdd3..735a25d 100644
--- a/Wrappers/Python/test/test_gpu_regularizers.py
+++ b/Wrappers/Python/test/test_gpu_regularizers.py
@@ -40,7 +40,8 @@ filename = os.path.join(".." , ".." , ".." , "data" ,"lena_gray_512.tif")
Im = plt.imread(filename)
Im = np.asarray(Im, dtype='float32')
-perc = 0.15
+Im = Im/255
+perc = 0.075
u0 = Im + np.random.normal(loc = Im ,
scale = perc * Im ,
size = np.shape(Im))
@@ -53,49 +54,52 @@ fig = plt.figure()
a=fig.add_subplot(2,3,1)
a.set_title('noise')
-imgplot = plt.imshow(u0#,cmap="gray"
- )
+imgplot = plt.imshow(u0,cmap="gray")
## Diff4thHajiaboli
start_time = timeit.default_timer()
pars = {'algorithm' : Diff4thHajiaboli , \
'input' : u0,
- 'regularization_parameter':0.02 , \
-'number_of_iterations' :150 ,\
-'edge_preserving_parameter':0.001
+ 'edge_preserv_parameter':0.1 , \
+'number_of_iterations' :250 ,\
+'time_marching_parameter':0.03 ,\
+'regularization_parameter':0.7
}
+
+
d4h = Diff4thHajiaboli(pars['input'],
- pars['regularization_parameter'],
+ pars['edge_preserv_parameter'],
pars['number_of_iterations'],
- pars['edge_preserving_parameter'])
+ pars['time_marching_parameter'],
+ pars['regularization_parameter'])
+rms = rmse(Im, d4h)
+pars['rmse'] = rms
txtstr = printParametersToString(pars)
txtstr += "%s = %.3fs" % ('elapsed time',timeit.default_timer() - start_time)
print (txtstr)
a=fig.add_subplot(2,3,2)
# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.5)
+props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
# place a text box in upper left in axes coords
-a.text(0.05, 0.95, txtstr, transform=a.transAxes, fontsize=14,
+a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=12,
verticalalignment='top', bbox=props)
-imgplot = plt.imshow(d4h #, cmap="gray"
- )
+imgplot = plt.imshow(d4h, cmap="gray")
a=fig.add_subplot(2,3,5)
# these are matplotlib.patch.Patch properties
props = dict(boxstyle='round', facecolor='wheat', alpha=0.5)
# place a text box in upper left in axes coords
-a.text(0.05, 0.95, 'd4h - u0', transform=a.transAxes, fontsize=14,
+a.text(0.05, 0.95, 'd4h - u0', transform=a.transAxes, fontsize=12,
verticalalignment='top', bbox=props)
-imgplot = plt.imshow(d4h - u0 #, cmap="gray"
- )
+imgplot = plt.imshow((d4h - u0)**2, cmap="gray")
## Patch Based Regul NML
start_time = timeit.default_timer()
-
+"""
pars = {'algorithm' : NML , \
'input' : u0,
'SearchW_real':3 , \
@@ -103,13 +107,15 @@ pars = {'algorithm' : NML , \
'h':0.05 ,#
'lambda' : 0.08
}
+"""
pars = {
'input' : u0,
- 'regularization_parameter': 0.05,\
+ 'regularization_parameter': 0.01,\
'searching_window_ratio':3, \
'similarity_window_ratio':1,\
- 'PB_filtering_parameter': 0.06
+ 'PB_filtering_parameter': 0.2
}
+
nml = NML(pars['input'],
pars['searching_window_ratio'],
pars['similarity_window_ratio'],
@@ -123,12 +129,11 @@ print (txtstr)
a=fig.add_subplot(2,3,3)
# these are matplotlib.patch.Patch properties
-props = dict(boxstyle='round', facecolor='wheat', alpha=0.5)
+props = dict(boxstyle='round', facecolor='wheat', alpha=0.75)
# place a text box in upper left in axes coords
-a.text(0.05, 0.95, txtstr, transform=a.transAxes, fontsize=14,
+a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=12,
verticalalignment='top', bbox=props)
-imgplot = plt.imshow(nml #, cmap="gray"
- )
+imgplot = plt.imshow(nml, cmap="gray")
a=fig.add_subplot(2,3,6)
@@ -137,8 +142,7 @@ props = dict(boxstyle='round', facecolor='wheat', alpha=0.5)
# place a text box in upper left in axes coords
a.text(0.05, 0.95, 'nml - u0', transform=a.transAxes, fontsize=14,
verticalalignment='top', bbox=props)
-imgplot = plt.imshow(nml - u0 #, cmap="gray"
- )
+imgplot = plt.imshow((nml - u0)**2, cmap="gray")
plt.show()
- \ No newline at end of file
+