Skip to content

Commit

Permalink
removed cython code
Browse files Browse the repository at this point in the history
  • Loading branch information
paskino committed May 13, 2024
1 parent b986325 commit 3e930d9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 743 deletions.
24 changes: 15 additions & 9 deletions demos/demo_cpu_regularisers3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def printParametersToString(pars):
return txt
###############################################################################

os.chdir(os.path.join("..", "demos"))
# os.chdir(os.path.join("..", "demos"))
os.chdir("C:/Users/ofn77899/Dev/CCPi-Regularisation-Toolkit/demos")
filename = os.path.join( "data" ,"lena_gray_512.tif")

# read image
Expand Down Expand Up @@ -70,7 +71,7 @@ def printParametersToString(pars):
Im = Im2
del Im2
"""
slices = 15
slices = 20

noisyVol = np.zeros((slices,N,M),dtype='float32')
noisyRef = np.zeros((slices,N,M),dtype='float32')
Expand All @@ -90,14 +91,15 @@ def printParametersToString(pars):
fig = plt.figure()
plt.suptitle('Performance of ROF-TV regulariser using the CPU')
a=fig.add_subplot(1,2,1)
a.set_title('Noisy 15th slice of a volume')
imgplot = plt.imshow(noisyVol[10,:,:],cmap="gray")
slice_num = 10
a.set_title(f'Noisy slice {slice_num} of a volume')
imgplot = plt.imshow(noisyVol[slice_num,:,:],cmap="gray")

# set parameters
pars = {'algorithm': ROF_TV, \
'input' : noisyVol,\
'regularisation_parameter':0.02,\
'number_of_iterations': 7000,\
'regularisation_parameter':0.02 * 100,\
'number_of_iterations': 200,\
'time_marching_parameter': 0.0007,\
'tolerance_constant':1e-06}

Expand All @@ -108,7 +110,7 @@ def printParametersToString(pars):
pars['regularisation_parameter'],
pars['number_of_iterations'],
pars['time_marching_parameter'],
pars['tolerance_constant'], device='cpu', infovector=info_vec_cpu)
pars['tolerance_constant'], device='gpu', infovector=info_vec_cpu)

Qtools = QualityTools(idealVol, rof_cpu3D)
pars['rmse'] = Qtools.rmse()
Expand All @@ -126,6 +128,7 @@ def printParametersToString(pars):
imgplot = plt.imshow(rof_cpu3D[10,:,:], cmap="gray")
plt.title('{}'.format('Recovered volume on the CPU using ROF-TV'))

print (f"information vector: {info_vec_cpu}")
#%%
print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
print ("_______________FGP-TV (3D)__________________")
Expand All @@ -141,8 +144,8 @@ def printParametersToString(pars):
# set parameters
pars = {'algorithm' : FGP_TV, \
'input' : noisyVol,\
'regularisation_parameter':0.02, \
'number_of_iterations' :1000 ,\
'regularisation_parameter': 0.08,# 0.02 * 10000,
'number_of_iterations' :2000 ,\
'tolerance_constant':1e-06,\
'methodTV': 0 ,\
'nonneg': 0}
Expand Down Expand Up @@ -171,6 +174,9 @@ def printParametersToString(pars):
verticalalignment='top', bbox=props)
imgplot = plt.imshow(fgp_cpu3D[10,:,:], cmap="gray")
plt.title('{}'.format('Recovered volume on the CPU using FGP-TV'))

#%%
imgplot = plt.imshow(fgp_cpu3D[:,1,:], cmap="gray")
#%%
print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
print ("_______________PD-TV (3D)__________________")
Expand Down
Loading

0 comments on commit 3e930d9

Please sign in to comment.