summaryrefslogtreecommitdiffstats
path: root/src/Python/ccpi
diff options
context:
space:
mode:
authorDaniil Kazantsev <dkazanc@hotmail.com>2019-03-10 22:23:22 +0000
committerDaniil Kazantsev <dkazanc@hotmail.com>2019-03-10 22:23:22 +0000
commite2208bfc2ed540065bef2e8e12d914d873464da7 (patch)
tree36f91247b169ad423ff40a5850b19524f85d1f3e /src/Python/ccpi
parent49761c3730e2ddf2ec40c84952572c43e9334ccb (diff)
downloadregularization-e2208bfc2ed540065bef2e8e12d914d873464da7.tar.gz
regularization-e2208bfc2ed540065bef2e8e12d914d873464da7.tar.bz2
regularization-e2208bfc2ed540065bef2e8e12d914d873464da7.tar.xz
regularization-e2208bfc2ed540065bef2e8e12d914d873464da7.zip
all python code updated
Diffstat (limited to 'src/Python/ccpi')
-rw-r--r--src/Python/ccpi/filters/regularisers.py142
1 files changed, 72 insertions, 70 deletions
diff --git a/src/Python/ccpi/filters/regularisers.py b/src/Python/ccpi/filters/regularisers.py
index 09b465a..398e11c 100644
--- a/src/Python/ccpi/filters/regularisers.py
+++ b/src/Python/ccpi/filters/regularisers.py
@@ -7,7 +7,7 @@ try:
from ccpi.filters.gpu_regularisers import TV_ROF_GPU, TV_FGP_GPU, TV_SB_GPU, dTV_FGP_GPU, NDF_GPU, Diff4th_GPU, TGV_GPU, LLT_ROF_GPU, PATCHSEL_GPU
gpu_enabled = True
except ImportError:
- gpu_enabled = False
+ gpu_enabled = False
from ccpi.filters.cpu_regularisers import NDF_INPAINT_CPU, NVM_INPAINT_CPU
def ROF_TV(inputData, regularisation_parameter, iterations,
@@ -15,13 +15,13 @@ def ROF_TV(inputData, regularisation_parameter, iterations,
if device == 'cpu':
return TV_ROF_CPU(inputData,
regularisation_parameter,
- iterations,
+ iterations,
time_marching_parameter,
tolerance_param)
elif device == 'gpu' and gpu_enabled:
return TV_ROF_GPU(inputData,
regularisation_parameter,
- iterations,
+ iterations,
time_marching_parameter,
tolerance_param)
else:
@@ -35,14 +35,14 @@ def FGP_TV(inputData, regularisation_parameter,iterations,
if device == 'cpu':
return TV_FGP_CPU(inputData,
regularisation_parameter,
- iterations,
+ iterations,
tolerance_param,
methodTV,
nonneg)
elif device == 'gpu' and gpu_enabled:
return TV_FGP_GPU(inputData,
regularisation_parameter,
- iterations,
+ iterations,
tolerance_param,
methodTV,
nonneg)
@@ -56,13 +56,13 @@ def SB_TV(inputData, regularisation_parameter, iterations,
if device == 'cpu':
return TV_SB_CPU(inputData,
regularisation_parameter,
- iterations,
+ iterations,
tolerance_param,
methodTV)
elif device == 'gpu' and gpu_enabled:
return TV_SB_GPU(inputData,
regularisation_parameter,
- iterations,
+ iterations,
tolerance_param,
methodTV)
else:
@@ -81,91 +81,115 @@ def LLT_ROF(inputData, regularisation_parameterROF, regularisation_parameterLLT,
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,
- tolerance_param, eta_const, methodTV, nonneg, printM, device='cpu'):
+def TGV(inputData, regularisation_parameter, alpha1, alpha0, iterations,
+ LipshitzConst, tolerance_param, device='cpu'):
if device == 'cpu':
- return dTV_FGP_CPU(inputData,
- refdata,
- regularisation_parameter,
- iterations,
- tolerance_param,
- eta_const,
- methodTV,
- nonneg,
- printM)
+ return TGV_CPU(inputData,
+ regularisation_parameter,
+ alpha1,
+ alpha0,
+ iterations,
+ LipshitzConst,
+ tolerance_param)
elif device == 'gpu' and gpu_enabled:
- return dTV_FGP_GPU(inputData,
- refdata,
- regularisation_parameter,
- iterations,
- tolerance_param,
- eta_const,
- methodTV,
- nonneg,
- printM)
+ return TGV_GPU(inputData,
+ regularisation_parameter,
+ alpha1,
+ alpha0,
+ iterations,
+ LipshitzConst,
+ tolerance_param)
else:
if not gpu_enabled and device == 'gpu':
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):
- return TNV_CPU(inputData,
- regularisation_parameter,
- iterations,
- tolerance_param)
def NDF(inputData, regularisation_parameter, edge_parameter, iterations,
- time_marching_parameter, penalty_type, device='cpu'):
+ time_marching_parameter, penalty_type, tolerance_param, device='cpu'):
if device == 'cpu':
return NDF_CPU(inputData,
regularisation_parameter,
edge_parameter,
- iterations,
+ iterations,
time_marching_parameter,
- penalty_type)
+ penalty_type,
+ tolerance_param)
elif device == 'gpu' and gpu_enabled:
return NDF_GPU(inputData,
regularisation_parameter,
edge_parameter,
- iterations,
+ iterations,
time_marching_parameter,
- penalty_type)
+ penalty_type,
+ tolerance_param)
else:
if not gpu_enabled and device == 'gpu':
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,
- time_marching_parameter, device='cpu'):
+ time_marching_parameter, tolerance_param, device='cpu'):
if device == 'cpu':
return Diff4th_CPU(inputData,
regularisation_parameter,
edge_parameter,
- iterations,
- time_marching_parameter)
+ iterations,
+ time_marching_parameter,
+ tolerance_param)
elif device == 'gpu' and gpu_enabled:
return Diff4th_GPU(inputData,
regularisation_parameter,
edge_parameter,
- iterations,
- time_marching_parameter)
+ iterations,
+ time_marching_parameter,
+ tolerance_param)
else:
if not gpu_enabled and device == 'gpu':
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,
+ tolerance_param, eta_const, methodTV, nonneg, device='cpu'):
+ if device == 'cpu':
+ return dTV_FGP_CPU(inputData,
+ refdata,
+ regularisation_parameter,
+ iterations,
+ tolerance_param,
+ eta_const,
+ methodTV,
+ nonneg)
+ elif device == 'gpu' and gpu_enabled:
+ return dTV_FGP_GPU(inputData,
+ refdata,
+ regularisation_parameter,
+ iterations,
+ tolerance_param,
+ eta_const,
+ methodTV,
+ nonneg)
+ else:
+ if not gpu_enabled and device == 'gpu':
+ 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):
+ return TNV_CPU(inputData,
+ regularisation_parameter,
+ iterations,
+ tolerance_param)
def PatchSelect(inputData, searchwindow, patchwindow, neighbours, edge_parameter, device='cpu'):
if device == 'cpu':
return PATCHSEL_CPU(inputData,
searchwindow,
patchwindow,
- neighbours,
+ neighbours,
edge_parameter)
elif device == 'gpu' and gpu_enabled:
return PATCHSEL_GPU(inputData,
searchwindow,
patchwindow,
- neighbours,
+ neighbours,
edge_parameter)
else:
if not gpu_enabled and device == 'gpu':
@@ -177,36 +201,14 @@ def NLTV(inputData, H_i, H_j, H_k, Weights, regularisation_parameter, iterations
return NLTV_CPU(inputData,
H_i,
H_j,
- H_k,
+ H_k,
Weights,
regularisation_parameter,
iterations)
-
-def TGV(inputData, regularisation_parameter, alpha1, alpha0, iterations,
- LipshitzConst, device='cpu'):
- if device == 'cpu':
- return TGV_CPU(inputData,
- regularisation_parameter,
- alpha1,
- alpha0,
- iterations,
- LipshitzConst)
- elif device == 'gpu' and gpu_enabled:
- return TGV_GPU(inputData,
- regularisation_parameter,
- alpha1,
- alpha0,
- iterations,
- LipshitzConst)
- else:
- if not gpu_enabled and device == 'gpu':
- 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,
time_marching_parameter, penalty_type):
- return NDF_INPAINT_CPU(inputData, maskData, regularisation_parameter,
+ return NDF_INPAINT_CPU(inputData, maskData, regularisation_parameter,
edge_parameter, iterations, time_marching_parameter, penalty_type)
-
+
def NVM_INP(inputData, maskData, SW_increment, iterations):
return NVM_INPAINT_CPU(inputData, maskData, SW_increment, iterations)