From 9f943b6ee5018e917a032eeebfa938855502934c Mon Sep 17 00:00:00 2001 From: Edoardo Pasca Date: Thu, 10 Jan 2019 14:15:30 +0000 Subject: fix indentation --- Wrappers/Python/ccpi/filters/regularisers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Wrappers/Python') diff --git a/Wrappers/Python/ccpi/filters/regularisers.py b/Wrappers/Python/ccpi/filters/regularisers.py index 0a65590..5dbb96a 100644 --- a/Wrappers/Python/ccpi/filters/regularisers.py +++ b/Wrappers/Python/ccpi/filters/regularisers.py @@ -191,7 +191,7 @@ def TGV(inputData, regularisation_parameter, alpha1, alpha0, iterations, LipshitzConst) else: if not gpu_enabled and device == 'gpu': - raise ValueError ('GPU is not available') + raise ValueError ('GPU is not available') raise ValueError('Unknown device {0}. Expecting gpu or cpu'\ .format(device)) def LLT_ROF(inputData, regularisation_parameterROF, regularisation_parameterLLT, iterations, -- cgit v1.2.3 From 4c1cdbe58a441a27e46da0d6983851740db94939 Mon Sep 17 00:00:00 2001 From: Edoardo Pasca Date: Thu, 10 Jan 2019 14:50:36 +0000 Subject: allows 3D TGV by a for loop on slices --- Wrappers/Python/src/cpu_regularisers.pyx | 11 +++++++++-- Wrappers/Python/src/gpu_regularisers.pyx | 7 ++++++- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'Wrappers/Python') diff --git a/Wrappers/Python/src/cpu_regularisers.pyx b/Wrappers/Python/src/cpu_regularisers.pyx index 4aa3251..33d6eb7 100644 --- a/Wrappers/Python/src/cpu_regularisers.pyx +++ b/Wrappers/Python/src/cpu_regularisers.pyx @@ -199,9 +199,16 @@ def TV_SB_3D(np.ndarray[np.float32_t, ndim=3, mode="c"] inputData, #***************************************************************# def TGV_CPU(inputData, regularisation_parameter, alpha1, alpha0, iterations, LipshitzConst): if inputData.ndim == 2: - return TGV_2D(inputData, regularisation_parameter, alpha1, alpha0, iterations, LipshitzConst) + return TGV_2D(inputData, regularisation_parameter, alpha1, alpha0, + iterations, LipshitzConst) elif inputData.ndim == 3: - return 0 + shape = inputData.shape + print (shape) + out = inputData.copy() + for i in range(shape[0]): + out[i,:,:] = TGV_2D(inputData[i,:,:], regularisation_parameter, + alpha1, alpha0, iterations, LipshitzConst) + return out def TGV_2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData, float regularisation_parameter, diff --git a/Wrappers/Python/src/gpu_regularisers.pyx b/Wrappers/Python/src/gpu_regularisers.pyx index 2b97865..47a6149 100644 --- a/Wrappers/Python/src/gpu_regularisers.pyx +++ b/Wrappers/Python/src/gpu_regularisers.pyx @@ -102,7 +102,12 @@ def TGV_GPU(inputData, regularisation_parameter, alpha1, alpha0, iterations, Lip if inputData.ndim == 2: return TGV2D(inputData, regularisation_parameter, alpha1, alpha0, iterations, LipshitzConst) elif inputData.ndim == 3: - return 0 + shape = inputData.shape + out = inputData.copy() + for i in range(shape[0]): + out[i,:,:] = TGV2D(inputData[i,:,:], regularisation_parameter, + alpha1, alpha0, iterations, LipshitzConst) + return out # Directional Total-variation Fast-Gradient-Projection (FGP) def dTV_FGP_GPU(inputData, refdata, -- cgit v1.2.3 From 35c1ed097876b80f6de8f88da966d763162c04ff Mon Sep 17 00:00:00 2001 From: Edoardo Pasca Date: Thu, 10 Jan 2019 14:51:51 +0000 Subject: remove print closes #86 --- Wrappers/Python/src/cpu_regularisers.pyx | 1 - 1 file changed, 1 deletion(-) (limited to 'Wrappers/Python') diff --git a/Wrappers/Python/src/cpu_regularisers.pyx b/Wrappers/Python/src/cpu_regularisers.pyx index 33d6eb7..7d57ed1 100644 --- a/Wrappers/Python/src/cpu_regularisers.pyx +++ b/Wrappers/Python/src/cpu_regularisers.pyx @@ -203,7 +203,6 @@ def TGV_CPU(inputData, regularisation_parameter, alpha1, alpha0, iterations, Lip iterations, LipshitzConst) elif inputData.ndim == 3: shape = inputData.shape - print (shape) out = inputData.copy() for i in range(shape[0]): out[i,:,:] = TGV_2D(inputData[i,:,:], regularisation_parameter, -- cgit v1.2.3 From 3660ecf4ce9594edd6b35bd8e3c70e5c6d080ef0 Mon Sep 17 00:00:00 2001 From: Edoardo Pasca Date: Thu, 10 Jan 2019 16:34:44 +0000 Subject: bugfix and rename DIFF4th to Diff4th --- Wrappers/Python/ccpi/filters/regularisers.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'Wrappers/Python') diff --git a/Wrappers/Python/ccpi/filters/regularisers.py b/Wrappers/Python/ccpi/filters/regularisers.py index 5dbb96a..588ea32 100644 --- a/Wrappers/Python/ccpi/filters/regularisers.py +++ b/Wrappers/Python/ccpi/filters/regularisers.py @@ -24,7 +24,7 @@ def ROF_TV(inputData, regularisation_parameter, iterations, time_marching_parameter) else: if not gpu_enabled and device == 'gpu': - raise ValueError ('GPU is not available') + raise ValueError ('GPU is not available') raise ValueError('Unknown device {0}. Expecting gpu or cpu'\ .format(device)) @@ -48,7 +48,7 @@ def FGP_TV(inputData, regularisation_parameter,iterations, printM) else: if not gpu_enabled and device == 'gpu': - raise ValueError ('GPU is not available') + raise ValueError ('GPU is not available') raise ValueError('Unknown device {0}. Expecting gpu or cpu'\ .format(device)) def SB_TV(inputData, regularisation_parameter, iterations, @@ -69,7 +69,7 @@ def SB_TV(inputData, regularisation_parameter, iterations, printM) else: if not gpu_enabled and device == 'gpu': - raise ValueError ('GPU is not available') + raise ValueError ('GPU is not available') raise ValueError('Unknown device {0}. Expecting gpu or cpu'\ .format(device)) def FGP_dTV(inputData, refdata, regularisation_parameter, iterations, @@ -96,7 +96,7 @@ def FGP_dTV(inputData, refdata, regularisation_parameter, iterations, printM) else: if not gpu_enabled and device == 'gpu': - raise ValueError ('GPU is not available') + raise ValueError ('GPU is not available') raise ValueError('Unknown device {0}. Expecting gpu or cpu'\ .format(device)) def TNV(inputData, regularisation_parameter, iterations, tolerance_param): @@ -125,7 +125,7 @@ def NDF(inputData, regularisation_parameter, edge_parameter, iterations, raise ValueError ('GPU is not available') raise ValueError('Unknown device {0}. Expecting gpu or cpu'\ .format(device)) -def DIFF4th(inputData, regularisation_parameter, edge_parameter, iterations, +def Diff4th(inputData, regularisation_parameter, edge_parameter, iterations, time_marching_parameter, device='cpu'): if device == 'cpu': return Diff4th_CPU(inputData, @@ -141,7 +141,7 @@ def DIFF4th(inputData, regularisation_parameter, edge_parameter, iterations, time_marching_parameter) else: if not gpu_enabled and device == 'gpu': - raise ValueError ('GPU is not available') + raise ValueError ('GPU is not available') raise ValueError('Unknown device {0}. Expecting gpu or cpu'\ .format(device)) @@ -160,7 +160,7 @@ def PatchSelect(inputData, searchwindow, patchwindow, neighbours, edge_parameter edge_parameter) else: if not gpu_enabled and device == 'gpu': - raise ValueError ('GPU is not available') + raise ValueError ('GPU is not available') raise ValueError('Unknown device {0}. Expecting gpu or cpu'\ .format(device)) @@ -202,7 +202,7 @@ def LLT_ROF(inputData, regularisation_parameterROF, regularisation_parameterLLT, return LLT_ROF_GPU(inputData, regularisation_parameterROF, regularisation_parameterLLT, iterations, time_marching_parameter) else: if not gpu_enabled and device == 'gpu': - raise ValueError ('GPU is not available') + raise ValueError ('GPU is not available') raise ValueError('Unknown device {0}. Expecting gpu or cpu'\ .format(device)) def NDF_INP(inputData, maskData, regularisation_parameter, edge_parameter, iterations, -- cgit v1.2.3