Generated by Cython 0.13 on Thu Jun 2 17:00:12 2011
Raw output: _sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx_0.c
1:
2: include "interrupt.pxi" # ctrl-c interrupt block support
/* "/tmp/sagenbflask/temp/boxen/28187/spyx/_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx/_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx_0.pyx":2 * * include "interrupt.pxi" # ctrl-c interrupt block support #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* include "stdsage.pxi" # ctrl-c interrupt block support * */ __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_1))<
0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
3: include "stdsage.pxi" # ctrl-c interrupt block support
4:
5: include "cdefs.pxi"
6: cimport numpy
7: import pylab
/* "/tmp/sagenbflask/temp/boxen/28187/spyx/_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx/_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx_0.pyx":7 * include "cdefs.pxi" * cimport numpy * import pylab #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * cpdef denoise_cython(numpy.ndarray[numpy.float32_t, ndim=2]img, int i, int j): */ __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__pylab), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyObject_SetAttr(__pyx_m, __pyx_n_s__pylab, __pyx_t_1)<
0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8:
9: cpdef denoise_cython(numpy.ndarray[numpy.float32_t, ndim=2]img, int i, int j):
/* "/tmp/sagenbflask/temp/boxen/28187/spyx/_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx/_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx_0.pyx":9 * import pylab * * cpdef denoise_cython(numpy.ndarray[numpy.float32_t, ndim=2]img, int i, int j): #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * # Does a fast, 2-dimensional Fourier Transform, then shifts the quadrants of the matrix */ static PyObject *__pyx_pf_78_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx_0_denoise_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_78_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx_0_denoise_cython(PyArrayObject *__pyx_v_img, int __pyx_v_i, int __pyx_v_j, int __pyx_skip_dispatch) { PyArrayObject *__pyx_v_im = 0; PyObject *__pyx_v_mgrid = 0; PyArrayObject *__pyx_v_kx; PyArrayObject *__pyx_v_ky = 0; int __pyx_v_x_mid; int __pyx_v_y_mid; float __pyx_v_wx; float __pyx_v_wy; PyArrayObject *__pyx_v_filter = 0; PyArrayObject *__pyx_v_imfilt = 0; PyArrayObject *__pyx_v_imf = 0; Py_buffer __pyx_bstruct_img; Py_ssize_t __pyx_bstride_0_img = 0; Py_ssize_t __pyx_bstride_1_img = 0; Py_ssize_t __pyx_bshape_0_img = 0; Py_ssize_t __pyx_bshape_1_img = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannySetupContext("denoise_cython"); __pyx_v_kx = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_img.buf = NULL; { __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_img, (PyObject*)__pyx_v_img, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_bstride_0_img = __pyx_bstruct_img.strides[0]; __pyx_bstride_1_img = __pyx_bstruct_img.strides[1]; __pyx_bshape_0_img = __pyx_bstruct_img.shape[0]; __pyx_bshape_1_img = __pyx_bstruct_img.shape[1]; /* "/tmp/sagenbflask/temp/boxen/28187/spyx/_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx/_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx_0.pyx":9 * import pylab * * cpdef denoise_cython(numpy.ndarray[numpy.float32_t, ndim=2]img, int i, int j): #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * # Does a fast, 2-dimensional Fourier Transform, then shifts the quadrants of the matrix */ static PyObject *__pyx_pf_78_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx_0_denoise_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_78_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx_0_denoise_cython[] = "File: _sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx_0.pyx (starting at line 9)"; static PyObject *__pyx_pf_78_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx_0_denoise_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyArrayObject *__pyx_v_img = 0; int __pyx_v_i; int __pyx_v_j; Py_buffer __pyx_bstruct_img; Py_ssize_t __pyx_bstride_0_img = 0; Py_ssize_t __pyx_bstride_1_img = 0; Py_ssize_t __pyx_bshape_0_img = 0; Py_ssize_t __pyx_bshape_1_img = 0; PyObject *__pyx_r = NULL; static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__img,&__pyx_n_s__i,&__pyx_n_s__j,0}; __Pyx_RefNannySetupContext("denoise_cython"); __pyx_self = __pyx_self; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args = PyDict_Size(__pyx_kwds); PyObject* values[3] = {0,0,0}; switch (PyTuple_GET_SIZE(__pyx_args)) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } switch (PyTuple_GET_SIZE(__pyx_args)) { case 0: values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__img); if (likely(values[0])) kw_args--; else goto __pyx_L5_argtuple_error; case 1: values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__i); if (likely(values[1])) kw_args--; else { __Pyx_RaiseArgtupleInvalid("denoise_cython", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__j); if (likely(values[2])) kw_args--; else { __Pyx_RaiseArgtupleInvalid("denoise_cython", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "denoise_cython")<
0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } __pyx_v_img = ((PyArrayObject *)values[0]); __pyx_v_i = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_i == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_j = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_j == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; } else { __pyx_v_img = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 0)); __pyx_v_i = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_i == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_j = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_j == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("denoise_cython", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx_0.denoise_cython"); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_bstruct_img.buf = NULL; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_img), __pyx_ptype_5numpy_ndarray, 1, "img", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} { __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_img, (PyObject*)__pyx_v_img, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_bstride_0_img = __pyx_bstruct_img.strides[0]; __pyx_bstride_1_img = __pyx_bstruct_img.strides[1]; __pyx_bshape_0_img = __pyx_bstruct_img.shape[0]; __pyx_bshape_1_img = __pyx_bstruct_img.shape[1]; __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_78_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx_0_denoise_cython(__pyx_v_img, __pyx_v_i, __pyx_v_j, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); __Pyx_SafeReleaseBuffer(&__pyx_bstruct_img); __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} __Pyx_AddTraceback("_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx_0.denoise_cython"); __pyx_r = NULL; goto __pyx_L2; __pyx_L0:; __Pyx_SafeReleaseBuffer(&__pyx_bstruct_img); __pyx_L2:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
10:
11: # Does a fast, 2-dimensional Fourier Transform, then shifts the quadrants of the matrix
12: cdef numpy.ndarray im = pylab.fftshift(pylab.fft2(img))
/* "/tmp/sagenbflask/temp/boxen/28187/spyx/_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx/_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx_0.pyx":12 * * # Does a fast, 2-dimensional Fourier Transform, then shifts the quadrants of the matrix * cdef numpy.ndarray im = pylab.fftshift(pylab.fft2(img)) #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * # Creates a meshgrid for use in the filter */ __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__pylab); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__fftshift); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__pylab); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__fft2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)__pyx_v_img)); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_img)); __Pyx_GIVEREF(((PyObject *)__pyx_v_img)); __pyx_t_4 = PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_im = ((PyArrayObject *)__pyx_t_4); __pyx_t_4 = 0;
13:
14: # Creates a meshgrid for use in the filter
15: cdef mgrid = numpy.lib.index_tricks.nd_grid()
/* "/tmp/sagenbflask/temp/boxen/28187/spyx/_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx/_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx_0.pyx":15 * * # Creates a meshgrid for use in the filter * cdef mgrid = numpy.lib.index_tricks.nd_grid() #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* cdef numpy.ndarray kx, ky = mgrid[0:img.shape[0], 0:img.shape[1]] * */ __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__lib); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__index_tricks); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__nd_grid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_mgrid = __pyx_t_4; __pyx_t_4 = 0;
16: cdef numpy.ndarray kx, ky = mgrid[0:img.shape[0], 0:img.shape[1]]
/* "/tmp/sagenbflask/temp/boxen/28187/spyx/_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx/_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx_0.pyx":16 * # Creates a meshgrid for use in the filter * cdef mgrid = numpy.lib.index_tricks.nd_grid() * cdef numpy.ndarray kx, ky = mgrid[0:img.shape[0], 0:img.shape[1]] #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * # The midpoints with respect to the x and y dimensions of the image matrix for use in the filter */ __pyx_t_4 = __Pyx_PyInt_to_py_Py_intptr_t((__pyx_v_img->dimensions[0])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = PySlice_New(__pyx_int_0, __pyx_t_4, Py_None); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyInt_to_py_Py_intptr_t((__pyx_v_img->dimensions[1])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = PySlice_New(__pyx_int_0, __pyx_t_4, Py_None); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_2 = PyObject_GetItem(__pyx_v_mgrid, __pyx_t_4); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_ky = ((PyArrayObject *)__pyx_t_2); __pyx_t_2 = 0;
17:
18: # The midpoints with respect to the x and y dimensions of the image matrix for use in the filter
19: cdef int x_mid = img.shape[0]/2
/* "/tmp/sagenbflask/temp/boxen/28187/spyx/_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx/_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx_0.pyx":19 * * # The midpoints with respect to the x and y dimensions of the image matrix for use in the filter * cdef int x_mid = img.shape[0]/2 #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* cdef int y_mid = img.shape[1]/2 * */ __pyx_v_x_mid = __Pyx_div_long((__pyx_v_img->dimensions[0]), 2);
20: cdef int y_mid = img.shape[1]/2
/* "/tmp/sagenbflask/temp/boxen/28187/spyx/_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx/_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx_0.pyx":20 * # The midpoints with respect to the x and y dimensions of the image matrix for use in the filter * cdef int x_mid = img.shape[0]/2 * cdef int y_mid = img.shape[1]/2 #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * # The desired widths for the filter */ __pyx_v_y_mid = __Pyx_div_long((__pyx_v_img->dimensions[1]), 2);
21:
22: # The desired widths for the filter
23: cdef float wx = 1/i
/* "/tmp/sagenbflask/temp/boxen/28187/spyx/_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx/_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx_0.pyx":23 * * # The desired widths for the filter * cdef float wx = 1/i #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* cdef float wy = 1/j * */ if (unlikely(__pyx_v_i == 0)) { PyErr_Format(PyExc_ZeroDivisionError, "integer division or modulo by zero"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } else if (sizeof(long) == sizeof(long) && unlikely(__pyx_v_i == -1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(1))) { PyErr_Format(PyExc_OverflowError, "value too large to perform division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_v_wx = __Pyx_div_long(1, __pyx_v_i);
24: cdef float wy = 1/j
/* "/tmp/sagenbflask/temp/boxen/28187/spyx/_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx/_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx_0.pyx":24 * # The desired widths for the filter * cdef float wx = 1/i * cdef float wy = 1/j #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * # The filter used to remove noise from the Fourier Transform of the image */ if (unlikely(__pyx_v_j == 0)) { PyErr_Format(PyExc_ZeroDivisionError, "integer division or modulo by zero"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } else if (sizeof(long) == sizeof(long) && unlikely(__pyx_v_j == -1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(1))) { PyErr_Format(PyExc_OverflowError, "value too large to perform division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_v_wy = __Pyx_div_long(1, __pyx_v_j);
25:
26: # The filter used to remove noise from the Fourier Transform of the image
27: cdef numpy.ndarray filter = numpy.exp(-wy*(kx-x_mid)**2 - wx*(ky-y_mid)**2)
/* "/tmp/sagenbflask/temp/boxen/28187/spyx/_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx/_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx_0.pyx":27 * * # The filter used to remove noise from the Fourier Transform of the image * cdef numpy.ndarray filter = numpy.exp(-wy*(kx-x_mid)**2 - wx*(ky-y_mid)**2) #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * # Applying the filter to the Fourier Transform */ __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__exp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyFloat_FromDouble((-__pyx_v_wy)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyInt_FromLong(__pyx_v_x_mid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyNumber_Subtract(((PyObject *)__pyx_v_kx), __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_Power(__pyx_t_3, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyFloat_FromDouble(__pyx_v_wx); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyInt_FromLong(__pyx_v_y_mid); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = PyNumber_Subtract(((PyObject *)__pyx_v_ky), __pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyNumber_Power(__pyx_t_5, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyNumber_Multiply(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyNumber_Subtract(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_filter = ((PyArrayObject *)__pyx_t_2); __pyx_t_2 = 0;
28:
29: # Applying the filter to the Fourier Transform
30: cdef numpy.ndarray imfilt = pylab.multiply(im,filter)
/* "/tmp/sagenbflask/temp/boxen/28187/spyx/_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx/_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx_0.pyx":30 * * # Applying the filter to the Fourier Transform * cdef numpy.ndarray imfilt = pylab.multiply(im,filter) #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * # Reverses the previous shift on the quadrants and inverses the Fourier Transform to get the filtered image */ __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__pylab); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__multiply); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(((PyObject *)__pyx_v_im)); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_im)); __Pyx_GIVEREF(((PyObject *)__pyx_v_im)); __Pyx_INCREF(((PyObject *)__pyx_v_filter)); PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_filter)); __Pyx_GIVEREF(((PyObject *)__pyx_v_filter)); __pyx_t_4 = PyObject_Call(__pyx_t_5, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_imfilt = ((PyArrayObject *)__pyx_t_4); __pyx_t_4 = 0;
31:
32: # Reverses the previous shift on the quadrants and inverses the Fourier Transform to get the filtered image
33: cdef numpy.ndarray imf = pylab.ifft2(pylab.ifftshift(imfilt))
/* "/tmp/sagenbflask/temp/boxen/28187/spyx/_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx/_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx_0.pyx":33 * * # Reverses the previous shift on the quadrants and inverses the Fourier Transform to get the filtered image * cdef numpy.ndarray imf = pylab.ifft2(pylab.ifftshift(imfilt)) #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* return imf */ __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__pylab); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__ifft2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__pylab); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__ifftshift); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(((PyObject *)__pyx_v_imfilt)); PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_imfilt)); __Pyx_GIVEREF(((PyObject *)__pyx_v_imfilt)); __pyx_t_3 = PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_imf = ((PyArrayObject *)__pyx_t_3); __pyx_t_3 = 0;
34: return imf
/* "/tmp/sagenbflask/temp/boxen/28187/spyx/_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx/_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx_0.pyx":34 * # Reverses the previous shift on the quadrants and inverses the Fourier Transform to get the filtered image * cdef numpy.ndarray imf = pylab.ifft2(pylab.ifftshift(imfilt)) * return imf #<
<
<
<
<
<
<
<
<
<
<
<
<
<
*/ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_imf)); __pyx_r = ((PyObject *)__pyx_v_imf); goto __pyx_L0; __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); __Pyx_SafeReleaseBuffer(&__pyx_bstruct_img); __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} __Pyx_AddTraceback("_sagenb_flask_sage_notebook_sagenb_home_openid4p4BbseWKk_22_code_sage55_spyx_0.denoise_cython"); __pyx_r = 0; goto __pyx_L2; __pyx_L0:; __Pyx_SafeReleaseBuffer(&__pyx_bstruct_img); __pyx_L2:; __Pyx_XDECREF((PyObject *)__pyx_v_im); __Pyx_XDECREF(__pyx_v_mgrid); __Pyx_DECREF((PyObject *)__pyx_v_kx); __Pyx_XDECREF((PyObject *)__pyx_v_ky); __Pyx_XDECREF((PyObject *)__pyx_v_filter); __Pyx_XDECREF((PyObject *)__pyx_v_imfilt); __Pyx_XDECREF((PyObject *)__pyx_v_imf); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }