Generated by Cython 0.29.32
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: gaussianBlur5x5.cpp
+001: # cython: binding=False, boundscheck=False, wraparound=False, nonecheck=False, cdivision=True, profile=False
__pyx_t_7 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_7) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
002: # cython: optimize.use_switch=True
003: # cython: warn.maybe_uninitialized=False
004: # cython: warn.unused=False
005: # cython: warn.unused_result=False
006: # cython: warn.unused_arg=False
007: # cython: language_level=3
008: # encoding: utf-8
009:
010: """
011: GNU GENERAL PUBLIC LICENSE
012: Version 3, 29 June 2007
013:
014: Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
015: Everyone is permitted to copy and distribute verbatim copies
016: of this license document, but changing it is not allowed.
017:
018: Copyright Yoann Berenguer
019: """
020:
021: # NUMPY IS REQUIRED
+022: from pygame.surfarray import pixels3d, array_alpha
__pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_pixels3d); __Pyx_GIVEREF(__pyx_n_s_pixels3d); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_pixels3d); __Pyx_INCREF(__pyx_n_s_array_alpha); __Pyx_GIVEREF(__pyx_n_s_array_alpha); PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_array_alpha); __pyx_t_2 = __Pyx_Import(__pyx_n_s_pygame_surfarray, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_pixels3d, __pyx_t_1) < 0) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_array_alpha); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_array_alpha, __pyx_t_1) < 0) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+023: from pygame import Surface
__pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_Surface); __Pyx_GIVEREF(__pyx_n_s_Surface); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_Surface); __pyx_t_1 = __Pyx_Import(__pyx_n_s_pygame, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Surface, __pyx_t_2) < 0) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+024: from pygame.image import frombuffer
__pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_frombuffer); __Pyx_GIVEREF(__pyx_n_s_frombuffer); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_frombuffer); __pyx_t_2 = __Pyx_Import(__pyx_n_s_pygame_image, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_frombuffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_frombuffer, __pyx_t_1) < 0) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
025:
+026: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L7_try_end; __pyx_L2_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5); goto __pyx_L1_error; __pyx_L7_try_end:; }
+027: import numpy
__pyx_t_2 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_numpy, __pyx_t_2) < 0) __PYX_ERR(0, 27, __pyx_L2_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+028: from numpy import ndarray, zeros, empty, uint8, int32, float64, float32, \
__pyx_t_2 = PyList_New(21); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_ndarray); __Pyx_GIVEREF(__pyx_n_s_ndarray); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_ndarray); __Pyx_INCREF(__pyx_n_s_zeros); __Pyx_GIVEREF(__pyx_n_s_zeros); PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_zeros); __Pyx_INCREF(__pyx_n_s_empty); __Pyx_GIVEREF(__pyx_n_s_empty); PyList_SET_ITEM(__pyx_t_2, 2, __pyx_n_s_empty); __Pyx_INCREF(__pyx_n_s_uint8); __Pyx_GIVEREF(__pyx_n_s_uint8); PyList_SET_ITEM(__pyx_t_2, 3, __pyx_n_s_uint8); __Pyx_INCREF(__pyx_n_s_int32); __Pyx_GIVEREF(__pyx_n_s_int32); PyList_SET_ITEM(__pyx_t_2, 4, __pyx_n_s_int32); __Pyx_INCREF(__pyx_n_s_float64); __Pyx_GIVEREF(__pyx_n_s_float64); PyList_SET_ITEM(__pyx_t_2, 5, __pyx_n_s_float64); __Pyx_INCREF(__pyx_n_s_float32); __Pyx_GIVEREF(__pyx_n_s_float32); PyList_SET_ITEM(__pyx_t_2, 6, __pyx_n_s_float32); __Pyx_INCREF(__pyx_n_s_dstack); __Pyx_GIVEREF(__pyx_n_s_dstack); PyList_SET_ITEM(__pyx_t_2, 7, __pyx_n_s_dstack); __Pyx_INCREF(__pyx_n_s_full); __Pyx_GIVEREF(__pyx_n_s_full); PyList_SET_ITEM(__pyx_t_2, 8, __pyx_n_s_full); __Pyx_INCREF(__pyx_n_s_ones); __Pyx_GIVEREF(__pyx_n_s_ones); PyList_SET_ITEM(__pyx_t_2, 9, __pyx_n_s_ones); __Pyx_INCREF(__pyx_n_s_asarray); __Pyx_GIVEREF(__pyx_n_s_asarray); PyList_SET_ITEM(__pyx_t_2, 10, __pyx_n_s_asarray); __Pyx_INCREF(__pyx_n_s_ascontiguousarray); __Pyx_GIVEREF(__pyx_n_s_ascontiguousarray); PyList_SET_ITEM(__pyx_t_2, 11, __pyx_n_s_ascontiguousarray); __Pyx_INCREF(__pyx_n_s_full_like); __Pyx_GIVEREF(__pyx_n_s_full_like); PyList_SET_ITEM(__pyx_t_2, 12, __pyx_n_s_full_like); __Pyx_INCREF(__pyx_n_s_add); __Pyx_GIVEREF(__pyx_n_s_add); PyList_SET_ITEM(__pyx_t_2, 13, __pyx_n_s_add); __Pyx_INCREF(__pyx_n_s_putmask); __Pyx_GIVEREF(__pyx_n_s_putmask); PyList_SET_ITEM(__pyx_t_2, 14, __pyx_n_s_putmask); __Pyx_INCREF(__pyx_n_s_int16); __Pyx_GIVEREF(__pyx_n_s_int16); PyList_SET_ITEM(__pyx_t_2, 15, __pyx_n_s_int16); __Pyx_INCREF(__pyx_n_s_arange); __Pyx_GIVEREF(__pyx_n_s_arange); PyList_SET_ITEM(__pyx_t_2, 16, __pyx_n_s_arange); __Pyx_INCREF(__pyx_n_s_repeat); __Pyx_GIVEREF(__pyx_n_s_repeat); PyList_SET_ITEM(__pyx_t_2, 17, __pyx_n_s_repeat); __Pyx_INCREF(__pyx_n_s_newaxis); __Pyx_GIVEREF(__pyx_n_s_newaxis); PyList_SET_ITEM(__pyx_t_2, 18, __pyx_n_s_newaxis); __Pyx_INCREF(__pyx_n_s_sum); __Pyx_GIVEREF(__pyx_n_s_sum); PyList_SET_ITEM(__pyx_t_2, 19, __pyx_n_s_sum); __Pyx_INCREF(__pyx_n_s_divide); __Pyx_GIVEREF(__pyx_n_s_divide); PyList_SET_ITEM(__pyx_t_2, 20, __pyx_n_s_divide); __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ndarray, __pyx_t_2) < 0) __PYX_ERR(0, 28, __pyx_L2_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_zeros, __pyx_t_2) < 0) __PYX_ERR(0, 28, __pyx_L2_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_empty); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_empty, __pyx_t_2) < 0) __PYX_ERR(0, 28, __pyx_L2_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_uint8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_uint8, __pyx_t_2) < 0) __PYX_ERR(0, 28, __pyx_L2_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_int32); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_int32, __pyx_t_2) < 0) __PYX_ERR(0, 28, __pyx_L2_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_float64); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_float64, __pyx_t_2) < 0) __PYX_ERR(0, 28, __pyx_L2_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_float32); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_float32, __pyx_t_2) < 0) __PYX_ERR(0, 28, __pyx_L2_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_dstack); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_dstack, __pyx_t_2) < 0) __PYX_ERR(0, 29, __pyx_L2_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_full); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_full, __pyx_t_2) < 0) __PYX_ERR(0, 29, __pyx_L2_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_ones); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ones, __pyx_t_2) < 0) __PYX_ERR(0, 29, __pyx_L2_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_asarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_asarray, __pyx_t_2) < 0) __PYX_ERR(0, 29, __pyx_L2_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_ascontiguousarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ascontiguousarray, __pyx_t_2) < 0) __PYX_ERR(0, 29, __pyx_L2_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_full_like); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_full_like, __pyx_t_2) < 0) __PYX_ERR(0, 29, __pyx_L2_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_add); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_add, __pyx_t_2) < 0) __PYX_ERR(0, 29, __pyx_L2_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_putmask); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_putmask, __pyx_t_2) < 0) __PYX_ERR(0, 29, __pyx_L2_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_int16); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_int16, __pyx_t_2) < 0) __PYX_ERR(0, 30, __pyx_L2_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_arange); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_arange, __pyx_t_2) < 0) __PYX_ERR(0, 30, __pyx_L2_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_repeat); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_repeat, __pyx_t_2) < 0) __PYX_ERR(0, 30, __pyx_L2_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_newaxis); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_newaxis, __pyx_t_2) < 0) __PYX_ERR(0, 30, __pyx_L2_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_sum); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_sum, __pyx_t_2) < 0) __PYX_ERR(0, 30, __pyx_L2_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_divide); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_divide, __pyx_t_2) < 0) __PYX_ERR(0, 30, __pyx_L2_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
029: dstack, full, ones, asarray, ascontiguousarray, full_like, add, putmask,\
030: int16, arange, repeat, newaxis, sum, divide
+031: except ImportError:
__pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ImportError); if (__pyx_t_6) { __Pyx_AddTraceback("PygameShader.gaussianBlur5x5", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_7) < 0) __PYX_ERR(0, 31, __pyx_L4_except_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GOTREF(__pyx_t_2); __Pyx_GOTREF(__pyx_t_7);
+032: print("\n<numpy> library is missing on your system."
__pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_tuple__26, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 32, __pyx_L4_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; /* … */ __pyx_tuple__26 = PyTuple_Pack(1, __pyx_kp_u_numpy_library_is_missing_on_you); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__26); __Pyx_GIVEREF(__pyx_tuple__26);
033: "\nTry: \n C:\\pip install numpy on a window command prompt.")
+034: raise SystemExit
__Pyx_Raise(__pyx_builtin_SystemExit, 0, 0, 0); __PYX_ERR(0, 34, __pyx_L4_except_error) } goto __pyx_L4_except_error; __pyx_L4_except_error:;
035:
+036: try:
{ /*try:*/ { /* … */ } }
037: cimport cython
038: from cython.parallel cimport prange
039:
040: except ImportError:
041: raise ImportError("\n<cython> library is missing on your system."
042: "\nTry: \n C:\\pip install cython on a window command prompt.")
043:
044:
045:
046: DEF SCHEDULE = 'static'
047:
048: DEF OPENMP = True
049: # num_threads – The num_threads argument indicates how many threads the team should consist of.
050: # If not given, OpenMP will decide how many threads to use.
051: # Typically this is the number of cores available on the machine. However,
052: # this may be controlled through the omp_set_num_threads() function,
053: # or through the OMP_NUM_THREADS environment variable.
054: DEF THREAD_NUMBER = 1
055: if OPENMP is True:
056: DEF THREAD_NUMBER = 8
057:
058:
059: @cython.boundscheck(False)
060: @cython.wraparound(False)
061: @cython.nonecheck(False)
062: @cython.cdivision(True)
063: @cython.profile(False)
+064: cpdef blur5x5_array24_inplace_c(unsigned char [:, :, :] rgb_array_):
static PyObject *__pyx_pw_12PygameShader_15gaussianBlur5x5_1blur5x5_array24_inplace_c(PyObject *__pyx_self, PyObject *__pyx_arg_rgb_array_); /*proto*/ static PyObject *__pyx_f_12PygameShader_15gaussianBlur5x5_blur5x5_array24_inplace_c(__Pyx_memviewslice __pyx_v_rgb_array_, CYTHON_UNUSED int __pyx_skip_dispatch) { int __pyx_v_w; int __pyx_v_h; CYTHON_UNUSED int __pyx_v_dim; CYTHON_UNUSED PyObject *__pyx_v_e = NULL; float __pyx_v_kernel[5]; short __pyx_v_kernel_half; __Pyx_memviewslice __pyx_v_convolve = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_v_x; int __pyx_v_y; int __pyx_v_xx; int __pyx_v_yy; float __pyx_v_k; float __pyx_v_r; float __pyx_v_g; float __pyx_v_b; char __pyx_v_kernel_offset; unsigned char __pyx_v_red; unsigned char __pyx_v_green; unsigned char __pyx_v_blue; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("blur5x5_array24_inplace_c", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __PYX_XDEC_MEMVIEW(&__pyx_t_21, 1); __Pyx_AddTraceback("PygameShader.gaussianBlur5x5.blur5x5_array24_inplace_c", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_e); __PYX_XDEC_MEMVIEW(&__pyx_v_convolve, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_12PygameShader_15gaussianBlur5x5_1blur5x5_array24_inplace_c(PyObject *__pyx_self, PyObject *__pyx_arg_rgb_array_); /*proto*/ static char __pyx_doc_12PygameShader_15gaussianBlur5x5_blur5x5_array24_inplace_c[] = "\n # Gaussian kernel 5x5\n # |1 4 6 4 1|\n # |4 16 24 16 4|\n # |6 24 36 24 6| x 1/256\n # |4 16 24 16 4|\n # |1 4 6 4 1|\n This method is using convolution property and process the image in two passes,\n first the horizontal convolution and last the vertical convolution\n pixels convoluted outside image edges will be set to adjacent edge value\n\n :param rgb_array_: numpy.ndarray type (w, h, 3) uint8 \n :return: Return 24-bit a numpy.ndarray type (w, h, 3) uint8\n "; static PyObject *__pyx_pw_12PygameShader_15gaussianBlur5x5_1blur5x5_array24_inplace_c(PyObject *__pyx_self, PyObject *__pyx_arg_rgb_array_) { __Pyx_memviewslice __pyx_v_rgb_array_ = { 0, 0, { 0 }, { 0 }, { 0 } }; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("blur5x5_array24_inplace_c (wrapper)", 0); assert(__pyx_arg_rgb_array_); { __pyx_v_rgb_array_ = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_arg_rgb_array_, PyBUF_WRITABLE); if (unlikely(!__pyx_v_rgb_array_.memview)) __PYX_ERR(0, 64, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; __Pyx_AddTraceback("PygameShader.gaussianBlur5x5.blur5x5_array24_inplace_c", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_12PygameShader_15gaussianBlur5x5_blur5x5_array24_inplace_c(__pyx_self, __pyx_v_rgb_array_); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_12PygameShader_15gaussianBlur5x5_blur5x5_array24_inplace_c(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_rgb_array_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("blur5x5_array24_inplace_c", 0); __Pyx_XDECREF(__pyx_r); if (unlikely(!__pyx_v_rgb_array_.memview)) { __Pyx_RaiseUnboundLocalError("rgb_array_"); __PYX_ERR(0, 64, __pyx_L1_error) } __pyx_t_1 = __pyx_f_12PygameShader_15gaussianBlur5x5_blur5x5_array24_inplace_c(__pyx_v_rgb_array_, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("PygameShader.gaussianBlur5x5.blur5x5_array24_inplace_c", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_rgb_array_, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
065: """
066: # Gaussian kernel 5x5
067: # |1 4 6 4 1|
068: # |4 16 24 16 4|
069: # |6 24 36 24 6| x 1/256
070: # |4 16 24 16 4|
071: # |1 4 6 4 1|
072: This method is using convolution property and process the image in two passes,
073: first the horizontal convolution and last the vertical convolution
074: pixels convoluted outside image edges will be set to adjacent edge value
075:
076: :param rgb_array_: numpy.ndarray type (w, h, 3) uint8
077: :return: Return 24-bit a numpy.ndarray type (w, h, 3) uint8
078: """
079:
080: cdef int w, h, dim
+081: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L8_try_end; __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; /* … */ __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L1_error; __pyx_L8_try_end:; }
+082: w, h, dim = (<object>rgb_array_).shape[:3]
__pyx_t_4 = __pyx_memoryview_fromslice(__pyx_v_rgb_array_, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 82, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 82, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_t_5, 0, 3, NULL, NULL, &__pyx_slice_, 0, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 82, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) { PyObject* sequence = __pyx_t_4; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 3)) { if (size > 3) __Pyx_RaiseTooManyValuesError(3); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 82, __pyx_L3_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); __pyx_t_7 = PyTuple_GET_ITEM(sequence, 2); } else { __pyx_t_5 = PyList_GET_ITEM(sequence, 0); __pyx_t_6 = PyList_GET_ITEM(sequence, 1); __pyx_t_7 = PyList_GET_ITEM(sequence, 2); } __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); #else __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 82, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 82, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 82, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_7); #endif __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { Py_ssize_t index = -1; __pyx_t_8 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 82, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext; index = 0; __pyx_t_5 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_5)) goto __pyx_L9_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); index = 1; __pyx_t_6 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L9_unpacking_failed; __Pyx_GOTREF(__pyx_t_6); index = 2; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L9_unpacking_failed; __Pyx_GOTREF(__pyx_t_7); if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 3) < 0) __PYX_ERR(0, 82, __pyx_L3_error) __pyx_t_9 = NULL; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L10_unpacking_done; __pyx_L9_unpacking_failed:; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_9 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 82, __pyx_L3_error) __pyx_L10_unpacking_done:; } __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 82, __pyx_L3_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_6); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 82, __pyx_L3_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_7); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 82, __pyx_L3_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_v_w = __pyx_t_10; __pyx_v_h = __pyx_t_11; __pyx_v_dim = __pyx_t_12; /* … */ __pyx_slice_ = PySlice_New(Py_None, __pyx_int_3, Py_None); if (unlikely(!__pyx_slice_)) __PYX_ERR(0, 82, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice_); __Pyx_GIVEREF(__pyx_slice_);
083:
+084: except Exception as e:
__pyx_t_12 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_12) { __Pyx_AddTraceback("PygameShader.gaussianBlur5x5.blur5x5_array24_inplace_c", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_7, &__pyx_t_6) < 0) __PYX_ERR(0, 84, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_t_7); __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); __pyx_v_e = __pyx_t_7; /*try:*/ { /* … */ /*finally:*/ { __pyx_L16_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16) < 0)) __Pyx_ErrFetch(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16); __Pyx_XGOTREF(__pyx_t_14); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __pyx_t_12 = __pyx_lineno; __pyx_t_11 = __pyx_clineno; __pyx_t_13 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = NULL; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19); } __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_ErrRestore(__pyx_t_14, __pyx_t_15, __pyx_t_16); __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_lineno = __pyx_t_12; __pyx_clineno = __pyx_t_11; __pyx_filename = __pyx_t_13; goto __pyx_L5_except_error; } } } goto __pyx_L5_except_error; __pyx_L5_except_error:;
+085: raise ValueError('\nArray shape not understood.')
__pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 85, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __PYX_ERR(0, 85, __pyx_L16_error) } /* … */ __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_u_Array_shape_not_understood); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 85, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__2); __Pyx_GIVEREF(__pyx_tuple__2);
086:
087: # kernel 5x5 separable
088: cdef:
+089: float[5] kernel = [<float>(1.0/16.0), <float>(4.0/16.0),
__pyx_t_20[0] = ((float)(1.0 / 16.0)); __pyx_t_20[1] = ((float)(4.0 / 16.0)); __pyx_t_20[2] = ((float)(6.0 / 16.0)); __pyx_t_20[3] = ((float)(4.0 / 16.0)); __pyx_t_20[4] = ((float)(1.0 / 16.0)); memcpy(&(__pyx_v_kernel[0]), __pyx_t_20, sizeof(__pyx_v_kernel[0]) * (5));
090: <float>(6.0/16.0), <float>(4.0/16.0), <float>(1.0/16.0)]
+091: short int kernel_half = <short int>2
__pyx_v_kernel_half = ((short)2);
+092: unsigned char [:, :, ::1] convolve = numpy.empty((w, h, 3), dtype=uint8)
__Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_empty); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_w); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_h); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4); __Pyx_INCREF(__pyx_int_3); __Pyx_GIVEREF(__pyx_int_3); PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_int_3); __pyx_t_6 = 0; __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_uint8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_t_6) < 0) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_21 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_unsigned_char(__pyx_t_6, PyBUF_WRITABLE); if (unlikely(!__pyx_t_21.memview)) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_convolve = __pyx_t_21; __pyx_t_21.memview = NULL; __pyx_t_21.data = NULL;
093: int x, y, xx, yy
094: float k, r, g, b, s
095: char kernel_offset
096: unsigned char red, green, blue
097:
+098: with nogil:
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L24; } __pyx_L24:; } }
099: # horizontal convolution
+100: for y in prange(0, h, schedule=SCHEDULE, num_threads=THREAD_NUMBER): # range [0..h-1)
__pyx_t_11 = __pyx_v_h; if ((1 == 0)) abort(); { #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) #undef likely #undef unlikely #define likely(x) (x) #define unlikely(x) (x) #endif __pyx_t_23 = (__pyx_t_11 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_23 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_blue) lastprivate(__pyx_v_g) lastprivate(__pyx_v_green) lastprivate(__pyx_v_k) lastprivate(__pyx_v_kernel_offset) lastprivate(__pyx_v_r) lastprivate(__pyx_v_red) lastprivate(__pyx_v_x) lastprivate(__pyx_v_xx) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) schedule(static) num_threads(8) #endif /* _OPENMP */ for (__pyx_t_22 = 0; __pyx_t_22 < __pyx_t_23; __pyx_t_22++){ { __pyx_v_y = (int)(0 + 1 * __pyx_t_22); /* Initialize private variables to invalid values */ __pyx_v_b = ((float)__PYX_NAN()); __pyx_v_blue = ((unsigned char)'?'); __pyx_v_g = ((float)__PYX_NAN()); __pyx_v_green = ((unsigned char)'?'); __pyx_v_k = ((float)__PYX_NAN()); __pyx_v_kernel_offset = ((char)'?'); __pyx_v_r = ((float)__PYX_NAN()); __pyx_v_red = ((unsigned char)'?'); __pyx_v_x = ((int)0xbad0bad0); __pyx_v_xx = ((int)0xbad0bad0);
101:
+102: for x in range(0, w): # range [0..w-1]
__pyx_t_12 = __pyx_v_w; __pyx_t_10 = __pyx_t_12; for (__pyx_t_24 = 0; __pyx_t_24 < __pyx_t_10; __pyx_t_24+=1) { __pyx_v_x = __pyx_t_24;
103:
+104: r, g, b = 0, 0, 0
__pyx_t_25 = 0.0; __pyx_t_26 = 0.0; __pyx_t_27 = 0.0; __pyx_v_r = __pyx_t_25; __pyx_v_g = __pyx_t_26; __pyx_v_b = __pyx_t_27;
105:
+106: for kernel_offset in range(-kernel_half, kernel_half + 1):
__pyx_t_28 = (__pyx_v_kernel_half + 1); __pyx_t_29 = __pyx_t_28; for (__pyx_t_30 = (-__pyx_v_kernel_half); __pyx_t_30 < __pyx_t_29; __pyx_t_30+=1) { __pyx_v_kernel_offset = __pyx_t_30;
107:
+108: k = kernel[kernel_offset + kernel_half]
__pyx_v_k = (__pyx_v_kernel[(__pyx_v_kernel_offset + __pyx_v_kernel_half)]);
109:
+110: xx = x + kernel_offset
__pyx_v_xx = (__pyx_v_x + __pyx_v_kernel_offset);
111:
112: # check boundaries.
113: # Fetch the edge pixel for the convolution
+114: if xx < 0:
__pyx_t_31 = ((__pyx_v_xx < 0) != 0); if (__pyx_t_31) { /* … */ goto __pyx_L33; }
+115: red, green, blue = rgb_array_[0, y, 0],\
__pyx_t_32 = 0; __pyx_t_33 = __pyx_v_y; __pyx_t_34 = 0; __pyx_t_35 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_32 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_33 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_34 * __pyx_v_rgb_array_.strides[2]) )));
+116: rgb_array_[0, y, 1], rgb_array_[0, y, 2]
__pyx_t_34 = 0; __pyx_t_33 = __pyx_v_y; __pyx_t_32 = 1; __pyx_t_36 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_34 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_33 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_32 * __pyx_v_rgb_array_.strides[2]) ))); __pyx_t_32 = 0; __pyx_t_33 = __pyx_v_y; __pyx_t_34 = 2; __pyx_t_37 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_32 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_33 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_34 * __pyx_v_rgb_array_.strides[2]) ))); __pyx_v_red = __pyx_t_35; __pyx_v_green = __pyx_t_36; __pyx_v_blue = __pyx_t_37;
+117: elif xx > (w - 1):
__pyx_t_31 = ((__pyx_v_xx > (__pyx_v_w - 1)) != 0); if (__pyx_t_31) { /* … */ goto __pyx_L33; }
+118: red, green, blue = rgb_array_[w-1, y, 0],\
__pyx_t_34 = (__pyx_v_w - 1); __pyx_t_33 = __pyx_v_y; __pyx_t_32 = 0; __pyx_t_37 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_34 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_33 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_32 * __pyx_v_rgb_array_.strides[2]) )));
+119: rgb_array_[w-1, y, 1], rgb_array_[w-1, y, 2]
__pyx_t_32 = (__pyx_v_w - 1); __pyx_t_33 = __pyx_v_y; __pyx_t_34 = 1; __pyx_t_36 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_32 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_33 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_34 * __pyx_v_rgb_array_.strides[2]) ))); __pyx_t_34 = (__pyx_v_w - 1); __pyx_t_33 = __pyx_v_y; __pyx_t_32 = 2; __pyx_t_35 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_34 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_33 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_32 * __pyx_v_rgb_array_.strides[2]) ))); __pyx_v_red = __pyx_t_37; __pyx_v_green = __pyx_t_36; __pyx_v_blue = __pyx_t_35;
120: else:
+121: red, green, blue = rgb_array_[xx, y, 0],\
/*else*/ { __pyx_t_32 = __pyx_v_xx; __pyx_t_33 = __pyx_v_y; __pyx_t_34 = 0; __pyx_t_35 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_32 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_33 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_34 * __pyx_v_rgb_array_.strides[2]) )));
+122: rgb_array_[xx, y, 1], rgb_array_[xx, y, 2]
__pyx_t_34 = __pyx_v_xx; __pyx_t_33 = __pyx_v_y; __pyx_t_32 = 1; __pyx_t_36 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_34 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_33 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_32 * __pyx_v_rgb_array_.strides[2]) ))); __pyx_t_32 = __pyx_v_xx; __pyx_t_33 = __pyx_v_y; __pyx_t_34 = 2; __pyx_t_37 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_32 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_33 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_34 * __pyx_v_rgb_array_.strides[2]) ))); __pyx_v_red = __pyx_t_35; __pyx_v_green = __pyx_t_36; __pyx_v_blue = __pyx_t_37; } __pyx_L33:;
123:
+124: r = r + red * k
__pyx_v_r = (__pyx_v_r + (__pyx_v_red * __pyx_v_k));
+125: g = g + green * k
__pyx_v_g = (__pyx_v_g + (__pyx_v_green * __pyx_v_k));
+126: b = b + blue * k
__pyx_v_b = (__pyx_v_b + (__pyx_v_blue * __pyx_v_k)); }
127:
+128: convolve[x, y, 0], convolve[x, y, 1], convolve[x, y, 2] = <unsigned char>r,\
__pyx_t_37 = ((unsigned char)__pyx_v_r); /* … */ __pyx_t_34 = __pyx_v_x; __pyx_t_33 = __pyx_v_y; __pyx_t_32 = 0; *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_34 * __pyx_v_convolve.strides[0]) ) + __pyx_t_33 * __pyx_v_convolve.strides[1]) )) + __pyx_t_32)) )) = __pyx_t_37; __pyx_t_32 = __pyx_v_x; __pyx_t_33 = __pyx_v_y; __pyx_t_34 = 1; *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_32 * __pyx_v_convolve.strides[0]) ) + __pyx_t_33 * __pyx_v_convolve.strides[1]) )) + __pyx_t_34)) )) = __pyx_t_36; __pyx_t_34 = __pyx_v_x; __pyx_t_33 = __pyx_v_y; __pyx_t_32 = 2; *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_34 * __pyx_v_convolve.strides[0]) ) + __pyx_t_33 * __pyx_v_convolve.strides[1]) )) + __pyx_t_32)) )) = __pyx_t_35; } } } } } } #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) #undef likely #undef unlikely #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #endif
+129: <unsigned char>g, <unsigned char>b
__pyx_t_36 = ((unsigned char)__pyx_v_g); __pyx_t_35 = ((unsigned char)__pyx_v_b);
130:
131: # Vertical convolution
+132: for x in prange(0, w, schedule=SCHEDULE, num_threads=THREAD_NUMBER):
__pyx_t_11 = __pyx_v_w; if ((1 == 0)) abort(); { #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) #undef likely #undef unlikely #define likely(x) (x) #define unlikely(x) (x) #endif __pyx_t_22 = (__pyx_t_11 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_22 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_blue) lastprivate(__pyx_v_g) lastprivate(__pyx_v_green) lastprivate(__pyx_v_k) lastprivate(__pyx_v_kernel_offset) lastprivate(__pyx_v_r) lastprivate(__pyx_v_red) firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) lastprivate(__pyx_v_y) lastprivate(__pyx_v_yy) schedule(static) num_threads(8) #endif /* _OPENMP */ for (__pyx_t_23 = 0; __pyx_t_23 < __pyx_t_22; __pyx_t_23++){ { __pyx_v_x = (int)(0 + 1 * __pyx_t_23); /* Initialize private variables to invalid values */ __pyx_v_b = ((float)__PYX_NAN()); __pyx_v_blue = ((unsigned char)'?'); __pyx_v_g = ((float)__PYX_NAN()); __pyx_v_green = ((unsigned char)'?'); __pyx_v_k = ((float)__PYX_NAN()); __pyx_v_kernel_offset = ((char)'?'); __pyx_v_r = ((float)__PYX_NAN()); __pyx_v_red = ((unsigned char)'?'); __pyx_v_y = ((int)0xbad0bad0); __pyx_v_yy = ((int)0xbad0bad0);
133:
+134: for y in range(0, h):
__pyx_t_12 = __pyx_v_h; __pyx_t_10 = __pyx_t_12; for (__pyx_t_24 = 0; __pyx_t_24 < __pyx_t_10; __pyx_t_24+=1) { __pyx_v_y = __pyx_t_24;
+135: r, g, b = 0, 0, 0
__pyx_t_27 = 0.0; __pyx_t_26 = 0.0; __pyx_t_25 = 0.0; __pyx_v_r = __pyx_t_27; __pyx_v_g = __pyx_t_26; __pyx_v_b = __pyx_t_25;
136:
+137: for kernel_offset in range(-kernel_half, kernel_half + 1):
__pyx_t_28 = (__pyx_v_kernel_half + 1); __pyx_t_29 = __pyx_t_28; for (__pyx_t_30 = (-__pyx_v_kernel_half); __pyx_t_30 < __pyx_t_29; __pyx_t_30+=1) { __pyx_v_kernel_offset = __pyx_t_30;
138:
+139: k = kernel[kernel_offset + kernel_half]
__pyx_v_k = (__pyx_v_kernel[(__pyx_v_kernel_offset + __pyx_v_kernel_half)]);
+140: yy = y + kernel_offset
__pyx_v_yy = (__pyx_v_y + __pyx_v_kernel_offset);
141:
+142: if yy < 0:
__pyx_t_31 = ((__pyx_v_yy < 0) != 0); if (__pyx_t_31) { /* … */ goto __pyx_L44; }
+143: red, green, blue = convolve[x, 0, 0],\
__pyx_t_32 = __pyx_v_x; __pyx_t_33 = 0; __pyx_t_34 = 0; __pyx_t_35 = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_32 * __pyx_v_convolve.strides[0]) ) + __pyx_t_33 * __pyx_v_convolve.strides[1]) )) + __pyx_t_34)) )));
+144: convolve[x, 0, 1], convolve[x, 0, 2]
__pyx_t_34 = __pyx_v_x; __pyx_t_33 = 0; __pyx_t_32 = 1; __pyx_t_36 = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_34 * __pyx_v_convolve.strides[0]) ) + __pyx_t_33 * __pyx_v_convolve.strides[1]) )) + __pyx_t_32)) ))); __pyx_t_32 = __pyx_v_x; __pyx_t_33 = 0; __pyx_t_34 = 2; __pyx_t_37 = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_32 * __pyx_v_convolve.strides[0]) ) + __pyx_t_33 * __pyx_v_convolve.strides[1]) )) + __pyx_t_34)) ))); __pyx_v_red = __pyx_t_35; __pyx_v_green = __pyx_t_36; __pyx_v_blue = __pyx_t_37;
+145: elif yy > (h -1):
__pyx_t_31 = ((__pyx_v_yy > (__pyx_v_h - 1)) != 0); if (__pyx_t_31) { /* … */ goto __pyx_L44; }
+146: red, green, blue = convolve[x, h-1, 0],\
__pyx_t_34 = __pyx_v_x; __pyx_t_33 = (__pyx_v_h - 1); __pyx_t_32 = 0; __pyx_t_37 = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_34 * __pyx_v_convolve.strides[0]) ) + __pyx_t_33 * __pyx_v_convolve.strides[1]) )) + __pyx_t_32)) )));
+147: convolve[x, h-1, 1], convolve[x, h-1, 2]
__pyx_t_32 = __pyx_v_x; __pyx_t_33 = (__pyx_v_h - 1); __pyx_t_34 = 1; __pyx_t_36 = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_32 * __pyx_v_convolve.strides[0]) ) + __pyx_t_33 * __pyx_v_convolve.strides[1]) )) + __pyx_t_34)) ))); __pyx_t_34 = __pyx_v_x; __pyx_t_33 = (__pyx_v_h - 1); __pyx_t_32 = 2; __pyx_t_35 = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_34 * __pyx_v_convolve.strides[0]) ) + __pyx_t_33 * __pyx_v_convolve.strides[1]) )) + __pyx_t_32)) ))); __pyx_v_red = __pyx_t_37; __pyx_v_green = __pyx_t_36; __pyx_v_blue = __pyx_t_35;
148: else:
+149: red, green, blue = convolve[x, yy, 0],\
/*else*/ { __pyx_t_32 = __pyx_v_x; __pyx_t_33 = __pyx_v_yy; __pyx_t_34 = 0; __pyx_t_35 = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_32 * __pyx_v_convolve.strides[0]) ) + __pyx_t_33 * __pyx_v_convolve.strides[1]) )) + __pyx_t_34)) )));
+150: convolve[x, yy, 1], convolve[x, yy, 2]
__pyx_t_34 = __pyx_v_x; __pyx_t_33 = __pyx_v_yy; __pyx_t_32 = 1; __pyx_t_36 = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_34 * __pyx_v_convolve.strides[0]) ) + __pyx_t_33 * __pyx_v_convolve.strides[1]) )) + __pyx_t_32)) ))); __pyx_t_32 = __pyx_v_x; __pyx_t_33 = __pyx_v_yy; __pyx_t_34 = 2; __pyx_t_37 = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_32 * __pyx_v_convolve.strides[0]) ) + __pyx_t_33 * __pyx_v_convolve.strides[1]) )) + __pyx_t_34)) ))); __pyx_v_red = __pyx_t_35; __pyx_v_green = __pyx_t_36; __pyx_v_blue = __pyx_t_37; } __pyx_L44:;
151:
+152: r = r + red * k
__pyx_v_r = (__pyx_v_r + (__pyx_v_red * __pyx_v_k));
+153: g = g + green * k
__pyx_v_g = (__pyx_v_g + (__pyx_v_green * __pyx_v_k));
+154: b = b + blue * k
__pyx_v_b = (__pyx_v_b + (__pyx_v_blue * __pyx_v_k)); }
155:
+156: rgb_array_[x, y, 0], rgb_array_[x, y, 1], rgb_array_[x, y, 2] = \
__pyx_t_34 = __pyx_v_x; __pyx_t_33 = __pyx_v_y; __pyx_t_32 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_34 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_33 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_32 * __pyx_v_rgb_array_.strides[2]) )) = __pyx_t_37; __pyx_t_32 = __pyx_v_x; __pyx_t_33 = __pyx_v_y; __pyx_t_34 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_32 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_33 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_34 * __pyx_v_rgb_array_.strides[2]) )) = __pyx_t_36; __pyx_t_34 = __pyx_v_x; __pyx_t_33 = __pyx_v_y; __pyx_t_32 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_34 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_33 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_32 * __pyx_v_rgb_array_.strides[2]) )) = __pyx_t_35; } } } } } } #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) #undef likely #undef unlikely #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #endif }
+157: <unsigned char>r, <unsigned char>g, <unsigned char>b
__pyx_t_37 = ((unsigned char)__pyx_v_r); __pyx_t_36 = ((unsigned char)__pyx_v_g); __pyx_t_35 = ((unsigned char)__pyx_v_b);
158:
159:
160: @cython.boundscheck(False)
161: @cython.wraparound(False)
162: @cython.nonecheck(False)
163: @cython.cdivision(True)
164: @cython.profile(False)
+165: cdef blur5x5_surface24_inplace_c(surface_):
static PyObject *__pyx_f_12PygameShader_15gaussianBlur5x5_blur5x5_surface24_inplace_c(PyObject *__pyx_v_surface_) { __Pyx_memviewslice __pyx_v_rgb_array_ = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_v_w; int __pyx_v_h; CYTHON_UNUSED int __pyx_v_dim; CYTHON_UNUSED PyObject *__pyx_v_e = NULL; float __pyx_v_kernel[5]; short __pyx_v_kernel_half; __Pyx_memviewslice __pyx_v_convolve = { 0, 0, { 0 }, { 0 }, { 0 } }; CYTHON_UNUSED __Pyx_memviewslice __pyx_v_convolved = { 0, 0, { 0 }, { 0 }, { 0 } }; CYTHON_UNUSED short __pyx_v_kernel_length; int __pyx_v_x; int __pyx_v_y; int __pyx_v_xx; int __pyx_v_yy; float __pyx_v_k; float __pyx_v_r; float __pyx_v_g; float __pyx_v_b; char __pyx_v_kernel_offset; unsigned char __pyx_v_red; unsigned char __pyx_v_green; unsigned char __pyx_v_blue; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("blur5x5_surface24_inplace_c", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __PYX_XDEC_MEMVIEW(&__pyx_t_23, 1); __Pyx_AddTraceback("PygameShader.gaussianBlur5x5.blur5x5_surface24_inplace_c", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_rgb_array_, 1); __Pyx_XDECREF(__pyx_v_e); __PYX_XDEC_MEMVIEW(&__pyx_v_convolve, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_convolved, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
166: """
167: # Gaussian kernel 5x5
168: # |1 4 6 4 1|
169: # |4 16 24 16 4|
170: # |6 24 36 24 6| x 1/256
171: # |4 16 24 16 4|
172: # |1 4 6 4 1|
173: This method is using convolution property and process the image in two passes,
174: first the horizontal convolution and last the vertical convolution
175: pixels convoluted outside image edges will be set to adjacent edge value
176:
177: :param surface_: numpy.ndarray type (w, h, 3) uint8
178: :return: Return 24-bit a numpy.ndarray type (w, h, 3) uint8
179: """
180: cdef unsigned char [:, :, :] rgb_array_
+181: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L8_try_end; __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1); /* … */ __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L1_error; __pyx_L8_try_end:; }
+182: rgb_array_ = pixels3d(surface_)
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 182, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); } } __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 182, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_4, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 182, __pyx_L3_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_rgb_array_ = __pyx_t_7; __pyx_t_7.memview = NULL; __pyx_t_7.data = NULL;
+183: except:
/*except:*/ { __Pyx_AddTraceback("PygameShader.gaussianBlur5x5.blur5x5_surface24_inplace_c", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6) < 0) __PYX_ERR(0, 183, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_t_5); __Pyx_GOTREF(__pyx_t_6);
+184: raise ValueError(
__pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 184, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_Raise(__pyx_t_8, 0, 0, 0); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __PYX_ERR(0, 184, __pyx_L5_except_error) } __pyx_L5_except_error:;
+185: 'Invalid pygame surface, compatible with 24bit only got %s ' % surface_.get_bitsize())
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_bitsize); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 185, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); } } __pyx_t_8 = (__pyx_t_10) ? __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_10) : __Pyx_PyObject_CallNoArg(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 185, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_Invalid_pygame_surface_compatibl, __pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 185, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
186:
187: cdef int w, h, dim
+188: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L16_try_end; __pyx_L11_error:; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_1); __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_2, __pyx_t_1); goto __pyx_L1_error; __pyx_L16_try_end:; }
+189: w, h, dim = (<object>rgb_array_).shape[:3]
__pyx_t_6 = __pyx_memoryview_fromslice(__pyx_v_rgb_array_, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 189, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 189, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_GetSlice(__pyx_t_5, 0, 3, NULL, NULL, &__pyx_slice_, 0, 1, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 189, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) { PyObject* sequence = __pyx_t_6; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 3)) { if (size > 3) __Pyx_RaiseTooManyValuesError(3); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 189, __pyx_L11_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); __pyx_t_8 = PyTuple_GET_ITEM(sequence, 2); } else { __pyx_t_5 = PyList_GET_ITEM(sequence, 0); __pyx_t_4 = PyList_GET_ITEM(sequence, 1); __pyx_t_8 = PyList_GET_ITEM(sequence, 2); } __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(__pyx_t_8); #else __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 189, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 189, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_8 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 189, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_8); #endif __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else { Py_ssize_t index = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 189, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_11 = Py_TYPE(__pyx_t_9)->tp_iternext; index = 0; __pyx_t_5 = __pyx_t_11(__pyx_t_9); if (unlikely(!__pyx_t_5)) goto __pyx_L17_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); index = 1; __pyx_t_4 = __pyx_t_11(__pyx_t_9); if (unlikely(!__pyx_t_4)) goto __pyx_L17_unpacking_failed; __Pyx_GOTREF(__pyx_t_4); index = 2; __pyx_t_8 = __pyx_t_11(__pyx_t_9); if (unlikely(!__pyx_t_8)) goto __pyx_L17_unpacking_failed; __Pyx_GOTREF(__pyx_t_8); if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_9), 3) < 0) __PYX_ERR(0, 189, __pyx_L11_error) __pyx_t_11 = NULL; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L18_unpacking_done; __pyx_L17_unpacking_failed:; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_11 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 189, __pyx_L11_error) __pyx_L18_unpacking_done:; } __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 189, __pyx_L11_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_13 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 189, __pyx_L11_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_14 = __Pyx_PyInt_As_int(__pyx_t_8); if (unlikely((__pyx_t_14 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 189, __pyx_L11_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_v_w = __pyx_t_12; __pyx_v_h = __pyx_t_13; __pyx_v_dim = __pyx_t_14;
190:
+191: except Exception as e:
__pyx_t_14 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_14) { __Pyx_AddTraceback("PygameShader.gaussianBlur5x5.blur5x5_surface24_inplace_c", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_8, &__pyx_t_4) < 0) __PYX_ERR(0, 191, __pyx_L13_except_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_8); __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_t_8); __pyx_v_e = __pyx_t_8; /*try:*/ { /* … */ /*finally:*/ { __pyx_L24_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18) < 0)) __Pyx_ErrFetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_21); __pyx_t_14 = __pyx_lineno; __pyx_t_13 = __pyx_clineno; __pyx_t_15 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = NULL; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_20, __pyx_t_21); } __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_ErrRestore(__pyx_t_16, __pyx_t_17, __pyx_t_18); __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_lineno = __pyx_t_14; __pyx_clineno = __pyx_t_13; __pyx_filename = __pyx_t_15; goto __pyx_L13_except_error; } } } goto __pyx_L13_except_error; __pyx_L13_except_error:;
+192: raise ValueError('\nArray shape not understood.')
__pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 192, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __PYX_ERR(0, 192, __pyx_L24_error) }
193:
194: # kernel 5x5 separable
195: cdef:
+196: float[5] kernel = [1.0/16.0, 4.0/16.0, 6.0/16.0, 4.0/16.0, 1.0/16.0]
__pyx_t_22[0] = (1.0 / 16.0); __pyx_t_22[1] = (4.0 / 16.0); __pyx_t_22[2] = (6.0 / 16.0); __pyx_t_22[3] = (4.0 / 16.0); __pyx_t_22[4] = (1.0 / 16.0); memcpy(&(__pyx_v_kernel[0]), __pyx_t_22, sizeof(__pyx_v_kernel[0]) * (5));
+197: short int kernel_half = <short int>2
__pyx_v_kernel_half = ((short)2);
+198: unsigned char [:, :, ::1] convolve = numpy.empty((w, h, 3), dtype=uint8)
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_w); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_h); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_6); __Pyx_INCREF(__pyx_int_3); __Pyx_GIVEREF(__pyx_int_3); PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_int_3); __pyx_t_4 = 0; __pyx_t_6 = 0; __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_uint8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(0, 198, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_23 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_unsigned_char(__pyx_t_4, PyBUF_WRITABLE); if (unlikely(!__pyx_t_23.memview)) __PYX_ERR(0, 198, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_convolve = __pyx_t_23; __pyx_t_23.memview = NULL; __pyx_t_23.data = NULL;
+199: unsigned char [:, :, ::1] convolved = numpy.empty((w, h, 3), dtype=uint8)
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_w); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_h); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_6); __Pyx_INCREF(__pyx_int_3); __Pyx_GIVEREF(__pyx_int_3); PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_int_3); __pyx_t_4 = 0; __pyx_t_6 = 0; __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_uint8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_23 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_unsigned_char(__pyx_t_4, PyBUF_WRITABLE); if (unlikely(!__pyx_t_23.memview)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_convolved = __pyx_t_23; __pyx_t_23.memview = NULL; __pyx_t_23.data = NULL;
+200: short int kernel_length = <short int>len(kernel)
__pyx_t_4 = __Pyx_carray_to_py_float(__pyx_v_kernel, 5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 200, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_24 = PyObject_Length(__pyx_t_4); if (unlikely(__pyx_t_24 == ((Py_ssize_t)-1))) __PYX_ERR(0, 200, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_kernel_length = ((short)__pyx_t_24);
201: int x, y, xx, yy
202: float k, r, g, b, s
203: char kernel_offset
204: unsigned char red, green, blue
205:
+206: with nogil:
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L32; } __pyx_L32:; } }
207: # horizontal convolution
+208: for y in prange(0, h, schedule=SCHEDULE, num_threads=THREAD_NUMBER): # range [0..h-1)
__pyx_t_13 = __pyx_v_h; if ((1 == 0)) abort(); { #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) #undef likely #undef unlikely #define likely(x) (x) #define unlikely(x) (x) #endif __pyx_t_26 = (__pyx_t_13 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_26 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_blue) lastprivate(__pyx_v_g) lastprivate(__pyx_v_green) lastprivate(__pyx_v_k) lastprivate(__pyx_v_kernel_offset) lastprivate(__pyx_v_r) lastprivate(__pyx_v_red) lastprivate(__pyx_v_x) lastprivate(__pyx_v_xx) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) schedule(static) num_threads(8) #endif /* _OPENMP */ for (__pyx_t_25 = 0; __pyx_t_25 < __pyx_t_26; __pyx_t_25++){ { __pyx_v_y = (int)(0 + 1 * __pyx_t_25); /* Initialize private variables to invalid values */ __pyx_v_b = ((float)__PYX_NAN()); __pyx_v_blue = ((unsigned char)'?'); __pyx_v_g = ((float)__PYX_NAN()); __pyx_v_green = ((unsigned char)'?'); __pyx_v_k = ((float)__PYX_NAN()); __pyx_v_kernel_offset = ((char)'?'); __pyx_v_r = ((float)__PYX_NAN()); __pyx_v_red = ((unsigned char)'?'); __pyx_v_x = ((int)0xbad0bad0); __pyx_v_xx = ((int)0xbad0bad0);
209:
+210: for x in range(0, w): # range [0..w-1]
__pyx_t_14 = __pyx_v_w; __pyx_t_12 = __pyx_t_14; for (__pyx_t_27 = 0; __pyx_t_27 < __pyx_t_12; __pyx_t_27+=1) { __pyx_v_x = __pyx_t_27;
211:
+212: r, g, b = 0, 0, 0
__pyx_t_28 = 0.0; __pyx_t_29 = 0.0; __pyx_t_30 = 0.0; __pyx_v_r = __pyx_t_28; __pyx_v_g = __pyx_t_29; __pyx_v_b = __pyx_t_30;
213:
+214: for kernel_offset in range(-kernel_half, kernel_half + 1):
__pyx_t_31 = (__pyx_v_kernel_half + 1); __pyx_t_32 = __pyx_t_31; for (__pyx_t_33 = (-__pyx_v_kernel_half); __pyx_t_33 < __pyx_t_32; __pyx_t_33+=1) { __pyx_v_kernel_offset = __pyx_t_33;
215:
+216: k = kernel[kernel_offset + kernel_half]
__pyx_v_k = (__pyx_v_kernel[(__pyx_v_kernel_offset + __pyx_v_kernel_half)]);
217:
+218: xx = x + kernel_offset
__pyx_v_xx = (__pyx_v_x + __pyx_v_kernel_offset);
219:
220: # check boundaries.
221: # Fetch the edge pixel for the convolution
+222: if xx < 0:
__pyx_t_34 = ((__pyx_v_xx < 0) != 0); if (__pyx_t_34) { /* … */ goto __pyx_L41; }
+223: red, green, blue = rgb_array_[0, y, 0],\
__pyx_t_35 = 0; __pyx_t_36 = __pyx_v_y; __pyx_t_37 = 0; __pyx_t_38 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_35 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_36 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_37 * __pyx_v_rgb_array_.strides[2]) )));
+224: rgb_array_[0, y, 1], rgb_array_[0, y, 2]
__pyx_t_37 = 0; __pyx_t_36 = __pyx_v_y; __pyx_t_35 = 1; __pyx_t_39 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_37 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_36 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_35 * __pyx_v_rgb_array_.strides[2]) ))); __pyx_t_35 = 0; __pyx_t_36 = __pyx_v_y; __pyx_t_37 = 2; __pyx_t_40 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_35 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_36 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_37 * __pyx_v_rgb_array_.strides[2]) ))); __pyx_v_red = __pyx_t_38; __pyx_v_green = __pyx_t_39; __pyx_v_blue = __pyx_t_40;
+225: elif xx > (w - 1):
__pyx_t_34 = ((__pyx_v_xx > (__pyx_v_w - 1)) != 0); if (__pyx_t_34) { /* … */ goto __pyx_L41; }
+226: red, green, blue = rgb_array_[w-1, y, 0],\
__pyx_t_37 = (__pyx_v_w - 1); __pyx_t_36 = __pyx_v_y; __pyx_t_35 = 0; __pyx_t_40 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_37 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_36 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_35 * __pyx_v_rgb_array_.strides[2]) )));
+227: rgb_array_[w-1, y, 1], rgb_array_[w-1, y, 2]
__pyx_t_35 = (__pyx_v_w - 1); __pyx_t_36 = __pyx_v_y; __pyx_t_37 = 1; __pyx_t_39 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_35 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_36 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_37 * __pyx_v_rgb_array_.strides[2]) ))); __pyx_t_37 = (__pyx_v_w - 1); __pyx_t_36 = __pyx_v_y; __pyx_t_35 = 2; __pyx_t_38 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_37 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_36 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_35 * __pyx_v_rgb_array_.strides[2]) ))); __pyx_v_red = __pyx_t_40; __pyx_v_green = __pyx_t_39; __pyx_v_blue = __pyx_t_38;
228: else:
+229: red, green, blue = rgb_array_[xx, y, 0],\
/*else*/ { __pyx_t_35 = __pyx_v_xx; __pyx_t_36 = __pyx_v_y; __pyx_t_37 = 0; __pyx_t_38 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_35 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_36 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_37 * __pyx_v_rgb_array_.strides[2]) )));
+230: rgb_array_[xx, y, 1], rgb_array_[xx, y, 2]
__pyx_t_37 = __pyx_v_xx; __pyx_t_36 = __pyx_v_y; __pyx_t_35 = 1; __pyx_t_39 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_37 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_36 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_35 * __pyx_v_rgb_array_.strides[2]) ))); __pyx_t_35 = __pyx_v_xx; __pyx_t_36 = __pyx_v_y; __pyx_t_37 = 2; __pyx_t_40 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_35 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_36 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_37 * __pyx_v_rgb_array_.strides[2]) ))); __pyx_v_red = __pyx_t_38; __pyx_v_green = __pyx_t_39; __pyx_v_blue = __pyx_t_40; } __pyx_L41:;
231:
+232: r = r + red * k
__pyx_v_r = (__pyx_v_r + (__pyx_v_red * __pyx_v_k));
+233: g = g + green * k
__pyx_v_g = (__pyx_v_g + (__pyx_v_green * __pyx_v_k));
+234: b = b + blue * k
__pyx_v_b = (__pyx_v_b + (__pyx_v_blue * __pyx_v_k)); }
235:
+236: convolve[x, y, 0], convolve[x, y, 1], convolve[x, y, 2] = <unsigned char>r,\
__pyx_t_40 = ((unsigned char)__pyx_v_r); /* … */ __pyx_t_37 = __pyx_v_x; __pyx_t_36 = __pyx_v_y; __pyx_t_35 = 0; *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_37 * __pyx_v_convolve.strides[0]) ) + __pyx_t_36 * __pyx_v_convolve.strides[1]) )) + __pyx_t_35)) )) = __pyx_t_40; __pyx_t_35 = __pyx_v_x; __pyx_t_36 = __pyx_v_y; __pyx_t_37 = 1; *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_35 * __pyx_v_convolve.strides[0]) ) + __pyx_t_36 * __pyx_v_convolve.strides[1]) )) + __pyx_t_37)) )) = __pyx_t_39; __pyx_t_37 = __pyx_v_x; __pyx_t_36 = __pyx_v_y; __pyx_t_35 = 2; *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_37 * __pyx_v_convolve.strides[0]) ) + __pyx_t_36 * __pyx_v_convolve.strides[1]) )) + __pyx_t_35)) )) = __pyx_t_38; } } } } } } #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) #undef likely #undef unlikely #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #endif
+237: <unsigned char>g, <unsigned char>b
__pyx_t_39 = ((unsigned char)__pyx_v_g); __pyx_t_38 = ((unsigned char)__pyx_v_b);
238:
239: # Vertical convolution
+240: for x in prange(0, w, schedule=SCHEDULE, num_threads=THREAD_NUMBER):
__pyx_t_13 = __pyx_v_w; if ((1 == 0)) abort(); { #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) #undef likely #undef unlikely #define likely(x) (x) #define unlikely(x) (x) #endif __pyx_t_25 = (__pyx_t_13 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_25 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_blue) lastprivate(__pyx_v_g) lastprivate(__pyx_v_green) lastprivate(__pyx_v_k) lastprivate(__pyx_v_kernel_offset) lastprivate(__pyx_v_r) lastprivate(__pyx_v_red) firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) lastprivate(__pyx_v_y) lastprivate(__pyx_v_yy) schedule(static) num_threads(8) #endif /* _OPENMP */ for (__pyx_t_26 = 0; __pyx_t_26 < __pyx_t_25; __pyx_t_26++){ { __pyx_v_x = (int)(0 + 1 * __pyx_t_26); /* Initialize private variables to invalid values */ __pyx_v_b = ((float)__PYX_NAN()); __pyx_v_blue = ((unsigned char)'?'); __pyx_v_g = ((float)__PYX_NAN()); __pyx_v_green = ((unsigned char)'?'); __pyx_v_k = ((float)__PYX_NAN()); __pyx_v_kernel_offset = ((char)'?'); __pyx_v_r = ((float)__PYX_NAN()); __pyx_v_red = ((unsigned char)'?'); __pyx_v_y = ((int)0xbad0bad0); __pyx_v_yy = ((int)0xbad0bad0);
241:
+242: for y in range(0, h):
__pyx_t_14 = __pyx_v_h; __pyx_t_12 = __pyx_t_14; for (__pyx_t_27 = 0; __pyx_t_27 < __pyx_t_12; __pyx_t_27+=1) { __pyx_v_y = __pyx_t_27;
+243: r, g, b = 0, 0, 0
__pyx_t_30 = 0.0; __pyx_t_29 = 0.0; __pyx_t_28 = 0.0; __pyx_v_r = __pyx_t_30; __pyx_v_g = __pyx_t_29; __pyx_v_b = __pyx_t_28;
244:
+245: for kernel_offset in range(-kernel_half, kernel_half + 1):
__pyx_t_31 = (__pyx_v_kernel_half + 1); __pyx_t_32 = __pyx_t_31; for (__pyx_t_33 = (-__pyx_v_kernel_half); __pyx_t_33 < __pyx_t_32; __pyx_t_33+=1) { __pyx_v_kernel_offset = __pyx_t_33;
246:
+247: k = kernel[kernel_offset + kernel_half]
__pyx_v_k = (__pyx_v_kernel[(__pyx_v_kernel_offset + __pyx_v_kernel_half)]);
+248: yy = y + kernel_offset
__pyx_v_yy = (__pyx_v_y + __pyx_v_kernel_offset);
249:
+250: if yy < 0:
__pyx_t_34 = ((__pyx_v_yy < 0) != 0); if (__pyx_t_34) { /* … */ goto __pyx_L52; }
+251: red, green, blue = convolve[x, 0, 0],\
__pyx_t_35 = __pyx_v_x; __pyx_t_36 = 0; __pyx_t_37 = 0; __pyx_t_38 = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_35 * __pyx_v_convolve.strides[0]) ) + __pyx_t_36 * __pyx_v_convolve.strides[1]) )) + __pyx_t_37)) )));
+252: convolve[x, 0, 1], convolve[x, 0, 2]
__pyx_t_37 = __pyx_v_x; __pyx_t_36 = 0; __pyx_t_35 = 1; __pyx_t_39 = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_37 * __pyx_v_convolve.strides[0]) ) + __pyx_t_36 * __pyx_v_convolve.strides[1]) )) + __pyx_t_35)) ))); __pyx_t_35 = __pyx_v_x; __pyx_t_36 = 0; __pyx_t_37 = 2; __pyx_t_40 = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_35 * __pyx_v_convolve.strides[0]) ) + __pyx_t_36 * __pyx_v_convolve.strides[1]) )) + __pyx_t_37)) ))); __pyx_v_red = __pyx_t_38; __pyx_v_green = __pyx_t_39; __pyx_v_blue = __pyx_t_40;
+253: elif yy > (h -1):
__pyx_t_34 = ((__pyx_v_yy > (__pyx_v_h - 1)) != 0); if (__pyx_t_34) { /* … */ goto __pyx_L52; }
+254: red, green, blue = convolve[x, h-1, 0],\
__pyx_t_37 = __pyx_v_x; __pyx_t_36 = (__pyx_v_h - 1); __pyx_t_35 = 0; __pyx_t_40 = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_37 * __pyx_v_convolve.strides[0]) ) + __pyx_t_36 * __pyx_v_convolve.strides[1]) )) + __pyx_t_35)) )));
+255: convolve[x, h-1, 1], convolve[x, h-1, 2]
__pyx_t_35 = __pyx_v_x; __pyx_t_36 = (__pyx_v_h - 1); __pyx_t_37 = 1; __pyx_t_39 = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_35 * __pyx_v_convolve.strides[0]) ) + __pyx_t_36 * __pyx_v_convolve.strides[1]) )) + __pyx_t_37)) ))); __pyx_t_37 = __pyx_v_x; __pyx_t_36 = (__pyx_v_h - 1); __pyx_t_35 = 2; __pyx_t_38 = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_37 * __pyx_v_convolve.strides[0]) ) + __pyx_t_36 * __pyx_v_convolve.strides[1]) )) + __pyx_t_35)) ))); __pyx_v_red = __pyx_t_40; __pyx_v_green = __pyx_t_39; __pyx_v_blue = __pyx_t_38;
256: else:
+257: red, green, blue = convolve[x, yy, 0],\
/*else*/ { __pyx_t_35 = __pyx_v_x; __pyx_t_36 = __pyx_v_yy; __pyx_t_37 = 0; __pyx_t_38 = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_35 * __pyx_v_convolve.strides[0]) ) + __pyx_t_36 * __pyx_v_convolve.strides[1]) )) + __pyx_t_37)) )));
+258: convolve[x, yy, 1], convolve[x, yy, 2]
__pyx_t_37 = __pyx_v_x; __pyx_t_36 = __pyx_v_yy; __pyx_t_35 = 1; __pyx_t_39 = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_37 * __pyx_v_convolve.strides[0]) ) + __pyx_t_36 * __pyx_v_convolve.strides[1]) )) + __pyx_t_35)) ))); __pyx_t_35 = __pyx_v_x; __pyx_t_36 = __pyx_v_yy; __pyx_t_37 = 2; __pyx_t_40 = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_35 * __pyx_v_convolve.strides[0]) ) + __pyx_t_36 * __pyx_v_convolve.strides[1]) )) + __pyx_t_37)) ))); __pyx_v_red = __pyx_t_38; __pyx_v_green = __pyx_t_39; __pyx_v_blue = __pyx_t_40; } __pyx_L52:;
259:
+260: r = r + red * k
__pyx_v_r = (__pyx_v_r + (__pyx_v_red * __pyx_v_k));
+261: g = g + green * k
__pyx_v_g = (__pyx_v_g + (__pyx_v_green * __pyx_v_k));
+262: b = b + blue * k
__pyx_v_b = (__pyx_v_b + (__pyx_v_blue * __pyx_v_k)); }
263:
+264: rgb_array_[x, y, 0], rgb_array_[x, y, 1], rgb_array_[x, y, 2] = \
__pyx_t_37 = __pyx_v_x; __pyx_t_36 = __pyx_v_y; __pyx_t_35 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_37 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_36 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_35 * __pyx_v_rgb_array_.strides[2]) )) = __pyx_t_40; __pyx_t_35 = __pyx_v_x; __pyx_t_36 = __pyx_v_y; __pyx_t_37 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_35 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_36 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_37 * __pyx_v_rgb_array_.strides[2]) )) = __pyx_t_39; __pyx_t_37 = __pyx_v_x; __pyx_t_36 = __pyx_v_y; __pyx_t_35 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_37 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_36 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_35 * __pyx_v_rgb_array_.strides[2]) )) = __pyx_t_38; } } } } } } #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) #undef likely #undef unlikely #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #endif }
+265: <unsigned char>r, <unsigned char>g, <unsigned char>b
__pyx_t_40 = ((unsigned char)__pyx_v_r); __pyx_t_39 = ((unsigned char)__pyx_v_g); __pyx_t_38 = ((unsigned char)__pyx_v_b);
266:
267: @cython.boundscheck(False)
268: @cython.wraparound(False)
269: @cython.nonecheck(False)
270: @cython.cdivision(True)
271: @cython.profile(False)
+272: cpdef canny_blur5x5_surface24_c(surface_):
static PyObject *__pyx_pw_12PygameShader_15gaussianBlur5x5_3canny_blur5x5_surface24_c(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static PyObject *__pyx_f_12PygameShader_15gaussianBlur5x5_canny_blur5x5_surface24_c(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_v_kernel = NULL; int __pyx_v_w; int __pyx_v_h; PyObject *__pyx_v_rgb_array_ = NULL; CYTHON_UNUSED float __pyx_v_kernel_weight; __Pyx_memviewslice __pyx_v_canny_kernel = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_rgb_array = { 0, 0, { 0 }, { 0 }, { 0 } }; short __pyx_v_kernel_half; __Pyx_memviewslice __pyx_v_output_array = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_v_x; int __pyx_v_y; int __pyx_v_xx; int __pyx_v_yy; unsigned short __pyx_v_red; unsigned short __pyx_v_green; unsigned short __pyx_v_blue; short __pyx_v_kernel_offset_y; short __pyx_v_kernel_offset_x; float __pyx_v_r; float __pyx_v_g; float __pyx_v_b; float __pyx_v_k; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("canny_blur5x5_surface24_c", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __PYX_XDEC_MEMVIEW(&__pyx_t_20, 1); __PYX_XDEC_MEMVIEW(&__pyx_t_21, 1); __PYX_XDEC_MEMVIEW(&__pyx_t_22, 1); __Pyx_AddTraceback("PygameShader.gaussianBlur5x5.canny_blur5x5_surface24_c", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_kernel); __Pyx_XDECREF(__pyx_v_rgb_array_); __PYX_XDEC_MEMVIEW(&__pyx_v_canny_kernel, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_rgb_array, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_output_array, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_12PygameShader_15gaussianBlur5x5_3canny_blur5x5_surface24_c(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static char __pyx_doc_12PygameShader_15gaussianBlur5x5_2canny_blur5x5_surface24_c[] = "\n # Gaussian kernel 5x5\n # |2 4 5 4 2|\n # |4 9 12 9 4|\n # |5 12 15 12 5| x 1/159\n # |4 9 12 9 4|\n # |2 4 5 4 2|\n pixels convoluted outside image edges will be set to adjacent edge value\n\n :param surface_: Surface, 8, 24-32 bit format\n :return: return a numpy.ndarray (w, h, 3) uint8 with RGB values\n "; static PyObject *__pyx_pw_12PygameShader_15gaussianBlur5x5_3canny_blur5x5_surface24_c(PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("canny_blur5x5_surface24_c (wrapper)", 0); __pyx_r = __pyx_pf_12PygameShader_15gaussianBlur5x5_2canny_blur5x5_surface24_c(__pyx_self, ((PyObject *)__pyx_v_surface_)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_12PygameShader_15gaussianBlur5x5_2canny_blur5x5_surface24_c(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("canny_blur5x5_surface24_c", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_12PygameShader_15gaussianBlur5x5_canny_blur5x5_surface24_c(__pyx_v_surface_, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 272, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("PygameShader.gaussianBlur5x5.canny_blur5x5_surface24_c", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
273: """
274: # Gaussian kernel 5x5
275: # |2 4 5 4 2|
276: # |4 9 12 9 4|
277: # |5 12 15 12 5| x 1/159
278: # |4 9 12 9 4|
279: # |2 4 5 4 2|
280: pixels convoluted outside image edges will be set to adjacent edge value
281:
282: :param surface_: Surface, 8, 24-32 bit format
283: :return: return a numpy.ndarray (w, h, 3) uint8 with RGB values
284: """
285:
+286: assert isinstance(surface_, Surface),\
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_1); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!(__pyx_t_2 != 0))) {
+287: 'Argument image must be a valid Surface, got %s ' % type(surface_)
__pyx_t_1 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_Argument_image_must_be_a_valid_S, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); PyErr_SetObject(PyExc_AssertionError, __pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 286, __pyx_L1_error) } } #endif
288:
289: # kernel definition
+290: kernel = numpy.array(([2.0, 4.0, 5.0, 4.0, 2.0],
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 290, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_array); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 290, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyList_New(5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 290, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_float_2_0); __Pyx_GIVEREF(__pyx_float_2_0); PyList_SET_ITEM(__pyx_t_3, 0, __pyx_float_2_0); __Pyx_INCREF(__pyx_float_4_0); __Pyx_GIVEREF(__pyx_float_4_0); PyList_SET_ITEM(__pyx_t_3, 1, __pyx_float_4_0); __Pyx_INCREF(__pyx_float_5_0); __Pyx_GIVEREF(__pyx_float_5_0); PyList_SET_ITEM(__pyx_t_3, 2, __pyx_float_5_0); __Pyx_INCREF(__pyx_float_4_0); __Pyx_GIVEREF(__pyx_float_4_0); PyList_SET_ITEM(__pyx_t_3, 3, __pyx_float_4_0); __Pyx_INCREF(__pyx_float_2_0); __Pyx_GIVEREF(__pyx_float_2_0); PyList_SET_ITEM(__pyx_t_3, 4, __pyx_float_2_0); /* … */ __pyx_t_9 = PyTuple_New(5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 290, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 3, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 4, __pyx_t_8); __pyx_t_3 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_8, __pyx_t_9) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_9); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 290, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+291: [4.0, 9.0, 12.0, 9.0, 4.0],
__pyx_t_5 = PyList_New(5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 291, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_float_4_0); __Pyx_GIVEREF(__pyx_float_4_0); PyList_SET_ITEM(__pyx_t_5, 0, __pyx_float_4_0); __Pyx_INCREF(__pyx_float_9_0); __Pyx_GIVEREF(__pyx_float_9_0); PyList_SET_ITEM(__pyx_t_5, 1, __pyx_float_9_0); __Pyx_INCREF(__pyx_float_12_0); __Pyx_GIVEREF(__pyx_float_12_0); PyList_SET_ITEM(__pyx_t_5, 2, __pyx_float_12_0); __Pyx_INCREF(__pyx_float_9_0); __Pyx_GIVEREF(__pyx_float_9_0); PyList_SET_ITEM(__pyx_t_5, 3, __pyx_float_9_0); __Pyx_INCREF(__pyx_float_4_0); __Pyx_GIVEREF(__pyx_float_4_0); PyList_SET_ITEM(__pyx_t_5, 4, __pyx_float_4_0);
+292: [5.0, 12.0, 15.0, 12.0, 5.0],
__pyx_t_6 = PyList_New(5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 292, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_float_5_0); __Pyx_GIVEREF(__pyx_float_5_0); PyList_SET_ITEM(__pyx_t_6, 0, __pyx_float_5_0); __Pyx_INCREF(__pyx_float_12_0); __Pyx_GIVEREF(__pyx_float_12_0); PyList_SET_ITEM(__pyx_t_6, 1, __pyx_float_12_0); __Pyx_INCREF(__pyx_float_15_0); __Pyx_GIVEREF(__pyx_float_15_0); PyList_SET_ITEM(__pyx_t_6, 2, __pyx_float_15_0); __Pyx_INCREF(__pyx_float_12_0); __Pyx_GIVEREF(__pyx_float_12_0); PyList_SET_ITEM(__pyx_t_6, 3, __pyx_float_12_0); __Pyx_INCREF(__pyx_float_5_0); __Pyx_GIVEREF(__pyx_float_5_0); PyList_SET_ITEM(__pyx_t_6, 4, __pyx_float_5_0);
+293: [4.0, 9.0, 12.0, 9.0, 4.0],
__pyx_t_7 = PyList_New(5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 293, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_float_4_0); __Pyx_GIVEREF(__pyx_float_4_0); PyList_SET_ITEM(__pyx_t_7, 0, __pyx_float_4_0); __Pyx_INCREF(__pyx_float_9_0); __Pyx_GIVEREF(__pyx_float_9_0); PyList_SET_ITEM(__pyx_t_7, 1, __pyx_float_9_0); __Pyx_INCREF(__pyx_float_12_0); __Pyx_GIVEREF(__pyx_float_12_0); PyList_SET_ITEM(__pyx_t_7, 2, __pyx_float_12_0); __Pyx_INCREF(__pyx_float_9_0); __Pyx_GIVEREF(__pyx_float_9_0); PyList_SET_ITEM(__pyx_t_7, 3, __pyx_float_9_0); __Pyx_INCREF(__pyx_float_4_0); __Pyx_GIVEREF(__pyx_float_4_0); PyList_SET_ITEM(__pyx_t_7, 4, __pyx_float_4_0);
+294: [2.0, 4.0, 5.0, 4.0, 2.0])).astype(dtype=float32, order='C')
__pyx_t_8 = PyList_New(5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 294, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_INCREF(__pyx_float_2_0); __Pyx_GIVEREF(__pyx_float_2_0); PyList_SET_ITEM(__pyx_t_8, 0, __pyx_float_2_0); __Pyx_INCREF(__pyx_float_4_0); __Pyx_GIVEREF(__pyx_float_4_0); PyList_SET_ITEM(__pyx_t_8, 1, __pyx_float_4_0); __Pyx_INCREF(__pyx_float_5_0); __Pyx_GIVEREF(__pyx_float_5_0); PyList_SET_ITEM(__pyx_t_8, 2, __pyx_float_5_0); __Pyx_INCREF(__pyx_float_4_0); __Pyx_GIVEREF(__pyx_float_4_0); PyList_SET_ITEM(__pyx_t_8, 3, __pyx_float_4_0); __Pyx_INCREF(__pyx_float_2_0); __Pyx_GIVEREF(__pyx_float_2_0); PyList_SET_ITEM(__pyx_t_8, 4, __pyx_float_2_0); /* … */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_astype); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 294, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 294, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_float32); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 294, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_9) < 0) __PYX_ERR(0, 294, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_order, __pyx_n_u_C) < 0) __PYX_ERR(0, 294, __pyx_L1_error) __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 294, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_kernel = __pyx_t_9; __pyx_t_9 = 0;
295:
296: cdef int w, h
+297: w, h = surface_.get_size()
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 297, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_9 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 297, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_9))) || (PyList_CheckExact(__pyx_t_9))) { PyObject* sequence = __pyx_t_9; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 297, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_1 = PyList_GET_ITEM(sequence, 0); __pyx_t_4 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); #else __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 297, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 297, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else { Py_ssize_t index = -1; __pyx_t_8 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 297, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_10 = Py_TYPE(__pyx_t_8)->tp_iternext; index = 0; __pyx_t_1 = __pyx_t_10(__pyx_t_8); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_1); index = 1; __pyx_t_4 = __pyx_t_10(__pyx_t_8); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_4); if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_8), 2) < 0) __PYX_ERR(0, 297, __pyx_L1_error) __pyx_t_10 = NULL; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L4_unpacking_done; __pyx_L3_unpacking_failed:; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_10 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 297, __pyx_L1_error) __pyx_L4_unpacking_done:; } __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 297, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 297, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_w = __pyx_t_11; __pyx_v_h = __pyx_t_12;
298:
+299: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; goto __pyx_L10_try_end; __pyx_L5_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15); goto __pyx_L1_error; __pyx_L10_try_end:; }
+300: rgb_array_ = pixels3d(surface_)
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 300, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } __pyx_t_9 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_1, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 300, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_rgb_array_ = __pyx_t_9; __pyx_t_9 = 0;
+301: except (surface_.error, ValueError):
__Pyx_ErrFetch(&__pyx_t_9, &__pyx_t_4, &__pyx_t_1); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_error); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 301, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_12 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_9, __pyx_t_8) || __Pyx_PyErr_GivenExceptionMatches(__pyx_t_9, __pyx_builtin_ValueError); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_ErrRestore(__pyx_t_9, __pyx_t_4, __pyx_t_1); __pyx_t_9 = 0; __pyx_t_4 = 0; __pyx_t_1 = 0; if (__pyx_t_12) { __Pyx_AddTraceback("PygameShader.gaussianBlur5x5.canny_blur5x5_surface24_c", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_4, &__pyx_t_9) < 0) __PYX_ERR(0, 301, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_t_9);
+302: raise ValueError('\nTexture/image is not compatible.')
__pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 302, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_Raise(__pyx_t_8, 0, 0, 0); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __PYX_ERR(0, 302, __pyx_L7_except_error) } goto __pyx_L7_except_error; __pyx_L7_except_error:; /* … */ __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_u_Texture_image_is_not_compatible); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 302, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__3); __Pyx_GIVEREF(__pyx_tuple__3);
303:
+304: assert w != 0 or h !=0, 'image with incorrect dimensions (w>0, h>0) got (%s, %s) ' % (w, h)
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_16 = ((__pyx_v_w != 0) != 0); if (!__pyx_t_16) { } else { __pyx_t_2 = __pyx_t_16; goto __pyx_L13_bool_binop_done; } __pyx_t_16 = ((__pyx_v_h != 0) != 0); __pyx_t_2 = __pyx_t_16; __pyx_L13_bool_binop_done:; if (unlikely(!__pyx_t_2)) { __pyx_t_9 = PyTuple_New(5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_17 = 0; __pyx_t_18 = 127; __Pyx_INCREF(__pyx_kp_u_image_with_incorrect_dimensions); __pyx_t_17 += 48; __Pyx_GIVEREF(__pyx_kp_u_image_with_incorrect_dimensions); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_kp_u_image_with_incorrect_dimensions); __pyx_t_4 = __Pyx_PyUnicode_From_int(__pyx_v_w, 0, ' ', 'd'); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_17 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_4); __pyx_t_4 = 0; __Pyx_INCREF(__pyx_kp_u__4); __pyx_t_17 += 2; __Pyx_GIVEREF(__pyx_kp_u__4); PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_kp_u__4); __pyx_t_4 = __Pyx_PyUnicode_From_int(__pyx_v_h, 0, ' ', 'd'); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_17 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 3, __pyx_t_4); __pyx_t_4 = 0; __Pyx_INCREF(__pyx_kp_u__5); __pyx_t_17 += 2; __Pyx_GIVEREF(__pyx_kp_u__5); PyTuple_SET_ITEM(__pyx_t_9, 4, __pyx_kp_u__5); __pyx_t_4 = __Pyx_PyUnicode_Join(__pyx_t_9, 5, __pyx_t_17, __pyx_t_18); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 304, __pyx_L1_error) } } #endif
305:
306: cdef:
+307: float kernel_weight = sum(kernel)
__Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_sum); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 307, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); } } __pyx_t_4 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_1, __pyx_v_kernel) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_kernel); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 307, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_19 = __pyx_PyFloat_AsFloat(__pyx_t_4); if (unlikely((__pyx_t_19 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 307, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_kernel_weight = __pyx_t_19;
+308: float [:, :] canny_kernel = divide(kernel, 159.0, dtype=float32)
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_divide); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 308, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 308, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_v_kernel); __Pyx_GIVEREF(__pyx_v_kernel); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_kernel); __Pyx_INCREF(__pyx_float_159_0); __Pyx_GIVEREF(__pyx_float_159_0); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_float_159_0); __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 308, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_float32); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 308, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_8) < 0) __PYX_ERR(0, 308, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 308, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_20 = __Pyx_PyObject_to_MemoryviewSlice_dsds_float(__pyx_t_8, PyBUF_WRITABLE); if (unlikely(!__pyx_t_20.memview)) __PYX_ERR(0, 308, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_v_canny_kernel = __pyx_t_20; __pyx_t_20.memview = NULL; __pyx_t_20.data = NULL;
+309: unsigned char [:, :, :] rgb_array = rgb_array_
__pyx_t_21 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_v_rgb_array_, PyBUF_WRITABLE); if (unlikely(!__pyx_t_21.memview)) __PYX_ERR(0, 309, __pyx_L1_error) __pyx_v_rgb_array = __pyx_t_21; __pyx_t_21.memview = NULL; __pyx_t_21.data = NULL;
+310: short kernel_half = <short>(len(kernel) >> 1)
__pyx_t_17 = PyObject_Length(__pyx_v_kernel); if (unlikely(__pyx_t_17 == ((Py_ssize_t)-1))) __PYX_ERR(0, 310, __pyx_L1_error) __pyx_v_kernel_half = ((short)(__pyx_t_17 >> 1));
+311: float [:, :, ::1] output_array = empty((w, h, 3), order='C', dtype=float32)
__Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_empty); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 311, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_w); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 311, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_h); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 311, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 311, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_9); __Pyx_INCREF(__pyx_int_3); __Pyx_GIVEREF(__pyx_int_3); PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_int_3); __pyx_t_1 = 0; __pyx_t_9 = 0; __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 311, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 311, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_order, __pyx_n_u_C) < 0) __PYX_ERR(0, 311, __pyx_L1_error) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_float32); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 311, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_1) < 0) __PYX_ERR(0, 311, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_9, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 311, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_22 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_float(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_22.memview)) __PYX_ERR(0, 311, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_output_array = __pyx_t_22; __pyx_t_22.memview = NULL; __pyx_t_22.data = NULL;
312: int x, y, xx, yy
313: unsigned short red, green, blue,
314: short kernel_offset_y, kernel_offset_x
315: float r, g, b, k
316:
+317: with nogil:
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L17; } __pyx_L17:; } }
318:
+319: for x in prange(0, w, schedule=SCHEDULE, num_threads=THREAD_NUMBER):
__pyx_t_12 = __pyx_v_w; if ((1 == 0)) abort(); { #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) #undef likely #undef unlikely #define likely(x) (x) #define unlikely(x) (x) #endif __pyx_t_24 = (__pyx_t_12 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_24 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_blue) lastprivate(__pyx_v_g) lastprivate(__pyx_v_green) lastprivate(__pyx_v_k) lastprivate(__pyx_v_kernel_offset_x) lastprivate(__pyx_v_kernel_offset_y) lastprivate(__pyx_v_r) lastprivate(__pyx_v_red) firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) lastprivate(__pyx_v_xx) lastprivate(__pyx_v_y) lastprivate(__pyx_v_yy) schedule(static) num_threads(8) #endif /* _OPENMP */ for (__pyx_t_23 = 0; __pyx_t_23 < __pyx_t_24; __pyx_t_23++){ { __pyx_v_x = (int)(0 + 1 * __pyx_t_23); /* Initialize private variables to invalid values */ __pyx_v_b = ((float)__PYX_NAN()); __pyx_v_blue = ((unsigned short)0xbad0bad0); __pyx_v_g = ((float)__PYX_NAN()); __pyx_v_green = ((unsigned short)0xbad0bad0); __pyx_v_k = ((float)__PYX_NAN()); __pyx_v_kernel_offset_x = ((short)0xbad0bad0); __pyx_v_kernel_offset_y = ((short)0xbad0bad0); __pyx_v_r = ((float)__PYX_NAN()); __pyx_v_red = ((unsigned short)0xbad0bad0); __pyx_v_xx = ((int)0xbad0bad0); __pyx_v_y = ((int)0xbad0bad0); __pyx_v_yy = ((int)0xbad0bad0);
320:
+321: for y in range(0, h):
__pyx_t_11 = __pyx_v_h; __pyx_t_25 = __pyx_t_11; for (__pyx_t_26 = 0; __pyx_t_26 < __pyx_t_25; __pyx_t_26+=1) { __pyx_v_y = __pyx_t_26;
322:
+323: r, g, b = 0, 0, 0
__pyx_t_19 = 0.0; __pyx_t_27 = 0.0; __pyx_t_28 = 0.0; __pyx_v_r = __pyx_t_19; __pyx_v_g = __pyx_t_27; __pyx_v_b = __pyx_t_28;
324:
+325: for kernel_offset_y in range(-kernel_half, kernel_half + 1):
__pyx_t_29 = (__pyx_v_kernel_half + 1); __pyx_t_30 = __pyx_t_29; for (__pyx_t_31 = (-__pyx_v_kernel_half); __pyx_t_31 < __pyx_t_30; __pyx_t_31+=1) { __pyx_v_kernel_offset_y = __pyx_t_31;
326:
+327: for kernel_offset_x in range(-kernel_half, kernel_half + 1):
__pyx_t_32 = (__pyx_v_kernel_half + 1); __pyx_t_33 = __pyx_t_32; for (__pyx_t_34 = (-__pyx_v_kernel_half); __pyx_t_34 < __pyx_t_33; __pyx_t_34+=1) { __pyx_v_kernel_offset_x = __pyx_t_34;
328:
+329: xx = x + kernel_offset_x
__pyx_v_xx = (__pyx_v_x + __pyx_v_kernel_offset_x);
+330: yy = y + kernel_offset_y
__pyx_v_yy = (__pyx_v_y + __pyx_v_kernel_offset_y);
331:
+332: if xx < 0:
__pyx_t_2 = ((__pyx_v_xx < 0) != 0); if (__pyx_t_2) { /* … */ goto __pyx_L28; }
+333: xx = 0
__pyx_v_xx = 0;
+334: elif xx > w :
__pyx_t_2 = ((__pyx_v_xx > __pyx_v_w) != 0); if (__pyx_t_2) { /* … */ } __pyx_L28:;
+335: xx = w
__pyx_v_xx = __pyx_v_w;
336:
+337: if yy < 0:
__pyx_t_2 = ((__pyx_v_yy < 0) != 0); if (__pyx_t_2) { /* … */ goto __pyx_L29; }
+338: yy = 0
__pyx_v_yy = 0;
+339: elif yy > h :
__pyx_t_2 = ((__pyx_v_yy > __pyx_v_h) != 0); if (__pyx_t_2) { /* … */ } __pyx_L29:;
+340: yy = h
__pyx_v_yy = __pyx_v_h;
341:
+342: red = rgb_array[xx, yy, 0]
__pyx_t_35 = __pyx_v_xx; __pyx_t_36 = __pyx_v_yy; __pyx_t_37 = 0; __pyx_v_red = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_35 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_36 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_37 * __pyx_v_rgb_array.strides[2]) )));
+343: green = rgb_array[xx, yy, 1]
__pyx_t_37 = __pyx_v_xx; __pyx_t_36 = __pyx_v_yy; __pyx_t_35 = 1; __pyx_v_green = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_37 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_36 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_35 * __pyx_v_rgb_array.strides[2]) )));
+344: blue = rgb_array[xx, yy, 2]
__pyx_t_35 = __pyx_v_xx; __pyx_t_36 = __pyx_v_yy; __pyx_t_37 = 2; __pyx_v_blue = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_35 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_36 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_37 * __pyx_v_rgb_array.strides[2]) )));
345:
+346: k = canny_kernel[kernel_offset_y + kernel_half,
__pyx_t_37 = (__pyx_v_kernel_offset_y + __pyx_v_kernel_half); __pyx_t_36 = (__pyx_v_kernel_offset_x + __pyx_v_kernel_half); __pyx_v_k = (*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_canny_kernel.data + __pyx_t_37 * __pyx_v_canny_kernel.strides[0]) ) + __pyx_t_36 * __pyx_v_canny_kernel.strides[1]) )));
347: kernel_offset_x + kernel_half]
348:
+349: r += red * k
__pyx_v_r = (__pyx_v_r + (__pyx_v_red * __pyx_v_k));
+350: g += green * k
__pyx_v_g = (__pyx_v_g + (__pyx_v_green * __pyx_v_k));
+351: b += blue * k
__pyx_v_b = (__pyx_v_b + (__pyx_v_blue * __pyx_v_k)); } }
352:
+353: r = r / <float>25.0
__pyx_v_r = (__pyx_v_r / ((float)25.0));
+354: g = g / <float>25.0
__pyx_v_g = (__pyx_v_g / ((float)25.0));
+355: b = b / <float>25.0
__pyx_v_b = (__pyx_v_b / ((float)25.0));
+356: if r > 255.0:
__pyx_t_2 = ((__pyx_v_r > 255.0) != 0); if (__pyx_t_2) { /* … */ }
+357: r = <float>255.0
__pyx_v_r = ((float)255.0);
+358: if g > 255.0:
__pyx_t_2 = ((__pyx_v_g > 255.0) != 0); if (__pyx_t_2) { /* … */ }
+359: g = <float>255.0
__pyx_v_g = ((float)255.0);
+360: if b > 255.0:
__pyx_t_2 = ((__pyx_v_b > 255.0) != 0); if (__pyx_t_2) { /* … */ }
+361: b = <float>255.0
__pyx_v_b = ((float)255.0);
362:
+363: output_array[x, y, 0] = r
__pyx_t_36 = __pyx_v_x; __pyx_t_37 = __pyx_v_y; __pyx_t_35 = 0; *((float *) ( /* dim=2 */ ((char *) (((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_output_array.data + __pyx_t_36 * __pyx_v_output_array.strides[0]) ) + __pyx_t_37 * __pyx_v_output_array.strides[1]) )) + __pyx_t_35)) )) = __pyx_v_r;
+364: output_array[x, y, 1] = g
__pyx_t_35 = __pyx_v_x; __pyx_t_37 = __pyx_v_y; __pyx_t_36 = 1; *((float *) ( /* dim=2 */ ((char *) (((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_output_array.data + __pyx_t_35 * __pyx_v_output_array.strides[0]) ) + __pyx_t_37 * __pyx_v_output_array.strides[1]) )) + __pyx_t_36)) )) = __pyx_v_g;
+365: output_array[x, y, 2] = b
__pyx_t_36 = __pyx_v_x; __pyx_t_37 = __pyx_v_y; __pyx_t_35 = 2; *((float *) ( /* dim=2 */ ((char *) (((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_output_array.data + __pyx_t_36 * __pyx_v_output_array.strides[0]) ) + __pyx_t_37 * __pyx_v_output_array.strides[1]) )) + __pyx_t_35)) )) = __pyx_v_b; } } } } } } #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) #undef likely #undef unlikely #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #endif }
366:
+367: return asarray(output_array).astype(dtype=uint8)
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_asarray); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 367, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_9 = __pyx_memoryview_fromslice(__pyx_v_output_array, 3, (PyObject *(*)(char *)) __pyx_memview_get_float, (int (*)(char *, PyObject *)) __pyx_memview_set_float, 0);; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 367, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_8, __pyx_t_9) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_9); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 367, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_astype); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 367, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 367, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_uint8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 367, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_9) < 0) __PYX_ERR(0, 367, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 367, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_9; __pyx_t_9 = 0; goto __pyx_L0;
368:
369:
370: @cython.boundscheck(False)
371: @cython.wraparound(False)
372: @cython.nonecheck(False)
373: @cython.cdivision(True)
374: @cython.profile(False)
+375: cpdef canny_blur5x5_surface32_c(surface_):
static PyObject *__pyx_pw_12PygameShader_15gaussianBlur5x5_5canny_blur5x5_surface32_c(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static PyObject *__pyx_f_12PygameShader_15gaussianBlur5x5_canny_blur5x5_surface32_c(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_v_kernel = NULL; int __pyx_v_w; int __pyx_v_h; PyObject *__pyx_v_rgb_array_ = NULL; PyObject *__pyx_v_array_alpha_ = NULL; CYTHON_UNUSED float __pyx_v_kernel_weight; __Pyx_memviewslice __pyx_v_canny_kernel = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_rgb_array = { 0, 0, { 0 }, { 0 }, { 0 } }; short __pyx_v_kernel_half; __Pyx_memviewslice __pyx_v_output_array = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_alpha = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_v_x; int __pyx_v_y; int __pyx_v_xx; int __pyx_v_yy; unsigned char __pyx_v_red; unsigned char __pyx_v_green; unsigned char __pyx_v_blue; short __pyx_v_kernel_offset_y; short __pyx_v_kernel_offset_x; float __pyx_v_r; float __pyx_v_g; float __pyx_v_b; float __pyx_v_k; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("canny_blur5x5_surface32_c", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __PYX_XDEC_MEMVIEW(&__pyx_t_20, 1); __PYX_XDEC_MEMVIEW(&__pyx_t_21, 1); __PYX_XDEC_MEMVIEW(&__pyx_t_22, 1); __Pyx_AddTraceback("PygameShader.gaussianBlur5x5.canny_blur5x5_surface32_c", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_kernel); __Pyx_XDECREF(__pyx_v_rgb_array_); __Pyx_XDECREF(__pyx_v_array_alpha_); __PYX_XDEC_MEMVIEW(&__pyx_v_canny_kernel, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_rgb_array, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_output_array, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_alpha, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_12PygameShader_15gaussianBlur5x5_5canny_blur5x5_surface32_c(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static char __pyx_doc_12PygameShader_15gaussianBlur5x5_4canny_blur5x5_surface32_c[] = "\n # Gaussian kernel 5x5\n # |2 4 5 4 2|\n # |4 9 12 9 4|\n # |5 12 15 12 5| x 1/159\n # |4 9 12 9 4|\n # |2 4 5 4 2|\n pixels convoluted outside image edges will be set to adjacent edge value\n\n :param surface_: Surface, 8, 24-32 bit format\n :return: return a numpy.ndarray (w, h, 3) uint8 with RGB values\n "; static PyObject *__pyx_pw_12PygameShader_15gaussianBlur5x5_5canny_blur5x5_surface32_c(PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("canny_blur5x5_surface32_c (wrapper)", 0); __pyx_r = __pyx_pf_12PygameShader_15gaussianBlur5x5_4canny_blur5x5_surface32_c(__pyx_self, ((PyObject *)__pyx_v_surface_)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_12PygameShader_15gaussianBlur5x5_4canny_blur5x5_surface32_c(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("canny_blur5x5_surface32_c", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_12PygameShader_15gaussianBlur5x5_canny_blur5x5_surface32_c(__pyx_v_surface_, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 375, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("PygameShader.gaussianBlur5x5.canny_blur5x5_surface32_c", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
376: """
377: # Gaussian kernel 5x5
378: # |2 4 5 4 2|
379: # |4 9 12 9 4|
380: # |5 12 15 12 5| x 1/159
381: # |4 9 12 9 4|
382: # |2 4 5 4 2|
383: pixels convoluted outside image edges will be set to adjacent edge value
384:
385: :param surface_: Surface, 8, 24-32 bit format
386: :return: return a numpy.ndarray (w, h, 3) uint8 with RGB values
387: """
388:
+389: assert isinstance(surface_, Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 389, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_1); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 389, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!(__pyx_t_2 != 0))) {
+390: 'Argument image must be a valid Surface, got %s ' % type(surface_)
__pyx_t_1 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_Argument_image_must_be_a_valid_S, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 390, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); PyErr_SetObject(PyExc_AssertionError, __pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 389, __pyx_L1_error) } } #endif
391:
392: # kernel definition
+393: kernel = numpy.array(([2.0, 4.0, 5.0, 4.0, 2.0],
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_array); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyList_New(5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_float_2_0); __Pyx_GIVEREF(__pyx_float_2_0); PyList_SET_ITEM(__pyx_t_3, 0, __pyx_float_2_0); __Pyx_INCREF(__pyx_float_4_0); __Pyx_GIVEREF(__pyx_float_4_0); PyList_SET_ITEM(__pyx_t_3, 1, __pyx_float_4_0); __Pyx_INCREF(__pyx_float_5_0); __Pyx_GIVEREF(__pyx_float_5_0); PyList_SET_ITEM(__pyx_t_3, 2, __pyx_float_5_0); __Pyx_INCREF(__pyx_float_4_0); __Pyx_GIVEREF(__pyx_float_4_0); PyList_SET_ITEM(__pyx_t_3, 3, __pyx_float_4_0); __Pyx_INCREF(__pyx_float_2_0); __Pyx_GIVEREF(__pyx_float_2_0); PyList_SET_ITEM(__pyx_t_3, 4, __pyx_float_2_0); /* … */ __pyx_t_9 = PyTuple_New(5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 3, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 4, __pyx_t_8); __pyx_t_3 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_8, __pyx_t_9) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_9); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+394: [4.0, 9.0, 12.0, 9.0, 4.0],
__pyx_t_5 = PyList_New(5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 394, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_float_4_0); __Pyx_GIVEREF(__pyx_float_4_0); PyList_SET_ITEM(__pyx_t_5, 0, __pyx_float_4_0); __Pyx_INCREF(__pyx_float_9_0); __Pyx_GIVEREF(__pyx_float_9_0); PyList_SET_ITEM(__pyx_t_5, 1, __pyx_float_9_0); __Pyx_INCREF(__pyx_float_12_0); __Pyx_GIVEREF(__pyx_float_12_0); PyList_SET_ITEM(__pyx_t_5, 2, __pyx_float_12_0); __Pyx_INCREF(__pyx_float_9_0); __Pyx_GIVEREF(__pyx_float_9_0); PyList_SET_ITEM(__pyx_t_5, 3, __pyx_float_9_0); __Pyx_INCREF(__pyx_float_4_0); __Pyx_GIVEREF(__pyx_float_4_0); PyList_SET_ITEM(__pyx_t_5, 4, __pyx_float_4_0);
+395: [5.0, 12.0, 15.0, 12.0, 5.0],
__pyx_t_6 = PyList_New(5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 395, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_float_5_0); __Pyx_GIVEREF(__pyx_float_5_0); PyList_SET_ITEM(__pyx_t_6, 0, __pyx_float_5_0); __Pyx_INCREF(__pyx_float_12_0); __Pyx_GIVEREF(__pyx_float_12_0); PyList_SET_ITEM(__pyx_t_6, 1, __pyx_float_12_0); __Pyx_INCREF(__pyx_float_15_0); __Pyx_GIVEREF(__pyx_float_15_0); PyList_SET_ITEM(__pyx_t_6, 2, __pyx_float_15_0); __Pyx_INCREF(__pyx_float_12_0); __Pyx_GIVEREF(__pyx_float_12_0); PyList_SET_ITEM(__pyx_t_6, 3, __pyx_float_12_0); __Pyx_INCREF(__pyx_float_5_0); __Pyx_GIVEREF(__pyx_float_5_0); PyList_SET_ITEM(__pyx_t_6, 4, __pyx_float_5_0);
+396: [4.0, 9.0, 12.0, 9.0, 4.0],
__pyx_t_7 = PyList_New(5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 396, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_float_4_0); __Pyx_GIVEREF(__pyx_float_4_0); PyList_SET_ITEM(__pyx_t_7, 0, __pyx_float_4_0); __Pyx_INCREF(__pyx_float_9_0); __Pyx_GIVEREF(__pyx_float_9_0); PyList_SET_ITEM(__pyx_t_7, 1, __pyx_float_9_0); __Pyx_INCREF(__pyx_float_12_0); __Pyx_GIVEREF(__pyx_float_12_0); PyList_SET_ITEM(__pyx_t_7, 2, __pyx_float_12_0); __Pyx_INCREF(__pyx_float_9_0); __Pyx_GIVEREF(__pyx_float_9_0); PyList_SET_ITEM(__pyx_t_7, 3, __pyx_float_9_0); __Pyx_INCREF(__pyx_float_4_0); __Pyx_GIVEREF(__pyx_float_4_0); PyList_SET_ITEM(__pyx_t_7, 4, __pyx_float_4_0);
+397: [2.0, 4.0, 5.0, 4.0, 2.0])).astype(dtype=float32, order='C')
__pyx_t_8 = PyList_New(5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 397, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_INCREF(__pyx_float_2_0); __Pyx_GIVEREF(__pyx_float_2_0); PyList_SET_ITEM(__pyx_t_8, 0, __pyx_float_2_0); __Pyx_INCREF(__pyx_float_4_0); __Pyx_GIVEREF(__pyx_float_4_0); PyList_SET_ITEM(__pyx_t_8, 1, __pyx_float_4_0); __Pyx_INCREF(__pyx_float_5_0); __Pyx_GIVEREF(__pyx_float_5_0); PyList_SET_ITEM(__pyx_t_8, 2, __pyx_float_5_0); __Pyx_INCREF(__pyx_float_4_0); __Pyx_GIVEREF(__pyx_float_4_0); PyList_SET_ITEM(__pyx_t_8, 3, __pyx_float_4_0); __Pyx_INCREF(__pyx_float_2_0); __Pyx_GIVEREF(__pyx_float_2_0); PyList_SET_ITEM(__pyx_t_8, 4, __pyx_float_2_0); /* … */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_astype); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 397, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 397, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_float32); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 397, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_9) < 0) __PYX_ERR(0, 397, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_order, __pyx_n_u_C) < 0) __PYX_ERR(0, 397, __pyx_L1_error) __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 397, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_kernel = __pyx_t_9; __pyx_t_9 = 0;
398:
399: cdef int w, h
+400: w, h = surface_.get_size()
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 400, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_9 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 400, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_9))) || (PyList_CheckExact(__pyx_t_9))) { PyObject* sequence = __pyx_t_9; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 400, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_1 = PyList_GET_ITEM(sequence, 0); __pyx_t_4 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); #else __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 400, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 400, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else { Py_ssize_t index = -1; __pyx_t_8 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 400, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_10 = Py_TYPE(__pyx_t_8)->tp_iternext; index = 0; __pyx_t_1 = __pyx_t_10(__pyx_t_8); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_1); index = 1; __pyx_t_4 = __pyx_t_10(__pyx_t_8); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_4); if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_8), 2) < 0) __PYX_ERR(0, 400, __pyx_L1_error) __pyx_t_10 = NULL; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L4_unpacking_done; __pyx_L3_unpacking_failed:; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_10 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 400, __pyx_L1_error) __pyx_L4_unpacking_done:; } __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 400, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 400, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_w = __pyx_t_11; __pyx_v_h = __pyx_t_12;
401:
+402: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; goto __pyx_L10_try_end; __pyx_L5_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15); goto __pyx_L1_error; __pyx_L10_try_end:; }
+403: rgb_array_ = pixels3d(surface_)
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 403, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } __pyx_t_9 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_1, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 403, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_rgb_array_ = __pyx_t_9; __pyx_t_9 = 0;
+404: array_alpha_ = array_alpha(surface_)
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_array_alpha); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 404, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } __pyx_t_9 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_1, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 404, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_array_alpha_ = __pyx_t_9; __pyx_t_9 = 0;
405:
+406: except (surface_.error, ValueError):
__Pyx_ErrFetch(&__pyx_t_9, &__pyx_t_4, &__pyx_t_1); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_error); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 406, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_12 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_9, __pyx_t_8) || __Pyx_PyErr_GivenExceptionMatches(__pyx_t_9, __pyx_builtin_ValueError); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_ErrRestore(__pyx_t_9, __pyx_t_4, __pyx_t_1); __pyx_t_9 = 0; __pyx_t_4 = 0; __pyx_t_1 = 0; if (__pyx_t_12) { __Pyx_AddTraceback("PygameShader.gaussianBlur5x5.canny_blur5x5_surface32_c", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_4, &__pyx_t_9) < 0) __PYX_ERR(0, 406, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_t_9);
+407: raise ValueError('\nInvalid texture or image. '
__pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 407, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_Raise(__pyx_t_8, 0, 0, 0); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __PYX_ERR(0, 407, __pyx_L7_except_error) } goto __pyx_L7_except_error; __pyx_L7_except_error:; /* … */ __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_u_Invalid_texture_or_image_This_v); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 407, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__6); __Pyx_GIVEREF(__pyx_tuple__6);
408: 'This version is compatible with 32-bit image format '
409: 'with per-pixel transparency.')
410:
+411: assert w != 0 or h !=0, 'image with incorrect dimensions (w>0, h>0) got (%s, %s) ' % (w, h)
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_16 = ((__pyx_v_w != 0) != 0); if (!__pyx_t_16) { } else { __pyx_t_2 = __pyx_t_16; goto __pyx_L13_bool_binop_done; } __pyx_t_16 = ((__pyx_v_h != 0) != 0); __pyx_t_2 = __pyx_t_16; __pyx_L13_bool_binop_done:; if (unlikely(!__pyx_t_2)) { __pyx_t_9 = PyTuple_New(5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 411, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_17 = 0; __pyx_t_18 = 127; __Pyx_INCREF(__pyx_kp_u_image_with_incorrect_dimensions); __pyx_t_17 += 48; __Pyx_GIVEREF(__pyx_kp_u_image_with_incorrect_dimensions); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_kp_u_image_with_incorrect_dimensions); __pyx_t_4 = __Pyx_PyUnicode_From_int(__pyx_v_w, 0, ' ', 'd'); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 411, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_17 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_4); __pyx_t_4 = 0; __Pyx_INCREF(__pyx_kp_u__4); __pyx_t_17 += 2; __Pyx_GIVEREF(__pyx_kp_u__4); PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_kp_u__4); __pyx_t_4 = __Pyx_PyUnicode_From_int(__pyx_v_h, 0, ' ', 'd'); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 411, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_17 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 3, __pyx_t_4); __pyx_t_4 = 0; __Pyx_INCREF(__pyx_kp_u__5); __pyx_t_17 += 2; __Pyx_GIVEREF(__pyx_kp_u__5); PyTuple_SET_ITEM(__pyx_t_9, 4, __pyx_kp_u__5); __pyx_t_4 = __Pyx_PyUnicode_Join(__pyx_t_9, 5, __pyx_t_17, __pyx_t_18); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 411, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 411, __pyx_L1_error) } } #endif
412:
413: cdef:
+414: float kernel_weight = sum(kernel)
__Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_sum); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 414, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); } } __pyx_t_4 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_1, __pyx_v_kernel) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_kernel); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 414, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_19 = __pyx_PyFloat_AsFloat(__pyx_t_4); if (unlikely((__pyx_t_19 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 414, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_kernel_weight = __pyx_t_19;
+415: float [:, :] canny_kernel = divide(kernel, 159.0, dtype=float32)
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_divide); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 415, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 415, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_v_kernel); __Pyx_GIVEREF(__pyx_v_kernel); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_kernel); __Pyx_INCREF(__pyx_float_159_0); __Pyx_GIVEREF(__pyx_float_159_0); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_float_159_0); __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 415, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_float32); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 415, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_8) < 0) __PYX_ERR(0, 415, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 415, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_20 = __Pyx_PyObject_to_MemoryviewSlice_dsds_float(__pyx_t_8, PyBUF_WRITABLE); if (unlikely(!__pyx_t_20.memview)) __PYX_ERR(0, 415, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_v_canny_kernel = __pyx_t_20; __pyx_t_20.memview = NULL; __pyx_t_20.data = NULL;
+416: unsigned char [:, :, :] rgb_array = rgb_array_
__pyx_t_21 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_v_rgb_array_, PyBUF_WRITABLE); if (unlikely(!__pyx_t_21.memview)) __PYX_ERR(0, 416, __pyx_L1_error) __pyx_v_rgb_array = __pyx_t_21; __pyx_t_21.memview = NULL; __pyx_t_21.data = NULL;
+417: short kernel_half = <short>(len(kernel) >> 1)
__pyx_t_17 = PyObject_Length(__pyx_v_kernel); if (unlikely(__pyx_t_17 == ((Py_ssize_t)-1))) __PYX_ERR(0, 417, __pyx_L1_error) __pyx_v_kernel_half = ((short)(__pyx_t_17 >> 1));
+418: unsigned char [:, :, :] output_array = empty((h, w, 4), dtype=uint8)
__Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_empty); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_h); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_w); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_9); __Pyx_INCREF(__pyx_int_4); __Pyx_GIVEREF(__pyx_int_4); PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_int_4); __pyx_t_1 = 0; __pyx_t_9 = 0; __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_uint8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_1) < 0) __PYX_ERR(0, 418, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_9, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_21 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_21.memview)) __PYX_ERR(0, 418, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_output_array = __pyx_t_21; __pyx_t_21.memview = NULL; __pyx_t_21.data = NULL;
+419: unsigned char [:, :] alpha = array_alpha_
__pyx_t_22 = __Pyx_PyObject_to_MemoryviewSlice_dsds_unsigned_char(__pyx_v_array_alpha_, PyBUF_WRITABLE); if (unlikely(!__pyx_t_22.memview)) __PYX_ERR(0, 419, __pyx_L1_error) __pyx_v_alpha = __pyx_t_22; __pyx_t_22.memview = NULL; __pyx_t_22.data = NULL;
420: int x, y, xx, yy
421: unsigned char red, green, blue,
422: short kernel_offset_y, kernel_offset_x
423: float r, g, b, k
424:
+425: with nogil:
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L17; } __pyx_L17:; } }
426:
+427: for x in prange(0, w, schedule=SCHEDULE, num_threads=THREAD_NUMBER):
__pyx_t_12 = __pyx_v_w; if ((1 == 0)) abort(); { #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) #undef likely #undef unlikely #define likely(x) (x) #define unlikely(x) (x) #endif __pyx_t_24 = (__pyx_t_12 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_24 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_blue) lastprivate(__pyx_v_g) lastprivate(__pyx_v_green) lastprivate(__pyx_v_k) lastprivate(__pyx_v_kernel_offset_x) lastprivate(__pyx_v_kernel_offset_y) lastprivate(__pyx_v_r) lastprivate(__pyx_v_red) firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) lastprivate(__pyx_v_xx) lastprivate(__pyx_v_y) lastprivate(__pyx_v_yy) schedule(static) num_threads(8) #endif /* _OPENMP */ for (__pyx_t_23 = 0; __pyx_t_23 < __pyx_t_24; __pyx_t_23++){ { __pyx_v_x = (int)(0 + 1 * __pyx_t_23); /* Initialize private variables to invalid values */ __pyx_v_b = ((float)__PYX_NAN()); __pyx_v_blue = ((unsigned char)'?'); __pyx_v_g = ((float)__PYX_NAN()); __pyx_v_green = ((unsigned char)'?'); __pyx_v_k = ((float)__PYX_NAN()); __pyx_v_kernel_offset_x = ((short)0xbad0bad0); __pyx_v_kernel_offset_y = ((short)0xbad0bad0); __pyx_v_r = ((float)__PYX_NAN()); __pyx_v_red = ((unsigned char)'?'); __pyx_v_xx = ((int)0xbad0bad0); __pyx_v_y = ((int)0xbad0bad0); __pyx_v_yy = ((int)0xbad0bad0);
428:
+429: for y in range(0, h):
__pyx_t_11 = __pyx_v_h; __pyx_t_25 = __pyx_t_11; for (__pyx_t_26 = 0; __pyx_t_26 < __pyx_t_25; __pyx_t_26+=1) { __pyx_v_y = __pyx_t_26;
430:
+431: r, g, b = 0, 0, 0
__pyx_t_19 = 0.0; __pyx_t_27 = 0.0; __pyx_t_28 = 0.0; __pyx_v_r = __pyx_t_19; __pyx_v_g = __pyx_t_27; __pyx_v_b = __pyx_t_28;
432:
+433: for kernel_offset_y in range(-kernel_half, kernel_half + 1):
__pyx_t_29 = (__pyx_v_kernel_half + 1); __pyx_t_30 = __pyx_t_29; for (__pyx_t_31 = (-__pyx_v_kernel_half); __pyx_t_31 < __pyx_t_30; __pyx_t_31+=1) { __pyx_v_kernel_offset_y = __pyx_t_31;
434:
+435: for kernel_offset_x in range(-kernel_half, kernel_half + 1):
__pyx_t_32 = (__pyx_v_kernel_half + 1); __pyx_t_33 = __pyx_t_32; for (__pyx_t_34 = (-__pyx_v_kernel_half); __pyx_t_34 < __pyx_t_33; __pyx_t_34+=1) { __pyx_v_kernel_offset_x = __pyx_t_34;
436:
+437: xx = x + kernel_offset_x
__pyx_v_xx = (__pyx_v_x + __pyx_v_kernel_offset_x);
+438: yy = y + kernel_offset_y
__pyx_v_yy = (__pyx_v_y + __pyx_v_kernel_offset_y);
439:
+440: if xx < 0:
__pyx_t_2 = ((__pyx_v_xx < 0) != 0); if (__pyx_t_2) { /* … */ goto __pyx_L28; }
+441: xx = 0
__pyx_v_xx = 0;
+442: elif xx > w :
__pyx_t_2 = ((__pyx_v_xx > __pyx_v_w) != 0); if (__pyx_t_2) { /* … */ } __pyx_L28:;
+443: xx = w
__pyx_v_xx = __pyx_v_w;
444:
+445: if yy < 0:
__pyx_t_2 = ((__pyx_v_yy < 0) != 0); if (__pyx_t_2) { /* … */ goto __pyx_L29; }
+446: yy = 0
__pyx_v_yy = 0;
+447: elif yy > h :
__pyx_t_2 = ((__pyx_v_yy > __pyx_v_h) != 0); if (__pyx_t_2) { /* … */ } __pyx_L29:;
+448: yy = h
__pyx_v_yy = __pyx_v_h;
449:
+450: red = rgb_array[xx, yy, 0]
__pyx_t_35 = __pyx_v_xx; __pyx_t_36 = __pyx_v_yy; __pyx_t_37 = 0; __pyx_v_red = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_35 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_36 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_37 * __pyx_v_rgb_array.strides[2]) )));
+451: green = rgb_array[xx, yy, 1]
__pyx_t_37 = __pyx_v_xx; __pyx_t_36 = __pyx_v_yy; __pyx_t_35 = 1; __pyx_v_green = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_37 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_36 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_35 * __pyx_v_rgb_array.strides[2]) )));
+452: blue = rgb_array[xx, yy, 2]
__pyx_t_35 = __pyx_v_xx; __pyx_t_36 = __pyx_v_yy; __pyx_t_37 = 2; __pyx_v_blue = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_35 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_36 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_37 * __pyx_v_rgb_array.strides[2]) )));
453:
+454: k = canny_kernel[kernel_offset_y + kernel_half,
__pyx_t_37 = (__pyx_v_kernel_offset_y + __pyx_v_kernel_half); __pyx_t_36 = (__pyx_v_kernel_offset_x + __pyx_v_kernel_half); __pyx_v_k = (*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_canny_kernel.data + __pyx_t_37 * __pyx_v_canny_kernel.strides[0]) ) + __pyx_t_36 * __pyx_v_canny_kernel.strides[1]) )));
455: kernel_offset_x + kernel_half]
456:
+457: r += red * k
__pyx_v_r = (__pyx_v_r + (__pyx_v_red * __pyx_v_k));
+458: g += green * k
__pyx_v_g = (__pyx_v_g + (__pyx_v_green * __pyx_v_k));
+459: b += blue * k
__pyx_v_b = (__pyx_v_b + (__pyx_v_blue * __pyx_v_k)); } }
460:
+461: if r > 255.0:
__pyx_t_2 = ((__pyx_v_r > 255.0) != 0); if (__pyx_t_2) { /* … */ }
+462: r = <float>255.0
__pyx_v_r = ((float)255.0);
+463: if g > 255.0:
__pyx_t_2 = ((__pyx_v_g > 255.0) != 0); if (__pyx_t_2) { /* … */ }
+464: g = <float>255.0
__pyx_v_g = ((float)255.0);
+465: if b > 255.0:
__pyx_t_2 = ((__pyx_v_b > 255.0) != 0); if (__pyx_t_2) { /* … */ }
+466: b = <float>255.0
__pyx_v_b = ((float)255.0);
467:
+468: output_array[y, x, 0] = <unsigned char>r
__pyx_t_36 = __pyx_v_y; __pyx_t_37 = __pyx_v_x; __pyx_t_35 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_output_array.data + __pyx_t_36 * __pyx_v_output_array.strides[0]) ) + __pyx_t_37 * __pyx_v_output_array.strides[1]) ) + __pyx_t_35 * __pyx_v_output_array.strides[2]) )) = ((unsigned char)__pyx_v_r);
+469: output_array[y, x, 1] = <unsigned char>g
__pyx_t_35 = __pyx_v_y; __pyx_t_37 = __pyx_v_x; __pyx_t_36 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_output_array.data + __pyx_t_35 * __pyx_v_output_array.strides[0]) ) + __pyx_t_37 * __pyx_v_output_array.strides[1]) ) + __pyx_t_36 * __pyx_v_output_array.strides[2]) )) = ((unsigned char)__pyx_v_g);
+470: output_array[y, x, 2] = <unsigned char>b
__pyx_t_36 = __pyx_v_y; __pyx_t_37 = __pyx_v_x; __pyx_t_35 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_output_array.data + __pyx_t_36 * __pyx_v_output_array.strides[0]) ) + __pyx_t_37 * __pyx_v_output_array.strides[1]) ) + __pyx_t_35 * __pyx_v_output_array.strides[2]) )) = ((unsigned char)__pyx_v_b);
+471: output_array[y, x, 3] = <unsigned char>alpha[x, y]
__pyx_t_35 = __pyx_v_x; __pyx_t_37 = __pyx_v_y; __pyx_t_36 = __pyx_v_y; __pyx_t_38 = __pyx_v_x; __pyx_t_39 = 3; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_output_array.data + __pyx_t_36 * __pyx_v_output_array.strides[0]) ) + __pyx_t_38 * __pyx_v_output_array.strides[1]) ) + __pyx_t_39 * __pyx_v_output_array.strides[2]) )) = ((unsigned char)(*((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_alpha.data + __pyx_t_35 * __pyx_v_alpha.strides[0]) ) + __pyx_t_37 * __pyx_v_alpha.strides[1]) )))); } } } } } } #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) #undef likely #undef unlikely #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #endif }
472:
473: # return asarray(output_array).astype(dtype=uint8)
+474: return frombuffer(output_array, (h, w), "RGBA")
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_frombuffer); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 474, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_9 = __pyx_memoryview_fromslice(__pyx_v_output_array, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 474, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_h); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 474, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_w); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 474, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 474, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_7); __pyx_t_8 = 0; __pyx_t_7 = 0; __pyx_t_7 = NULL; __pyx_t_12 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_12 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_t_9, __pyx_t_6, __pyx_n_u_RGBA}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_12, 3+__pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 474, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_t_9, __pyx_t_6, __pyx_n_u_RGBA}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_12, 3+__pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 474, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_8 = PyTuple_New(3+__pyx_t_12); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 474, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL; } __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_12, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_12, __pyx_t_6); __Pyx_INCREF(__pyx_n_u_RGBA); __Pyx_GIVEREF(__pyx_n_u_RGBA); PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_12, __pyx_n_u_RGBA); __pyx_t_9 = 0; __pyx_t_6 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 474, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;