Generated by Cython 3.0.10
Yellow lines hint at Python interaction.
Click on a line that starts with a "+
" to see the C code that Cython generated for it.
Raw output: denoise_cython.c
001:
002:
+003: import numpy as np
__pyx_t_7 = __Pyx_ImportDottedModule(__pyx_n_s_numpy, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_7) < 0) __PYX_ERR(0, 3, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __pyx_t_5 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_5) < 0) __PYX_ERR(0, 3, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
004: cimport numpy as np
005: cimport cython
006:
007: from libc.math cimport sqrt, abs
008:
+009: from PIL import Image
__pyx_t_7 = PyList_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_n_s_Image); __Pyx_GIVEREF(__pyx_n_s_Image); if (__Pyx_PyList_SET_ITEM(__pyx_t_7, 0, __pyx_n_s_Image)) __PYX_ERR(0, 9, __pyx_L1_error); __pyx_t_4 = __Pyx_Import(__pyx_n_s_PIL, __pyx_t_7, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_Image); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Image, __pyx_t_7) < 0) __PYX_ERR(0, 9, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
010:
+011: from pathlib import Path
__pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 11, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_n_s_Path); __Pyx_GIVEREF(__pyx_n_s_Path); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_Path)) __PYX_ERR(0, 11, __pyx_L1_error); __pyx_t_7 = __Pyx_Import(__pyx_n_s_pathlib, __pyx_t_4, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 11, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_7, __pyx_n_s_Path); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 11, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Path, __pyx_t_4) < 0) __PYX_ERR(0, 11, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
012:
+013: DTYPE = np.float64
__Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_float64); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_DTYPE, __pyx_t_4) < 0) __PYX_ERR(0, 13, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
014:
+015: @cython.boundscheck(False)
/* Python wrapper */ static PyObject *__pyx_pw_14denoise_cython_1denoise_chambolle(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_14denoise_cython_denoise_chambolle, "Image denoising algorithm following Chambolle's method\n proposed in [1]_.\n\n Note that the scikit-image library also has a reference implementation\n of the same algorithm.\n\n References\n ----------\n .. [1] Antonin Chambolle, An algorithm for total variation minimization\n and applications, Journal of Mathematical Imaging and Vision,\n Springer, 2004, 20, 89 -- 97.\n "); static PyMethodDef __pyx_mdef_14denoise_cython_1denoise_chambolle = {"denoise_chambolle", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_14denoise_cython_1denoise_chambolle, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_14denoise_cython_denoise_chambolle}; static PyObject *__pyx_pw_14denoise_cython_1denoise_chambolle(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_image_path = 0; double __pyx_v_weight; double __pyx_v_epsilon; int __pyx_v_max_num_iter; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("denoise_chambolle (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_image_path,&__pyx_n_s_weight,&__pyx_n_s_epsilon,&__pyx_n_s_max_num_iter,0}; PyObject* values[4] = {0,0,0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_image_path)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 15, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_weight); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 15, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_epsilon); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 15, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_max_num_iter); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 15, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "denoise_chambolle") < 0)) __PYX_ERR(0, 15, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_image_path = ((PyObject*)values[0]); if (values[1]) { __pyx_v_weight = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_weight == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 18, __pyx_L3_error) } else { __pyx_v_weight = ((double)((double)0.1)); } if (values[2]) { __pyx_v_epsilon = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_epsilon == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 19, __pyx_L3_error) } else { __pyx_v_epsilon = ((double)((double)2.0e-4)); } if (values[3]) { __pyx_v_max_num_iter = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_max_num_iter == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 20, __pyx_L3_error) } else { __pyx_v_max_num_iter = ((int)((int)0x64)); } } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("denoise_chambolle", 0, 1, 4, __pyx_nargs); __PYX_ERR(0, 15, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("denoise_cython.denoise_chambolle", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_image_path), (&PyString_Type), 1, "image_path", 1))) __PYX_ERR(0, 17, __pyx_L1_error) __pyx_r = __pyx_pf_14denoise_cython_denoise_chambolle(__pyx_self, __pyx_v_image_path, __pyx_v_weight, __pyx_v_epsilon, __pyx_v_max_num_iter); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_14denoise_cython_denoise_chambolle(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_image_path, double __pyx_v_weight, double __pyx_v_epsilon, int __pyx_v_max_num_iter) { PyObject *__pyx_v_img = NULL; PyObject *__pyx_v_image_data = NULL; __Pyx_memviewslice __pyx_v_image_data_view = { 0, 0, { 0 }, { 0 }, { 0 } }; float __pyx_v_tau; Py_ssize_t __pyx_v_M; Py_ssize_t __pyx_v_N; Py_ssize_t __pyx_v_num_channels; PyObject *__pyx_v_result_image = NULL; __Pyx_memviewslice __pyx_v_result_image_view = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_p_view = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_result_gradient_view = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_result_channel_view = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_v_num_iter; double __pyx_v_p_div_ij; double __pyx_v_scale; double __pyx_v_max_var; double __pyx_v_tmp_var; Py_ssize_t __pyx_v_i; Py_ssize_t __pyx_v_j; Py_ssize_t __pyx_v_channel; Py_ssize_t __pyx_v_ax; PyObject *__pyx_v_p = NULL; CYTHON_UNUSED PyObject *__pyx_v_result_gradient = NULL; CYTHON_UNUSED PyObject *__pyx_v_result_channel = NULL; double __pyx_v_tmp; PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __PYX_XCLEAR_MEMVIEW(&__pyx_t_8, 1); __PYX_XCLEAR_MEMVIEW(&__pyx_t_12, 1); __Pyx_AddTraceback("denoise_cython.denoise_chambolle", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_img); __Pyx_XDECREF(__pyx_v_image_data); __PYX_XCLEAR_MEMVIEW(&__pyx_v_image_data_view, 1); __Pyx_XDECREF(__pyx_v_result_image); __PYX_XCLEAR_MEMVIEW(&__pyx_v_result_image_view, 1); __PYX_XCLEAR_MEMVIEW(&__pyx_v_p_view, 1); __PYX_XCLEAR_MEMVIEW(&__pyx_v_result_gradient_view, 1); __PYX_XCLEAR_MEMVIEW(&__pyx_v_result_channel_view, 1); __Pyx_XDECREF(__pyx_v_p); __Pyx_XDECREF(__pyx_v_result_gradient); __Pyx_XDECREF(__pyx_v_result_channel); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__22 = PyTuple_Pack(30, __pyx_n_s_image_path, __pyx_n_s_weight, __pyx_n_s_epsilon, __pyx_n_s_max_num_iter, __pyx_n_s_img, __pyx_n_s_image_data, __pyx_n_s_image_data_view, __pyx_n_s_tau, __pyx_n_s_M, __pyx_n_s_N, __pyx_n_s_num_channels, __pyx_n_s_result_image, __pyx_n_s_result_image_view, __pyx_n_s_p_view, __pyx_n_s_result_gradient_view, __pyx_n_s_result_channel_view, __pyx_n_s_num_iter, __pyx_n_s_p_div_ij, __pyx_n_s_scale, __pyx_n_s_p_tmp, __pyx_n_s_max_var, __pyx_n_s_tmp_var, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_channel, __pyx_n_s_ax, __pyx_n_s_p, __pyx_n_s_result_gradient, __pyx_n_s_result_channel, __pyx_n_s_tmp); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__22); __Pyx_GIVEREF(__pyx_tuple__22); /* … */ __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_4); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4)) __PYX_ERR(0, 15, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_7); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_7)) __PYX_ERR(0, 15, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_5); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_5)) __PYX_ERR(0, 15, __pyx_L1_error); __pyx_t_4 = 0; __pyx_t_7 = 0; __pyx_t_5 = 0; __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_14denoise_cython_1denoise_chambolle, 0, __pyx_n_s_denoise_chambolle, NULL, __pyx_n_s_denoise_cython, __pyx_d, ((PyObject *)__pyx_codeobj__23)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_5, __pyx_t_9); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_denoise_chambolle, __pyx_t_5) < 0) __PYX_ERR(0, 15, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
016: def denoise_chambolle(
017: str image_path,
+018: double weight = 0.1,
__pyx_t_4 = PyFloat_FromDouble(((double)0.1)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 18, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4);
+019: double epsilon = 2.0e-4,
__pyx_t_7 = PyFloat_FromDouble(((double)2.0e-4)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7);
+020: int max_num_iter = 100
__pyx_t_5 = __Pyx_PyInt_From_int(((int)0x64)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 20, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5);
021: ):
022: """Image denoising algorithm following Chambolle's method
023: proposed in [1]_.
024:
025: Note that the scikit-image library also has a reference implementation
026: of the same algorithm.
027:
028: References
029: ----------
030: .. [1] Antonin Chambolle, An algorithm for total variation minimization
031: and applications, Journal of Mathematical Imaging and Vision,
032: Springer, 2004, 20, 89 -- 97.
033: """
+034: img = Image.open(image_path)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Image); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_open); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_image_path}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_v_img = __pyx_t_1; __pyx_t_1 = 0;
035:
036:
+037: image_data = np.multiply(
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_multiply); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+038: np.array(img, dtype=DTYPE),
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_array); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_img); __Pyx_GIVEREF(__pyx_v_img); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_img)) __PYX_ERR(0, 38, __pyx_L1_error); __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_DTYPE); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, __pyx_t_7) < 0) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+039: 1.0 / 255.0 # normalize to [0, 1]
__pyx_t_6 = PyFloat_FromDouble((1.0 / 255.0)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_t_7, __pyx_t_6}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 2+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_image_data = __pyx_t_1; __pyx_t_1 = 0;
040: )
+041: cdef double [:, :, :] image_data_view = image_data
__pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_double(__pyx_v_image_data, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 41, __pyx_L1_error) __pyx_v_image_data_view = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL;
+042: cdef float tau = 0.25
__pyx_v_tau = 0.25;
043:
044: # image_shape = tuple(image_data.shape)[:2]
+045: cdef Py_ssize_t M = image_data.shape[0]
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_image_data, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_M = __pyx_t_9;
+046: cdef Py_ssize_t N = image_data.shape[1]
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image_data, __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_N = __pyx_t_9;
047:
048: # num_channels = image_data.shape[2]
+049: cdef Py_ssize_t num_channels = image_data.shape[2]
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_image_data, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_num_channels = __pyx_t_9;
050:
+051: result_image = np.zeros_like(image_data, dtype=DTYPE)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 51, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros_like); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 51, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_image_data); __Pyx_GIVEREF(__pyx_v_image_data); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_image_data)) __PYX_ERR(0, 51, __pyx_L1_error); __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 51, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_DTYPE); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 51, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, __pyx_t_7) < 0) __PYX_ERR(0, 51, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 51, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_result_image = __pyx_t_7; __pyx_t_7 = 0;
+052: cdef double [:, :, :] result_image_view = result_image
__pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_double(__pyx_v_result_image, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 52, __pyx_L1_error) __pyx_v_result_image_view = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL;
053: cdef double [:, :, :] p_view, result_gradient_view
054: cdef double [:, :] result_channel_view
055:
+056: cdef int num_iter = 0
__pyx_v_num_iter = 0;
057: cdef double p_div_ij, scale, p_tmp, max_var, tmp_var
058:
059: cdef Py_ssize_t i, j, channel, ax
060:
+061: for channel in range(num_channels):
__pyx_t_9 = __pyx_v_num_channels; __pyx_t_10 = __pyx_t_9; for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { __pyx_v_channel = __pyx_t_11;
+062: p_view = p = np.zeros((2, M, N), dtype=DTYPE)
__Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 62, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 62, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyInt_FromSsize_t(__pyx_v_M); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 62, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_N); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 62, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_int_2); __Pyx_GIVEREF(__pyx_int_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_int_2)) __PYX_ERR(0, 62, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_7); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_7)) __PYX_ERR(0, 62, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_2)) __PYX_ERR(0, 62, __pyx_L1_error); __pyx_t_7 = 0; __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 62, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_DTYPE); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 62, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_7) < 0) __PYX_ERR(0, 62, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 62, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_double(__pyx_t_7, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 62, __pyx_L1_error) __PYX_XCLEAR_MEMVIEW(&__pyx_v_p_view, 1); __PYX_INC_MEMVIEW(&__pyx_t_8, 1); __pyx_v_p_view = __pyx_t_8; __Pyx_INCREF(__pyx_t_7); __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_7); __PYX_XCLEAR_MEMVIEW(&__pyx_t_8, 1); __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
063: # p_div = np.zeros((M, N), dtype=DTYPE)
+064: result_gradient_view = result_gradient = np.zeros_like(p, dtype=DTYPE)
__Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_zeros_like); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_v_p); __Pyx_GIVEREF(__pyx_v_p); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_p)) __PYX_ERR(0, 64, __pyx_L1_error); __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_DTYPE); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_t_6) < 0) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_double(__pyx_t_6, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 64, __pyx_L1_error) __PYX_XCLEAR_MEMVIEW(&__pyx_v_result_gradient_view, 1); __PYX_INC_MEMVIEW(&__pyx_t_8, 1); __pyx_v_result_gradient_view = __pyx_t_8; __Pyx_INCREF(__pyx_t_6); __Pyx_XDECREF_SET(__pyx_v_result_gradient, __pyx_t_6); __PYX_XCLEAR_MEMVIEW(&__pyx_t_8, 1); __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+065: result_channel_view = result_channel = image_data[:, :, channel].copy()
__pyx_t_2 = PyInt_FromSsize_t(__pyx_v_channel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_slice__5); __Pyx_GIVEREF(__pyx_slice__5); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_slice__5)) __PYX_ERR(0, 65, __pyx_L1_error); __Pyx_INCREF(__pyx_slice__5); __Pyx_GIVEREF(__pyx_slice__5); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_slice__5)) __PYX_ERR(0, 65, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_v_image_data, __pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_copy); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_t_12 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_6, PyBUF_WRITABLE); if (unlikely(!__pyx_t_12.memview)) __PYX_ERR(0, 65, __pyx_L1_error) __PYX_XCLEAR_MEMVIEW(&__pyx_v_result_channel_view, 1); __PYX_INC_MEMVIEW(&__pyx_t_12, 1); __pyx_v_result_channel_view = __pyx_t_12; __Pyx_INCREF(__pyx_t_6); __Pyx_XDECREF_SET(__pyx_v_result_channel, __pyx_t_6); __PYX_XCLEAR_MEMVIEW(&__pyx_t_12, 1); __pyx_t_12.memview = NULL; __pyx_t_12.data = NULL; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
066:
+067: num_iter = 0
__pyx_v_num_iter = 0;
+068: while num_iter < max_num_iter:
while (1) { __pyx_t_13 = (__pyx_v_num_iter < __pyx_v_max_num_iter); if (!__pyx_t_13) break;
+069: if num_iter > 0:
__pyx_t_13 = (__pyx_v_num_iter > 0); if (__pyx_t_13) { /* … */ }
070: # p_div = p.sum(axis=0)
071: # p_div[1:, :] -= p[0, 0:-1, :]
072: # p_div[:, 1:] -= p[1, :, 0:-1]
+073: for i in range(M):
__pyx_t_14 = __pyx_v_M; __pyx_t_15 = __pyx_t_14; for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) { __pyx_v_i = __pyx_t_16;
+074: for j in range(N):
__pyx_t_17 = __pyx_v_N; __pyx_t_18 = __pyx_t_17; for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) { __pyx_v_j = __pyx_t_19;
+075: p_div_ij = 0
__pyx_v_p_div_ij = 0.0;
+076: if i < M - 1:
__pyx_t_13 = (__pyx_v_i < (__pyx_v_M - 1)); if (__pyx_t_13) { /* … */ }
+077: p_div_ij += p_view[0, i, j]
__pyx_t_20 = 0; __pyx_t_21 = __pyx_v_i; __pyx_t_22 = __pyx_v_j; if (__pyx_t_20 < 0) __pyx_t_20 += __pyx_v_p_view.shape[0]; if (__pyx_t_21 < 0) __pyx_t_21 += __pyx_v_p_view.shape[1]; if (__pyx_t_22 < 0) __pyx_t_22 += __pyx_v_p_view.shape[2]; __pyx_v_p_div_ij = (__pyx_v_p_div_ij + (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_p_view.data + __pyx_t_20 * __pyx_v_p_view.strides[0]) ) + __pyx_t_21 * __pyx_v_p_view.strides[1]) ) + __pyx_t_22 * __pyx_v_p_view.strides[2]) ))));
+078: if i > 0:
__pyx_t_13 = (__pyx_v_i > 0); if (__pyx_t_13) { /* … */ }
+079: p_div_ij -= p_view[0, i-1, j]
__pyx_t_22 = 0; __pyx_t_21 = (__pyx_v_i - 1); __pyx_t_20 = __pyx_v_j; if (__pyx_t_22 < 0) __pyx_t_22 += __pyx_v_p_view.shape[0]; if (__pyx_t_21 < 0) __pyx_t_21 += __pyx_v_p_view.shape[1]; if (__pyx_t_20 < 0) __pyx_t_20 += __pyx_v_p_view.shape[2]; __pyx_v_p_div_ij = (__pyx_v_p_div_ij - (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_p_view.data + __pyx_t_22 * __pyx_v_p_view.strides[0]) ) + __pyx_t_21 * __pyx_v_p_view.strides[1]) ) + __pyx_t_20 * __pyx_v_p_view.strides[2]) ))));
+080: if j < N - 1:
__pyx_t_13 = (__pyx_v_j < (__pyx_v_N - 1)); if (__pyx_t_13) { /* … */ }
+081: p_div_ij += p_view[1, i, j]
__pyx_t_20 = 1; __pyx_t_21 = __pyx_v_i; __pyx_t_22 = __pyx_v_j; if (__pyx_t_20 < 0) __pyx_t_20 += __pyx_v_p_view.shape[0]; if (__pyx_t_21 < 0) __pyx_t_21 += __pyx_v_p_view.shape[1]; if (__pyx_t_22 < 0) __pyx_t_22 += __pyx_v_p_view.shape[2]; __pyx_v_p_div_ij = (__pyx_v_p_div_ij + (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_p_view.data + __pyx_t_20 * __pyx_v_p_view.strides[0]) ) + __pyx_t_21 * __pyx_v_p_view.strides[1]) ) + __pyx_t_22 * __pyx_v_p_view.strides[2]) ))));
+082: if j > 0:
__pyx_t_13 = (__pyx_v_j > 0); if (__pyx_t_13) { /* … */ }
+083: p_div_ij -= p_view[1, i, j-1]
__pyx_t_22 = 1; __pyx_t_21 = __pyx_v_i; __pyx_t_20 = (__pyx_v_j - 1); if (__pyx_t_22 < 0) __pyx_t_22 += __pyx_v_p_view.shape[0]; if (__pyx_t_21 < 0) __pyx_t_21 += __pyx_v_p_view.shape[1]; if (__pyx_t_20 < 0) __pyx_t_20 += __pyx_v_p_view.shape[2]; __pyx_v_p_div_ij = (__pyx_v_p_div_ij - (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_p_view.data + __pyx_t_22 * __pyx_v_p_view.strides[0]) ) + __pyx_t_21 * __pyx_v_p_view.strides[1]) ) + __pyx_t_20 * __pyx_v_p_view.strides[2]) ))));
084:
+085: result_channel_view[i, j] = image_data_view[i, j, channel] - p_div_ij
__pyx_t_20 = __pyx_v_i; __pyx_t_21 = __pyx_v_j; __pyx_t_22 = __pyx_v_channel; if (__pyx_t_20 < 0) __pyx_t_20 += __pyx_v_image_data_view.shape[0]; if (__pyx_t_21 < 0) __pyx_t_21 += __pyx_v_image_data_view.shape[1]; if (__pyx_t_22 < 0) __pyx_t_22 += __pyx_v_image_data_view.shape[2]; __pyx_t_23 = __pyx_v_i; __pyx_t_24 = __pyx_v_j; if (__pyx_t_23 < 0) __pyx_t_23 += __pyx_v_result_channel_view.shape[0]; if (__pyx_t_24 < 0) __pyx_t_24 += __pyx_v_result_channel_view.shape[1]; *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_result_channel_view.data + __pyx_t_23 * __pyx_v_result_channel_view.strides[0]) ) + __pyx_t_24 * __pyx_v_result_channel_view.strides[1]) )) = ((*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_image_data_view.data + __pyx_t_20 * __pyx_v_image_data_view.strides[0]) ) + __pyx_t_21 * __pyx_v_image_data_view.strides[1]) ) + __pyx_t_22 * __pyx_v_image_data_view.strides[2]) ))) - __pyx_v_p_div_ij); } }
086:
087: # result_channel = image_data[:, :, channel] - p_div
088:
089: # result_gradient[0, 0:-1, :] = np.diff(result_channel, axis=0)
090: # result_gradient[1, :, 0:-1] = np.diff(result_channel, axis=1)
+091: for i in range(M):
__pyx_t_14 = __pyx_v_M; __pyx_t_15 = __pyx_t_14; for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) { __pyx_v_i = __pyx_t_16;
+092: for j in range(N):
__pyx_t_17 = __pyx_v_N; __pyx_t_18 = __pyx_t_17; for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) { __pyx_v_j = __pyx_t_19;
+093: if i < M - 1:
__pyx_t_13 = (__pyx_v_i < (__pyx_v_M - 1)); if (__pyx_t_13) { /* … */ }
+094: result_gradient_view[0, i, j] = result_channel_view[i + 1, j] - result_channel_view[i, j]
__pyx_t_22 = (__pyx_v_i + 1); __pyx_t_21 = __pyx_v_j; if (__pyx_t_22 < 0) __pyx_t_22 += __pyx_v_result_channel_view.shape[0]; if (__pyx_t_21 < 0) __pyx_t_21 += __pyx_v_result_channel_view.shape[1]; __pyx_t_20 = __pyx_v_i; __pyx_t_24 = __pyx_v_j; if (__pyx_t_20 < 0) __pyx_t_20 += __pyx_v_result_channel_view.shape[0]; if (__pyx_t_24 < 0) __pyx_t_24 += __pyx_v_result_channel_view.shape[1]; __pyx_t_23 = 0; __pyx_t_25 = __pyx_v_i; __pyx_t_26 = __pyx_v_j; if (__pyx_t_23 < 0) __pyx_t_23 += __pyx_v_result_gradient_view.shape[0]; if (__pyx_t_25 < 0) __pyx_t_25 += __pyx_v_result_gradient_view.shape[1]; if (__pyx_t_26 < 0) __pyx_t_26 += __pyx_v_result_gradient_view.shape[2]; *((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_result_gradient_view.data + __pyx_t_23 * __pyx_v_result_gradient_view.strides[0]) ) + __pyx_t_25 * __pyx_v_result_gradient_view.strides[1]) ) + __pyx_t_26 * __pyx_v_result_gradient_view.strides[2]) )) = ((*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_result_channel_view.data + __pyx_t_22 * __pyx_v_result_channel_view.strides[0]) ) + __pyx_t_21 * __pyx_v_result_channel_view.strides[1]) ))) - (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_result_channel_view.data + __pyx_t_20 * __pyx_v_result_channel_view.strides[0]) ) + __pyx_t_24 * __pyx_v_result_channel_view.strides[1]) ))));
+095: if j < N - 1:
__pyx_t_13 = (__pyx_v_j < (__pyx_v_N - 1)); if (__pyx_t_13) { /* … */ } } }
+096: result_gradient_view[1, i, j] = result_channel_view[i, j + 1] - result_channel_view[i, j]
__pyx_t_24 = __pyx_v_i; __pyx_t_20 = (__pyx_v_j + 1); if (__pyx_t_24 < 0) __pyx_t_24 += __pyx_v_result_channel_view.shape[0]; if (__pyx_t_20 < 0) __pyx_t_20 += __pyx_v_result_channel_view.shape[1]; __pyx_t_21 = __pyx_v_i; __pyx_t_22 = __pyx_v_j; if (__pyx_t_21 < 0) __pyx_t_21 += __pyx_v_result_channel_view.shape[0]; if (__pyx_t_22 < 0) __pyx_t_22 += __pyx_v_result_channel_view.shape[1]; __pyx_t_26 = 1; __pyx_t_25 = __pyx_v_i; __pyx_t_23 = __pyx_v_j; if (__pyx_t_26 < 0) __pyx_t_26 += __pyx_v_result_gradient_view.shape[0]; if (__pyx_t_25 < 0) __pyx_t_25 += __pyx_v_result_gradient_view.shape[1]; if (__pyx_t_23 < 0) __pyx_t_23 += __pyx_v_result_gradient_view.shape[2]; *((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_result_gradient_view.data + __pyx_t_26 * __pyx_v_result_gradient_view.strides[0]) ) + __pyx_t_25 * __pyx_v_result_gradient_view.strides[1]) ) + __pyx_t_23 * __pyx_v_result_gradient_view.strides[2]) )) = ((*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_result_channel_view.data + __pyx_t_24 * __pyx_v_result_channel_view.strides[0]) ) + __pyx_t_20 * __pyx_v_result_channel_view.strides[1]) ))) - (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_result_channel_view.data + __pyx_t_21 * __pyx_v_result_channel_view.strides[0]) ) + __pyx_t_22 * __pyx_v_result_channel_view.strides[1]) ))));
097:
098:
+099: max_var = 0
__pyx_v_max_var = 0.0;
+100: for i in range(M):
__pyx_t_14 = __pyx_v_M; __pyx_t_15 = __pyx_t_14; for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) { __pyx_v_i = __pyx_t_16;
+101: for j in range(N):
__pyx_t_17 = __pyx_v_N; __pyx_t_18 = __pyx_t_17; for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) { __pyx_v_j = __pyx_t_19;
+102: for ax in range(2):
for (__pyx_t_27 = 0; __pyx_t_27 < 2; __pyx_t_27+=1) { __pyx_v_ax = __pyx_t_27;
+103: tmp = p_view[ax, i, j]
__pyx_t_22 = __pyx_v_ax; __pyx_t_21 = __pyx_v_i; __pyx_t_20 = __pyx_v_j; if (__pyx_t_22 < 0) __pyx_t_22 += __pyx_v_p_view.shape[0]; if (__pyx_t_21 < 0) __pyx_t_21 += __pyx_v_p_view.shape[1]; if (__pyx_t_20 < 0) __pyx_t_20 += __pyx_v_p_view.shape[2]; __pyx_v_tmp = (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_p_view.data + __pyx_t_22 * __pyx_v_p_view.strides[0]) ) + __pyx_t_21 * __pyx_v_p_view.strides[1]) ) + __pyx_t_20 * __pyx_v_p_view.strides[2]) )));
104: scale = (
+105: 1.0 + tau / weight * sqrt(
if (unlikely(__pyx_v_weight == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); __PYX_ERR(0, 105, __pyx_L1_error) } /* … */ __pyx_v_scale = (1.0 + ((((double)__pyx_v_tau) / __pyx_v_weight) * sqrt((pow((*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_result_gradient_view.data + __pyx_t_20 * __pyx_v_result_gradient_view.strides[0]) ) + __pyx_t_21 * __pyx_v_result_gradient_view.strides[1]) ) + __pyx_t_22 * __pyx_v_result_gradient_view.strides[2]) ))), 2.0) + pow((*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_result_gradient_view.data + __pyx_t_24 * __pyx_v_result_gradient_view.strides[0]) ) + __pyx_t_23 * __pyx_v_result_gradient_view.strides[1]) ) + __pyx_t_25 * __pyx_v_result_gradient_view.strides[2]) ))), 2.0)))));
+106: result_gradient_view[0, i, j]**2 + result_gradient_view[1, i, j]**2
__pyx_t_20 = 0; __pyx_t_21 = __pyx_v_i; __pyx_t_22 = __pyx_v_j; if (__pyx_t_20 < 0) __pyx_t_20 += __pyx_v_result_gradient_view.shape[0]; if (__pyx_t_21 < 0) __pyx_t_21 += __pyx_v_result_gradient_view.shape[1]; if (__pyx_t_22 < 0) __pyx_t_22 += __pyx_v_result_gradient_view.shape[2]; __pyx_t_24 = 1; __pyx_t_23 = __pyx_v_i; __pyx_t_25 = __pyx_v_j; if (__pyx_t_24 < 0) __pyx_t_24 += __pyx_v_result_gradient_view.shape[0]; if (__pyx_t_23 < 0) __pyx_t_23 += __pyx_v_result_gradient_view.shape[1]; if (__pyx_t_25 < 0) __pyx_t_25 += __pyx_v_result_gradient_view.shape[2];
107: )
108: )
+109: p_view[ax, i, j] = p_view[ax, i, j] - tau * result_gradient_view[ax, i, j]
__pyx_t_25 = __pyx_v_ax; __pyx_t_23 = __pyx_v_i; __pyx_t_24 = __pyx_v_j; if (__pyx_t_25 < 0) __pyx_t_25 += __pyx_v_p_view.shape[0]; if (__pyx_t_23 < 0) __pyx_t_23 += __pyx_v_p_view.shape[1]; if (__pyx_t_24 < 0) __pyx_t_24 += __pyx_v_p_view.shape[2]; __pyx_t_22 = __pyx_v_ax; __pyx_t_21 = __pyx_v_i; __pyx_t_20 = __pyx_v_j; if (__pyx_t_22 < 0) __pyx_t_22 += __pyx_v_result_gradient_view.shape[0]; if (__pyx_t_21 < 0) __pyx_t_21 += __pyx_v_result_gradient_view.shape[1]; if (__pyx_t_20 < 0) __pyx_t_20 += __pyx_v_result_gradient_view.shape[2]; __pyx_t_26 = __pyx_v_ax; __pyx_t_28 = __pyx_v_i; __pyx_t_29 = __pyx_v_j; if (__pyx_t_26 < 0) __pyx_t_26 += __pyx_v_p_view.shape[0]; if (__pyx_t_28 < 0) __pyx_t_28 += __pyx_v_p_view.shape[1]; if (__pyx_t_29 < 0) __pyx_t_29 += __pyx_v_p_view.shape[2]; *((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_p_view.data + __pyx_t_26 * __pyx_v_p_view.strides[0]) ) + __pyx_t_28 * __pyx_v_p_view.strides[1]) ) + __pyx_t_29 * __pyx_v_p_view.strides[2]) )) = ((*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_p_view.data + __pyx_t_25 * __pyx_v_p_view.strides[0]) ) + __pyx_t_23 * __pyx_v_p_view.strides[1]) ) + __pyx_t_24 * __pyx_v_p_view.strides[2]) ))) - (__pyx_v_tau * (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_result_gradient_view.data + __pyx_t_22 * __pyx_v_result_gradient_view.strides[0]) ) + __pyx_t_21 * __pyx_v_result_gradient_view.strides[1]) ) + __pyx_t_20 * __pyx_v_result_gradient_view.strides[2]) )))));
+110: p_view[ax, i, j] = p_view[ax, i, j] / scale
__pyx_t_20 = __pyx_v_ax; __pyx_t_21 = __pyx_v_i; __pyx_t_22 = __pyx_v_j; if (__pyx_t_20 < 0) __pyx_t_20 += __pyx_v_p_view.shape[0]; if (__pyx_t_21 < 0) __pyx_t_21 += __pyx_v_p_view.shape[1]; if (__pyx_t_22 < 0) __pyx_t_22 += __pyx_v_p_view.shape[2]; __pyx_t_30 = (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_p_view.data + __pyx_t_20 * __pyx_v_p_view.strides[0]) ) + __pyx_t_21 * __pyx_v_p_view.strides[1]) ) + __pyx_t_22 * __pyx_v_p_view.strides[2]) ))); if (unlikely(__pyx_v_scale == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); __PYX_ERR(0, 110, __pyx_L1_error) } __pyx_t_22 = __pyx_v_ax; __pyx_t_21 = __pyx_v_i; __pyx_t_20 = __pyx_v_j; if (__pyx_t_22 < 0) __pyx_t_22 += __pyx_v_p_view.shape[0]; if (__pyx_t_21 < 0) __pyx_t_21 += __pyx_v_p_view.shape[1]; if (__pyx_t_20 < 0) __pyx_t_20 += __pyx_v_p_view.shape[2]; *((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_p_view.data + __pyx_t_22 * __pyx_v_p_view.strides[0]) ) + __pyx_t_21 * __pyx_v_p_view.strides[1]) ) + __pyx_t_20 * __pyx_v_p_view.strides[2]) )) = (__pyx_t_30 / __pyx_v_scale);
+111: tmp_var = abs(p_view[ax, i, j] - tmp)
__pyx_t_20 = __pyx_v_ax; __pyx_t_21 = __pyx_v_i; __pyx_t_22 = __pyx_v_j; if (__pyx_t_20 < 0) __pyx_t_20 += __pyx_v_p_view.shape[0]; if (__pyx_t_21 < 0) __pyx_t_21 += __pyx_v_p_view.shape[1]; if (__pyx_t_22 < 0) __pyx_t_22 += __pyx_v_p_view.shape[2]; __pyx_v_tmp_var = fabs(((*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_p_view.data + __pyx_t_20 * __pyx_v_p_view.strides[0]) ) + __pyx_t_21 * __pyx_v_p_view.strides[1]) ) + __pyx_t_22 * __pyx_v_p_view.strides[2]) ))) - __pyx_v_tmp));
+112: if tmp_var > max_var:
__pyx_t_13 = (__pyx_v_tmp_var > __pyx_v_max_var); if (__pyx_t_13) { /* … */ } } } }
+113: max_var = tmp_var
__pyx_v_max_var = __pyx_v_tmp_var;
114:
115: #factors = 1.0 + tau / weight * np.sqrt(
116: # np.power(result_gradient, 2).sum(axis=0)
117: #)
118: #factors = factors[np.newaxis, ...]
119: #p_new = p - tau * result_gradient
120: #p_new /= factors
121:
122: # max_var = np.max(np.abs(p_new - p))
123: # if num_iter % 20 == 0:
124: # print(f"Maximal variation: {max_var}")
125:
+126: if max_var < epsilon:
__pyx_t_13 = (__pyx_v_max_var < __pyx_v_epsilon); if (__pyx_t_13) { /* … */ }
+127: print(f"Converged after {num_iter} iterations.")
__pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_14 = 0; __pyx_t_31 = 127; __Pyx_INCREF(__pyx_kp_u_Converged_after); __pyx_t_14 += 16; __Pyx_GIVEREF(__pyx_kp_u_Converged_after); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_kp_u_Converged_after); __pyx_t_7 = __Pyx_PyUnicode_From_int(__pyx_v_num_iter, 0, ' ', 'd'); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_14 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_7); __pyx_t_7 = 0; __Pyx_INCREF(__pyx_kp_u_iterations); __pyx_t_14 += 12; __Pyx_GIVEREF(__pyx_kp_u_iterations); PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_kp_u_iterations); __pyx_t_7 = __Pyx_PyUnicode_Join(__pyx_t_6, 3, __pyx_t_14, __pyx_t_31); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+128: break
goto __pyx_L6_break;
129:
+130: num_iter += 1
__pyx_v_num_iter = (__pyx_v_num_iter + 1); } __pyx_L6_break:;
131:
+132: result_image_view[:, :, channel] = result_channel_view
__pyx_t_12.data = __pyx_v_result_image_view.data;
__pyx_t_12.memview = __pyx_v_result_image_view.memview;
__PYX_INC_MEMVIEW(&__pyx_t_12, 1);
__pyx_t_12.shape[0] = __pyx_v_result_image_view.shape[0];
__pyx_t_12.strides[0] = __pyx_v_result_image_view.strides[0];
__pyx_t_12.suboffsets[0] = -1;
__pyx_t_12.shape[1] = __pyx_v_result_image_view.shape[1];
__pyx_t_12.strides[1] = __pyx_v_result_image_view.strides[1];
__pyx_t_12.suboffsets[1] = -1;
{
Py_ssize_t __pyx_tmp_idx = __pyx_v_channel;
Py_ssize_t __pyx_tmp_shape = __pyx_v_result_image_view.shape[2];
Py_ssize_t __pyx_tmp_stride = __pyx_v_result_image_view.strides[2];
if (__pyx_tmp_idx < 0)
__pyx_tmp_idx += __pyx_tmp_shape;
__pyx_t_12.data += __pyx_tmp_idx * __pyx_tmp_stride;
}
if (unlikely((__pyx_memoryview_copy_contents(__pyx_v_result_channel_view, __pyx_t_12, 2, 2, 0) < 0))) __PYX_ERR(0, 132, __pyx_L1_error)
__PYX_XCLEAR_MEMVIEW(&__pyx_t_12, 1);
__pyx_t_12.memview = NULL; __pyx_t_12.data = NULL;
}
133:
134:
+135: return Image.fromarray(
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_Image); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 135, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_fromarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 135, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
136: # (result_image * 255).astype(np.uint8)
+137: np.multiply(result_image, 255).astype(np.uint8)
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_multiply); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_v_result_image, __pyx_int_255}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_4, 2+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_astype); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_uint8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_t_3}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_5 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_7}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 135, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_r = __pyx_t_6; __pyx_t_6 = 0; goto __pyx_L0;
138: )
139: