From 42a10faa06bd56bff3f0f1804ddcdf1a3e1283cd Mon Sep 17 00:00:00 2001 From: Daniil Kazantsev Date: Tue, 1 May 2018 15:16:49 +0100 Subject: inpaint NVM added --- Wrappers/Python/src/cpu_regularisers.pyx | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'Wrappers/Python/src') diff --git a/Wrappers/Python/src/cpu_regularisers.pyx b/Wrappers/Python/src/cpu_regularisers.pyx index 3625106..19dd707 100644 --- a/Wrappers/Python/src/cpu_regularisers.pyx +++ b/Wrappers/Python/src/cpu_regularisers.pyx @@ -26,7 +26,7 @@ cdef extern float TNV_CPU_main(float *Input, float *u, float lambdaPar, int maxI cdef extern float dTV_FGP_CPU_main(float *Input, float *InputRef, float *Output, float lambdaPar, int iterationsNumb, float epsil, float eta, int methodTV, int nonneg, int printM, int dimX, int dimY, int dimZ); cdef extern float Diffusion_Inpaint_CPU_main(float *Input, unsigned char *Mask, float *Output, float lambdaPar, float sigmaPar, int iterationsNumb, float tau, int penaltytype, int dimX, int dimY, int dimZ); -#cdef extern float NonlocalMarching_Inpaint_main(float *Input, unsigned char *M, float *Output, unsigned char *M_upd, int SW_increment, int iterationsNumb, int dimX, int dimY, int dimZ); +cdef extern float NonlocalMarching_Inpaint_main(float *Input, unsigned char *M, float *Output, unsigned char *M_upd, int SW_increment, int iterationsNumb, int dimX, int dimY, int dimZ); #****************************************************************# #********************** Total-variation ROF *********************# @@ -368,4 +368,33 @@ def NDF_INP_3D(np.ndarray[np.float32_t, ndim=3, mode="c"] inputData, # Run Inpaiting by Diffusion iterations for 3D data Diffusion_Inpaint_CPU_main(&inputData[0,0,0], &maskData[0,0,0], &outputData[0,0,0], regularisation_parameter, edge_parameter, iterationsNumb, time_marching_parameter, penalty_type, dims[2], dims[1], dims[0]) + return outputData +#*********************Inpainting WITH****************************# +#***************Nonlocal Vertical Marching method****************# +#****************************************************************# +def NVM_INPAINT_CPU(inputData, maskData, SW_increment, iterations): + if inputData.ndim == 2: + return NVM_INP_2D(inputData, maskData, SW_increment, iterations) + elif inputData.ndim == 3: + return + +def NVM_INP_2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData, + np.ndarray[np.uint8_t, ndim=2, mode="c"] maskData, + int SW_increment, + int iterationsNumb): + cdef long dims[2] + dims[0] = inputData.shape[0] + dims[1] = inputData.shape[1] + + cdef np.ndarray[np.float32_t, ndim=2, mode="c"] outputData = \ + np.zeros([dims[0],dims[1]], dtype='float32') + + cdef np.ndarray[np.uint8_t, ndim=2, mode="c"] maskData_upd = \ + np.zeros([dims[0],dims[1]], dtype='uint8') + + # Run Inpaiting by Nonlocal vertical marching method for 2D data + NonlocalMarching_Inpaint_main(&inputData[0,0], &maskData[0,0], &outputData[0,0], &maskData_upd[0,0], + SW_increment, iterationsNumb, + dims[0], dims[1], 1) + return outputData -- cgit v1.2.3