diff options
Diffstat (limited to 'Wrappers')
4 files changed, 16 insertions, 13 deletions
diff --git a/Wrappers/Python/ccpi/framework/BlockDataContainer.py b/Wrappers/Python/ccpi/framework/BlockDataContainer.py index da6ee5b..21ef3f0 100755 --- a/Wrappers/Python/ccpi/framework/BlockDataContainer.py +++ b/Wrappers/Python/ccpi/framework/BlockDataContainer.py @@ -57,7 +57,6 @@ class BlockDataContainer(object): if type(self.containers[i])==type(self):
self = self.containers[i]
-
if isinstance(other, Number):
return True
elif isinstance(other, list):
diff --git a/Wrappers/Python/ccpi/optimisation/algorithms/PDHG.py b/Wrappers/Python/ccpi/optimisation/algorithms/PDHG.py index 084818c..d0e27ae 100644 --- a/Wrappers/Python/ccpi/optimisation/algorithms/PDHG.py +++ b/Wrappers/Python/ccpi/optimisation/algorithms/PDHG.py @@ -151,3 +151,5 @@ def PDHG_old(f, g, operator, tau = None, sigma = None, opt = None, **kwargs): return x, t_end - t, objective + + diff --git a/Wrappers/Python/ccpi/optimisation/operators/SparseFiniteDiff.py b/Wrappers/Python/ccpi/optimisation/operators/SparseFiniteDiff.py index 0b5e85f..1b88cba 100644 --- a/Wrappers/Python/ccpi/optimisation/operators/SparseFiniteDiff.py +++ b/Wrappers/Python/ccpi/optimisation/operators/SparseFiniteDiff.py @@ -64,11 +64,15 @@ class SparseFiniteDiff(): def sum_abs_row(self): - return ImageData(np.array(np.reshape(abs(self.matrix()).sum(axis=0), self.gm_domain.shape, 'F'))) + res = np.array(np.reshape(abs(self.matrix()).sum(axis=0), self.gm_domain.shape, 'F')) + res[res==0]=1 + return ImageData(res) def sum_abs_col(self): - return ImageData(np.array(np.reshape(abs(self.matrix()).sum(axis=1), self.gm_domain.shape, 'C'))) + res = np.array(np.reshape(abs(self.matrix()).sum(axis=1), self.gm_domain.shape, 'C')) + res[res==0]=1 + return ImageData(res) if __name__ == '__main__': diff --git a/Wrappers/Python/wip/pdhg_TV_denoising_precond.py b/Wrappers/Python/wip/pdhg_TV_denoising_precond.py index 6792f43..2e0b9f4 100644 --- a/Wrappers/Python/wip/pdhg_TV_denoising_precond.py +++ b/Wrappers/Python/wip/pdhg_TV_denoising_precond.py @@ -24,7 +24,7 @@ from skimage.util import random_noise # ############################################################################ # Create phantom for TV denoising -N = 500 +N = 100 data = np.zeros((N,N)) data[round(N/4):round(3*N/4),round(N/4):round(3*N/4)] = 0.5 data[round(N/8):round(7*N/8),round(3*N/8):round(5*N/8)] = 1 @@ -78,16 +78,14 @@ diag_precon = False if diag_precon: - tmp_tau = 1/operator.sum_abs_row() - tmp_sigma = 1/operator.sum_abs_col() + def tau_sigma_precond(operator): + tau = 1/operator.sum_abs_row() + sigma = 1/ operator.sum_abs_col() - tmp_sigma[0][0].as_array()[tmp_sigma[0][0].as_array()==np.inf]=0 - tmp_sigma[0][1].as_array()[tmp_sigma[0][1].as_array()==np.inf]=0 - tmp_sigma[1].as_array()[tmp_sigma[1].as_array()==np.inf]=0 - - tau = tmp_tau - sigma = tmp_sigma - + return tau, sigma + + tau, sigma = tau_sigma_precond(operator) + else: # Compute operator Norm normK = operator.norm() |