diff options
author | algol <dkazanc@hotmail.com> | 2018-03-06 16:18:20 +0000 |
---|---|---|
committer | algol <dkazanc@hotmail.com> | 2018-03-06 16:18:20 +0000 |
commit | 63ad8306c261a90c572d95084bf1dd8db2b3dce7 (patch) | |
tree | 8069f7f7bf5e454634dec8b757b02284a378de13 /Wrappers/Python/src | |
parent | 5411ebbd4165c81b398b010d6ad9d11d2e973aad (diff) | |
download | regularization-63ad8306c261a90c572d95084bf1dd8db2b3dce7.tar.gz regularization-63ad8306c261a90c572d95084bf1dd8db2b3dce7.tar.bz2 regularization-63ad8306c261a90c572d95084bf1dd8db2b3dce7.tar.xz regularization-63ad8306c261a90c572d95084bf1dd8db2b3dce7.zip |
FGP/ROF-CPU/GPU fully working with new interfaces and regularizers.py script. This closes #39 and #38
Diffstat (limited to 'Wrappers/Python/src')
-rw-r--r-- | Wrappers/Python/src/gpu_regularizers.pyx | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/Wrappers/Python/src/gpu_regularizers.pyx b/Wrappers/Python/src/gpu_regularizers.pyx index cb94e86..f96156a 100644 --- a/Wrappers/Python/src/gpu_regularizers.pyx +++ b/Wrappers/Python/src/gpu_regularizers.pyx @@ -26,14 +26,14 @@ cdef extern void NLM_GPU_kernel(float *A, float* B, float *Eucl_Vec, int SearchW, int SimilW, int SearchW_real, float denh2, float lambdaf); cdef extern void TV_ROF_GPU_main(float* Input, float* Output, float lambdaPar, int iter, float tau, int N, int M, int Z); -#cdef extern void TV_FGP_GPU(float *Input, float *Output, float lambdaPar, int iter, float epsil, int methodTV, int nonneg, int printM, int N, int M, int Z); -# correct the function cdef extern void TV_FGP_GPU_main(float *Input, float *Output, float lambdaPar, int iter, float epsil, int methodTV, int nonneg, int printM, int N, int M, int Z); +# padding function cdef extern float pad_crop(float *A, float *Ap, int OldSizeX, int OldSizeY, int OldSizeZ, int NewSizeX, int NewSizeY, int NewSizeZ, int padXY, int switchpad_crop); + #Diffusion 4th order regularizer def Diff4thHajiaboli(inputData, edge_preserv_parameter, @@ -70,6 +70,7 @@ def NML(inputData, SimilW, h, lambdaf) + # Total-variation Rudin-Osher-Fatemi (ROF) def TV_ROF_GPU(inputData, regularization_parameter, @@ -82,24 +83,34 @@ def TV_ROF_GPU(inputData, time_marching_parameter) elif inputData.ndim == 3: return ROFTV3D(inputData, - regularization_parameter + regularization_parameter, iterations, time_marching_parameter) + # Total-variation Fast-Gradient-Projection (FGP) def TV_FGP_GPU(inputData, regularization_parameter, iterations, - time_marching_parameter): + tolerance_param, + methodTV, + nonneg, + printM): if inputData.ndim == 2: - return FGPTV2D(inputData, + return FGPTV2D(inputData, regularization_parameter, - iterations, - time_marching_parameter) + iterations, + tolerance_param, + methodTV, + nonneg, + printM) elif inputData.ndim == 3: - return FGPTV3D(inputData, - regularization_parameter + return FGPTV3D(inputData, + regularization_parameter, iterations, - time_marching_parameter) + tolerance_param, + methodTV, + nonneg, + printM) #****************************************************************# def Diff4thHajiaboli2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData, float edge_preserv_parameter, @@ -347,7 +358,8 @@ def NML3D(np.ndarray[np.float32_t, ndim=3, mode="c"] inputData, switchpad_crop) return B - + +# Total-variation ROF def ROFTV2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData, float regularization_parameter, int iterations, @@ -393,6 +405,7 @@ def ROFTV3D(np.ndarray[np.float32_t, ndim=3, mode="c"] inputData, return outputData +# Total-variation Fast-Gradient-Projection (FGP) def FGPTV2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData, float regularization_parameter, int iterations, @@ -409,8 +422,7 @@ def FGPTV2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData, np.zeros([dims[0],dims[1]], dtype='float32') # Running CUDA code here - TV_FGP_GPU( - &inputData[0,0], &outputData[0,0], + TV_FGP_GPU_main(&inputData[0,0], &outputData[0,0], regularization_parameter, iterations, tolerance_param, @@ -438,7 +450,7 @@ def FGPTV3D(np.ndarray[np.float32_t, ndim=3, mode="c"] inputData, np.zeros([dims[0],dims[1],dims[2]], dtype='float32') # Running CUDA code here - TV_FGP_GPU( + TV_FGP_GPU_main( &inputData[0,0,0], &outputData[0,0,0], regularization_parameter , iterations, @@ -449,6 +461,3 @@ def FGPTV3D(np.ndarray[np.float32_t, ndim=3, mode="c"] inputData, dims[0], dims[1], dims[2]); return outputData - - - |