diff options
author | algol <dkazanc@hotmail.com> | 2018-05-02 11:01:57 +0100 |
---|---|---|
committer | algol <dkazanc@hotmail.com> | 2018-05-02 11:01:57 +0100 |
commit | 985fee04ac1abef2aaa69f282ae6c207e438b4af (patch) | |
tree | 034b3987314d72888b82a74cba725c065987e79a /Wrappers/Python | |
parent | a64fe4d083173cc67dd7585c3160a94ea24bca80 (diff) | |
download | regularization-985fee04ac1abef2aaa69f282ae6c207e438b4af.tar.gz regularization-985fee04ac1abef2aaa69f282ae6c207e438b4af.tar.bz2 regularization-985fee04ac1abef2aaa69f282ae6c207e438b4af.tar.xz regularization-985fee04ac1abef2aaa69f282ae6c207e438b4af.zip |
bugs in cython files
Diffstat (limited to 'Wrappers/Python')
-rw-r--r-- | Wrappers/Python/demos/demo_cpu_inpainters.py | 2 | ||||
-rw-r--r-- | Wrappers/Python/demos/demo_cpu_regularisers.py | 40 | ||||
-rw-r--r-- | Wrappers/Python/demos/demo_gpu_regularisers.py | 18 |
3 files changed, 28 insertions, 32 deletions
diff --git a/Wrappers/Python/demos/demo_cpu_inpainters.py b/Wrappers/Python/demos/demo_cpu_inpainters.py index 348d235..7f452c1 100644 --- a/Wrappers/Python/demos/demo_cpu_inpainters.py +++ b/Wrappers/Python/demos/demo_cpu_inpainters.py @@ -72,7 +72,7 @@ pars = {'algorithm' : NDF_INP, \ 'maskData' : mask,\ 'regularisation_parameter':5000,\ 'edge_parameter':0,\ - 'number_of_iterations' :1000 ,\ + 'number_of_iterations' :5000 ,\ 'time_marching_parameter':0.000075,\ 'penalty_type':0 } diff --git a/Wrappers/Python/demos/demo_cpu_regularisers.py b/Wrappers/Python/demos/demo_cpu_regularisers.py index f803870..986e3e9 100644 --- a/Wrappers/Python/demos/demo_cpu_regularisers.py +++ b/Wrappers/Python/demos/demo_cpu_regularisers.py @@ -44,29 +44,30 @@ u0 = Im + np.random.normal(loc = 0 , u_ref = Im + np.random.normal(loc = 0 , scale = 0.01 * Im , size = np.shape(Im)) - +(N,M) = np.shape(u0) # map the u0 u0->u0>0 # f = np.frompyfunc(lambda x: 0 if x < 0 else x, 1,1) u0 = u0.astype('float32') u_ref = u_ref.astype('float32') # change dims to check that modules work with non-squared images -(N,M) = np.shape(u0) -u_ref2 = np.zeros([N,M-100],dtype='float32') -u_ref2[:,0:M-100] = u_ref[:,0:M-100] +""" +M = M-100 +u_ref2 = np.zeros([N,M],dtype='float32') +u_ref2[:,0:M] = u_ref[:,0:M] u_ref = u_ref2 del u_ref2 -u02 = np.zeros([N,M-100],dtype='float32') -u02[:,0:M-100] = u0[:,0:M-100] +u02 = np.zeros([N,M],dtype='float32') +u02[:,0:M] = u0[:,0:M] u0 = u02 del u02 -Im2 = np.zeros([N,M-100],dtype='float32') -Im2[:,0:M-100] = Im[:,0:M-100] +Im2 = np.zeros([N,M],dtype='float32') +Im2[:,0:M] = Im[:,0:M] Im = Im2 del Im2 - +""" #%% print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%") print ("_______________ROF-TV (2D)_________________") @@ -305,7 +306,6 @@ a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14, imgplot = plt.imshow(fgp_dtv_cpu, cmap="gray") plt.title('{}'.format('CPU results')) - print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%") print ("__________Total nuclear Variation__________") print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%") @@ -318,9 +318,8 @@ a.set_title('Noisy Image') imgplot = plt.imshow(u0,cmap="gray") channelsNo = 5 -N = 512 -noisyVol = np.zeros((channelsNo,N,N),dtype='float32') -idealVol = np.zeros((channelsNo,N,N),dtype='float32') +noisyVol = np.zeros((channelsNo,N,M),dtype='float32') +idealVol = np.zeros((channelsNo,N,M),dtype='float32') for i in range (channelsNo): noisyVol[i,:,:] = Im + np.random.normal(loc = 0 , scale = perc * Im , size = np.shape(Im)) @@ -361,25 +360,19 @@ plt.title('{}'.format('CPU results')) # Uncomment to test 3D regularisation performance #%% """ -N = 512 slices = 20 - -filename = os.path.join(".." , ".." , ".." , "data" ,"lena_gray_512.tif") -Im = plt.imread(filename) -Im = np.asarray(Im, dtype='float32') - -Im = Im/255 perc = 0.05 -noisyVol = np.zeros((slices,N,N),dtype='float32') -noisyRef = np.zeros((slices,N,N),dtype='float32') -idealVol = np.zeros((slices,N,N),dtype='float32') +noisyVol = np.zeros((slices,N,M),dtype='float32') +noisyRef = np.zeros((slices,N,M),dtype='float32') +idealVol = np.zeros((slices,N,M),dtype='float32') for i in range (slices): noisyVol[i,:,:] = Im + np.random.normal(loc = 0 , scale = perc * Im , size = np.shape(Im)) noisyRef[i,:,:] = Im + np.random.normal(loc = 0 , scale = 0.01 * Im , size = np.shape(Im)) idealVol[i,:,:] = Im + print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%") print ("_______________ROF-TV (3D)_________________") print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%") @@ -420,6 +413,7 @@ a.text(0.15, 0.25, txtstr, transform=a.transAxes, fontsize=14, imgplot = plt.imshow(rof_cpu3D[10,:,:], cmap="gray") plt.title('{}'.format('Recovered volume on the CPU using ROF-TV')) + print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%") print ("_______________FGP-TV (3D)__________________") print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%") diff --git a/Wrappers/Python/demos/demo_gpu_regularisers.py b/Wrappers/Python/demos/demo_gpu_regularisers.py index dfdceee..f3ed50c 100644 --- a/Wrappers/Python/demos/demo_gpu_regularisers.py +++ b/Wrappers/Python/demos/demo_gpu_regularisers.py @@ -44,26 +44,28 @@ u0 = Im + np.random.normal(loc = 0 , u_ref = Im + np.random.normal(loc = 0 , scale = 0.01 * Im , size = np.shape(Im)) +(N,M) = np.shape(u0) # map the u0 u0->u0>0 # f = np.frompyfunc(lambda x: 0 if x < 0 else x, 1,1) u0 = u0.astype('float32') u_ref = u_ref.astype('float32') - -(N,M) = np.shape(u0) -u_ref2 = np.zeros([N,M-100],dtype='float32') -u_ref2[:,0:M-100] = u_ref[:,0:M-100] +""" +M = M-100 +u_ref2 = np.zeros([N,M],dtype='float32') +u_ref2[:,0:M] = u_ref[:,0:M] u_ref = u_ref2 del u_ref2 -u02 = np.zeros([N,M-100],dtype='float32') -u02[:,0:M-100] = u0[:,0:M-100] +u02 = np.zeros([N,M],dtype='float32') +u02[:,0:M] = u0[:,0:M] u0 = u02 del u02 -Im2 = np.zeros([N,M-100],dtype='float32') -Im2[:,0:M-100] = Im[:,0:M-100] +Im2 = np.zeros([N,M],dtype='float32') +Im2[:,0:M] = Im[:,0:M] Im = Im2 del Im2 +""" print ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%") print ("____________ROF-TV regulariser_____________") |