From fd65a3815329c33ba9335b651c18816633aae83c Mon Sep 17 00:00:00 2001 From: William Silversmith Date: Sun, 6 Sep 2020 04:49:45 -0400 Subject: [PATCH 01/23] wip: trying out bbdt for 2D boolean case --- cc3d.hpp | 140 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) diff --git a/cc3d.hpp b/cc3d.hpp index 53da744..96ed827 100644 --- a/cc3d.hpp +++ b/cc3d.hpp @@ -46,6 +46,7 @@ #define CC3D_HPP #include +#include #include #include #include @@ -752,6 +753,145 @@ OUT* connected_components2d_8( return relabel(out_labels, voxels, next_label, equivalences); } +template +OUT* connected_components2d_8_bbdt( + T* in_labels, + const int64_t sx, const int64_t sy, + size_t max_labels, OUT *out_labels = NULL + ) { + + const int64_t voxels = sx * sy; + + max_labels = std::max(std::min(max_labels, static_cast(voxels)), static_cast(1L)); // can't allocate 0 arrays + max_labels = std::min(max_labels, static_cast(std::numeric_limits::max())); + + DisjointSet equivalences(max_labels); + + if (out_labels == NULL) { + out_labels = new OUT[voxels](); + } + + /* + Layout of mask. We start from e. + + a | b | c + d | e + */ + + const int64_t A = -1 + sx; + const int64_t B = -1; + const int64_t C = -1 - sx; + const int64_t D = -sx; + const int64_t E = +1 - sx; + const int64_t F = +2 - sx; + const int64_t X = +sx; + const int64_t Y = 0; + const int64_t Z = +1; + const int64_t W = +1 + sx; + + int64_t loc = 0; + OUT next_label = 0; + + OUT lp = 0; + OUT lq = 0; + OUT lr = 0; + OUT ls = 0; + OUT lx = 0; + + std::function assignfn = [X,Y,Z,W,out_labels,in_labels](size_t loc, OUT value) { + out_labels[loc + Y] = in_labels[loc + Y] * value; + out_labels[loc + Z] = in_labels[loc + Z] * value; + out_labels[loc + X] = in_labels[loc + X] * value; + out_labels[loc + W] = in_labels[loc + W] * value; + }; + + // Raster Scan 1: Set temporary labels and + // record equivalences in a disjoint set. + for (int64_t y = 0; y < sy; y += 2) { + for (int64_t x = 0; x < sx; x += 2) { + loc = x + sx * y; + + lp = 0; + lq = 0; + lr = 0; + ls = 0; + lx = 0; + + if (in_labels[loc + Y]) { + if (x > 0 && y > 0 && in_labels[loc + C]) { + lp = out_labels[loc + C]; + } + if (y > 0 && in_labels[loc + D]) { + lq = out_labels[loc + D]; + } + else if (y > 0 && x < sx - 1 && in_labels[loc + E]) { + lq = out_labels[loc + E]; + } + if (x > 0 && in_labels[loc + B]) { + ls = out_labels[loc + B]; + } + else if (x > 0 && y < sx - 1 && in_labels[loc + A]) { + ls = out_labels[loc + A]; + } + if (x < sx - 2 && y > 0 && in_labels[loc + Z] && in_labels[loc + F]) { + lr = out_labels[loc + F]; + } + + } + else if (x < sx - 1 && in_labels[loc + Z]) { + if (y > 0 && in_labels[loc + D]) { + lq = out_labels[loc + D]; + } + else if (y > 0 && in_labels[loc + E]) { + lq = out_labels[loc + E]; + } + if (x < sx - 2 && y > 0 && in_labels[loc + F]) { + lr = in_labels[loc + F]; + } + if (x > 0 && y < sy - 1 && in_labels[loc + X]) { + ls = in_labels[loc + A] + ? out_labels[loc + A] + : out_labels[loc + B]; // out_labels will be 0 + } + } + else if (x > 0 && y < sy - 1 && in_labels[loc + X]) { + ls = in_labels[loc + A] + ? out_labels[loc + A] + : out_labels[loc + B]; // out_labels will be 0 + } + else if (!in_labels[loc + W]) { + continue; + } + + if (lq) { + assignfn(loc, lq); + } + else if (lp) { + assignfn(loc, lp); + if (lr) { + equivalences.unify(lp, lr); + } + } + else if (ls) { + assignfn(loc, ls); + if (lr) { + equivalences.unify(lp, lr); + } + } + else if (lr) { + assignfn(loc, lr); + } + else { + next_label++; + assignfn(loc, next_label); + equivalences.add(next_label); + } + } + } + + return relabel(out_labels, voxels, next_label, equivalences); +} + template OUT* connected_components3d( T* in_labels, From 0c3297d34ade576aeb897b67b7abd861f378db26 Mon Sep 17 00:00:00 2001 From: William Silversmith Date: Sun, 6 Sep 2020 14:48:19 -0400 Subject: [PATCH 02/23] wip: can run bbdt but it segfaults --- cc3d.cpp | 2403 +++++++++++++++++++++++++++++++----------------------- cc3d.hpp | 152 ++-- cc3d.pyx | 31 +- 3 files changed, 1478 insertions(+), 1108 deletions(-) diff --git a/cc3d.cpp b/cc3d.cpp index 561d085..6d51245 100644 --- a/cc3d.cpp +++ b/cc3d.cpp @@ -3177,7 +3177,7 @@ static PyObject *__pyx_codeobj__38; static PyObject *__pyx_codeobj__45; /* Late includes */ -/* "cc3d.pyx":73 +/* "cc3d.pyx":78 * pass * * def connected_components( # <<<<<<<<<<<<<< @@ -3241,7 +3241,7 @@ static PyObject *__pyx_pw_4cc3d_1connected_components(PyObject *__pyx_self, PyOb } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "connected_components") < 0)) __PYX_ERR(0, 73, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "connected_components") < 0)) __PYX_ERR(0, 78, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -3258,12 +3258,12 @@ static PyObject *__pyx_pw_4cc3d_1connected_components(PyObject *__pyx_self, PyOb } __pyx_v_data = values[0]; if (values[1]) { - __pyx_v_max_labels = __Pyx_PyInt_As_int64_t(values[1]); if (unlikely((__pyx_v_max_labels == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 74, __pyx_L3_error) + __pyx_v_max_labels = __Pyx_PyInt_As_int64_t(values[1]); if (unlikely((__pyx_v_max_labels == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 79, __pyx_L3_error) } else { __pyx_v_max_labels = ((int64_t)-1L); } if (values[2]) { - __pyx_v_connectivity = __Pyx_PyInt_As_int64_t(values[2]); if (unlikely((__pyx_v_connectivity == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 75, __pyx_L3_error) + __pyx_v_connectivity = __Pyx_PyInt_As_int64_t(values[2]); if (unlikely((__pyx_v_connectivity == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 80, __pyx_L3_error) } else { __pyx_v_connectivity = ((int64_t)26); } @@ -3271,7 +3271,7 @@ static PyObject *__pyx_pw_4cc3d_1connected_components(PyObject *__pyx_self, PyOb } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("connected_components", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 73, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("connected_components", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 78, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("cc3d.connected_components", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -3378,6 +3378,18 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p Py_ssize_t __pyx_t_67; Py_ssize_t __pyx_t_68; Py_ssize_t __pyx_t_69; + Py_ssize_t __pyx_t_70; + Py_ssize_t __pyx_t_71; + Py_ssize_t __pyx_t_72; + Py_ssize_t __pyx_t_73; + Py_ssize_t __pyx_t_74; + Py_ssize_t __pyx_t_75; + Py_ssize_t __pyx_t_76; + Py_ssize_t __pyx_t_77; + Py_ssize_t __pyx_t_78; + Py_ssize_t __pyx_t_79; + Py_ssize_t __pyx_t_80; + Py_ssize_t __pyx_t_81; __Pyx_RefNannySetupContext("connected_components", 0); __Pyx_INCREF(__pyx_v_data); __Pyx_INCREF(__pyx_v_out_dtype); @@ -3394,23 +3406,23 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p __pyx_pybuffernd_out_labels64.data = NULL; __pyx_pybuffernd_out_labels64.rcbuffer = &__pyx_pybuffer_out_labels64; - /* "cc3d.pyx":101 + /* "cc3d.pyx":106 * the connected components. * """ * dims = len(data.shape) # <<<<<<<<<<<<<< * if dims not in (1,2,3): * raise DimensionError("Only 1D, 2D, and 3D arrays supported. Got: " + str(dims)) */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 101, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 101, __pyx_L1_error) + __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 106, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 101, __pyx_L1_error) + __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_dims = __pyx_t_1; __pyx_t_1 = 0; - /* "cc3d.pyx":102 + /* "cc3d.pyx":107 * """ * dims = len(data.shape) * if dims not in (1,2,3): # <<<<<<<<<<<<<< @@ -3419,27 +3431,27 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ __Pyx_INCREF(__pyx_v_dims); __pyx_t_1 = __pyx_v_dims; - __pyx_t_4 = __Pyx_PyInt_NeObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 102, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_NeObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 102, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_5) { } else { __pyx_t_3 = __pyx_t_5; goto __pyx_L4_bool_binop_done; } - __pyx_t_4 = __Pyx_PyInt_NeObjC(__pyx_t_1, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 102, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_NeObjC(__pyx_t_1, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 102, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_5) { } else { __pyx_t_3 = __pyx_t_5; goto __pyx_L4_bool_binop_done; } - __pyx_t_4 = __Pyx_PyInt_NeObjC(__pyx_t_1, __pyx_int_3, 3, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 102, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_NeObjC(__pyx_t_1, __pyx_int_3, 3, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 102, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_3 = __pyx_t_5; __pyx_L4_bool_binop_done:; @@ -3447,18 +3459,18 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p __pyx_t_5 = (__pyx_t_3 != 0); if (unlikely(__pyx_t_5)) { - /* "cc3d.pyx":103 + /* "cc3d.pyx":108 * dims = len(data.shape) * if dims not in (1,2,3): * raise DimensionError("Only 1D, 2D, and 3D arrays supported. Got: " + str(dims)) # <<<<<<<<<<<<<< * * out_dtype = np.dtype(out_dtype) */ - __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_DimensionError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 103, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_DimensionError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_v_dims); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 103, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_v_dims); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Only_1D_2D_and_3D_arrays_support, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 103, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Only_1D_2D_and_3D_arrays_support, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = NULL; @@ -3474,14 +3486,14 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_6, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 103, __pyx_L1_error) + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 103, __pyx_L1_error) + __PYX_ERR(0, 108, __pyx_L1_error) - /* "cc3d.pyx":102 + /* "cc3d.pyx":107 * """ * dims = len(data.shape) * if dims not in (1,2,3): # <<<<<<<<<<<<<< @@ -3490,16 +3502,16 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ } - /* "cc3d.pyx":105 + /* "cc3d.pyx":110 * raise DimensionError("Only 1D, 2D, and 3D arrays supported. Got: " + str(dims)) * * out_dtype = np.dtype(out_dtype) # <<<<<<<<<<<<<< * if out_dtype not in (np.uint16, np.uint32, np.uint64): * raise TypeError( */ - __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 105, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 110, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 105, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 110, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; @@ -3514,13 +3526,13 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p } __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_4, __pyx_v_out_dtype) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_out_dtype); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 105, __pyx_L1_error) + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 110, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF_SET(__pyx_v_out_dtype, __pyx_t_1); __pyx_t_1 = 0; - /* "cc3d.pyx":106 + /* "cc3d.pyx":111 * * out_dtype = np.dtype(out_dtype) * if out_dtype not in (np.uint16, np.uint32, np.uint64): # <<<<<<<<<<<<<< @@ -3529,42 +3541,42 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ __Pyx_INCREF(__pyx_v_out_dtype); __pyx_t_1 = __pyx_v_out_dtype; - __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 106, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_uint16); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 106, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_uint16); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = PyObject_RichCompare(__pyx_t_1, __pyx_t_4, Py_NE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 106, __pyx_L1_error) + __pyx_t_7 = PyObject_RichCompare(__pyx_t_1, __pyx_t_4, Py_NE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 106, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_3) { } else { __pyx_t_5 = __pyx_t_3; goto __pyx_L8_bool_binop_done; } - __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 106, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_uint32); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 106, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_uint32); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = PyObject_RichCompare(__pyx_t_1, __pyx_t_4, Py_NE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 106, __pyx_L1_error) + __pyx_t_7 = PyObject_RichCompare(__pyx_t_1, __pyx_t_4, Py_NE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 106, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_3) { } else { __pyx_t_5 = __pyx_t_3; goto __pyx_L8_bool_binop_done; } - __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 106, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_uint64); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 106, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_uint64); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = PyObject_RichCompare(__pyx_t_1, __pyx_t_4, Py_NE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 106, __pyx_L1_error) + __pyx_t_7 = PyObject_RichCompare(__pyx_t_1, __pyx_t_4, Py_NE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 106, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_5 = __pyx_t_3; __pyx_L8_bool_binop_done:; @@ -3572,20 +3584,20 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p __pyx_t_3 = (__pyx_t_5 != 0); if (unlikely(__pyx_t_3)) { - /* "cc3d.pyx":107 + /* "cc3d.pyx":112 * out_dtype = np.dtype(out_dtype) * if out_dtype not in (np.uint16, np.uint32, np.uint64): * raise TypeError( # <<<<<<<<<<<<<< * """Only unsigned 16, 32, and 64 bit out data types are * supported through the python interface (C++ can handle any integer type).""" */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 107, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 107, __pyx_L1_error) + __PYX_ERR(0, 112, __pyx_L1_error) - /* "cc3d.pyx":106 + /* "cc3d.pyx":111 * * out_dtype = np.dtype(out_dtype) * if out_dtype not in (np.uint16, np.uint32, np.uint64): # <<<<<<<<<<<<<< @@ -3594,16 +3606,16 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ } - /* "cc3d.pyx":112 + /* "cc3d.pyx":117 * ) * * if dims == 2 and connectivity not in (4, 8, 6, 18, 26): # <<<<<<<<<<<<<< * raise ValueError("Only 4, 8, and 6, 18, 26 connectivities are supported for 2D images. Got: " + str(connectivity)) * elif dims != 2 and connectivity not in (6, 18, 26): */ - __pyx_t_1 = __Pyx_PyInt_EqObjC(__pyx_v_dims, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 112, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_EqObjC(__pyx_v_dims, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 117, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 112, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 117, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_5) { } else { @@ -3627,29 +3639,29 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p __pyx_L12_bool_binop_done:; if (unlikely(__pyx_t_3)) { - /* "cc3d.pyx":113 + /* "cc3d.pyx":118 * * if dims == 2 and connectivity not in (4, 8, 6, 18, 26): * raise ValueError("Only 4, 8, and 6, 18, 26 connectivities are supported for 2D images. Got: " + str(connectivity)) # <<<<<<<<<<<<<< * elif dims != 2 and connectivity not in (6, 18, 26): * raise ValueError("Only 6, 18, and 26 connectivities are supported for 3D images. Got: " + str(connectivity)) */ - __pyx_t_1 = __Pyx_PyInt_From_int64_t(__pyx_v_connectivity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 113, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int64_t(__pyx_v_connectivity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 118, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 113, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 118, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Only_4_8_and_6_18_26_connectivit, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 113, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Only_4_8_and_6_18_26_connectivit, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 118, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 113, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 118, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_7, 0, 0, 0); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __PYX_ERR(0, 113, __pyx_L1_error) + __PYX_ERR(0, 118, __pyx_L1_error) - /* "cc3d.pyx":112 + /* "cc3d.pyx":117 * ) * * if dims == 2 and connectivity not in (4, 8, 6, 18, 26): # <<<<<<<<<<<<<< @@ -3658,16 +3670,16 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ } - /* "cc3d.pyx":114 + /* "cc3d.pyx":119 * if dims == 2 and connectivity not in (4, 8, 6, 18, 26): * raise ValueError("Only 4, 8, and 6, 18, 26 connectivities are supported for 2D images. Got: " + str(connectivity)) * elif dims != 2 and connectivity not in (6, 18, 26): # <<<<<<<<<<<<<< * raise ValueError("Only 6, 18, and 26 connectivities are supported for 3D images. Got: " + str(connectivity)) * */ - __pyx_t_7 = __Pyx_PyInt_NeObjC(__pyx_v_dims, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 114, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyInt_NeObjC(__pyx_v_dims, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 119, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 114, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 119, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_8) { } else { @@ -3689,29 +3701,29 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p __pyx_L14_bool_binop_done:; if (unlikely(__pyx_t_3)) { - /* "cc3d.pyx":115 + /* "cc3d.pyx":120 * raise ValueError("Only 4, 8, and 6, 18, 26 connectivities are supported for 2D images. Got: " + str(connectivity)) * elif dims != 2 and connectivity not in (6, 18, 26): * raise ValueError("Only 6, 18, and 26 connectivities are supported for 3D images. Got: " + str(connectivity)) # <<<<<<<<<<<<<< * * if data.size == 0: */ - __pyx_t_7 = __Pyx_PyInt_From_int64_t(__pyx_v_connectivity); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 115, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyInt_From_int64_t(__pyx_v_connectivity); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 115, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Only_6_18_and_26_connectivities, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 115, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Only_6_18_and_26_connectivities, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 115, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 115, __pyx_L1_error) + __PYX_ERR(0, 120, __pyx_L1_error) - /* "cc3d.pyx":114 + /* "cc3d.pyx":119 * if dims == 2 and connectivity not in (4, 8, 6, 18, 26): * raise ValueError("Only 4, 8, and 6, 18, 26 connectivities are supported for 2D images. Got: " + str(connectivity)) * elif dims != 2 and connectivity not in (6, 18, 26): # <<<<<<<<<<<<<< @@ -3720,23 +3732,23 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ } - /* "cc3d.pyx":117 + /* "cc3d.pyx":122 * raise ValueError("Only 6, 18, and 26 connectivities are supported for 3D images. Got: " + str(connectivity)) * * if data.size == 0: # <<<<<<<<<<<<<< * return np.zeros(shape=(0,), dtype=np.uint32) * */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 117, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 122, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = __Pyx_PyInt_EqObjC(__pyx_t_1, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 117, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyInt_EqObjC(__pyx_t_1, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 122, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 117, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 122, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_3) { - /* "cc3d.pyx":118 + /* "cc3d.pyx":123 * * if data.size == 0: * return np.zeros(shape=(0,), dtype=np.uint32) # <<<<<<<<<<<<<< @@ -3744,22 +3756,22 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p * order = 'F' if data.flags['F_CONTIGUOUS'] else 'C' */ __Pyx_XDECREF(__pyx_r); - __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 118, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_zeros); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 118, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_zeros); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 118, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_shape, __pyx_tuple__3) < 0) __PYX_ERR(0, 118, __pyx_L1_error) - __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 118, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_shape, __pyx_tuple__3) < 0) __PYX_ERR(0, 123, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_uint32); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 118, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_uint32); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, __pyx_t_6) < 0) __PYX_ERR(0, 118, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, __pyx_t_6) < 0) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 118, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; @@ -3767,7 +3779,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p __pyx_t_6 = 0; goto __pyx_L0; - /* "cc3d.pyx":117 + /* "cc3d.pyx":122 * raise ValueError("Only 6, 18, and 26 connectivities are supported for 3D images. Got: " + str(connectivity)) * * if data.size == 0: # <<<<<<<<<<<<<< @@ -3776,19 +3788,19 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ } - /* "cc3d.pyx":120 + /* "cc3d.pyx":125 * return np.zeros(shape=(0,), dtype=np.uint32) * * order = 'F' if data.flags['F_CONTIGUOUS'] else 'C' # <<<<<<<<<<<<<< * * while len(data.shape) < 3: */ - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_flags); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 120, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_flags); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_t_7, __pyx_n_u_F_CONTIGUOUS); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 120, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_t_7, __pyx_n_u_F_CONTIGUOUS); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 120, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 125, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_3) { __Pyx_INCREF(__pyx_n_u_F); @@ -3800,7 +3812,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p __pyx_v_order = ((PyObject*)__pyx_t_6); __pyx_t_6 = 0; - /* "cc3d.pyx":122 + /* "cc3d.pyx":127 * order = 'F' if data.flags['F_CONTIGUOUS'] else 'C' * * while len(data.shape) < 3: # <<<<<<<<<<<<<< @@ -3808,37 +3820,37 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p * data = data[np.newaxis, ...] */ while (1) { - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_shape); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 122, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_shape); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_2 = PyObject_Length(__pyx_t_6); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 122, __pyx_L1_error) + __pyx_t_2 = PyObject_Length(__pyx_t_6); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_3 = ((__pyx_t_2 < 3) != 0); if (!__pyx_t_3) break; - /* "cc3d.pyx":123 + /* "cc3d.pyx":128 * * while len(data.shape) < 3: * if order == 'C': # <<<<<<<<<<<<<< * data = data[np.newaxis, ...] * else: # F */ - __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_v_order, __pyx_n_u_C, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 123, __pyx_L1_error) + __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_v_order, __pyx_n_u_C, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 128, __pyx_L1_error) __pyx_t_5 = (__pyx_t_3 != 0); if (__pyx_t_5) { - /* "cc3d.pyx":124 + /* "cc3d.pyx":129 * while len(data.shape) < 3: * if order == 'C': * data = data[np.newaxis, ...] # <<<<<<<<<<<<<< * else: # F * data = data[..., np.newaxis ] */ - __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 124, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 129, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_newaxis); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_newaxis); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 129, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 124, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 129, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); @@ -3846,13 +3858,13 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p __Pyx_GIVEREF(Py_Ellipsis); PyTuple_SET_ITEM(__pyx_t_6, 1, Py_Ellipsis); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_data, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_data, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 129, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_1); __pyx_t_1 = 0; - /* "cc3d.pyx":123 + /* "cc3d.pyx":128 * * while len(data.shape) < 3: * if order == 'C': # <<<<<<<<<<<<<< @@ -3862,7 +3874,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p goto __pyx_L19; } - /* "cc3d.pyx":126 + /* "cc3d.pyx":131 * data = data[np.newaxis, ...] * else: # F * data = data[..., np.newaxis ] # <<<<<<<<<<<<<< @@ -3870,12 +3882,12 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p * if not data.flags['C_CONTIGUOUS'] and not data.flags['F_CONTIGUOUS']: */ /*else*/ { - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 126, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 131, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_newaxis); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 126, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_newaxis); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 131, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 126, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 131, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(Py_Ellipsis); __Pyx_GIVEREF(Py_Ellipsis); @@ -3883,7 +3895,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_v_data, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 126, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_v_data, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 131, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_6); @@ -3892,19 +3904,19 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p __pyx_L19:; } - /* "cc3d.pyx":128 + /* "cc3d.pyx":133 * data = data[..., np.newaxis ] * * if not data.flags['C_CONTIGUOUS'] and not data.flags['F_CONTIGUOUS']: # <<<<<<<<<<<<<< * data = np.copy(data, order=order) * */ - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_flags); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 128, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_flags); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_t_6, __pyx_n_u_C_CONTIGUOUS); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 128, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_t_6, __pyx_n_u_C_CONTIGUOUS); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 128, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_8 = ((!__pyx_t_3) != 0); if (__pyx_t_8) { @@ -3912,39 +3924,39 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p __pyx_t_5 = __pyx_t_8; goto __pyx_L21_bool_binop_done; } - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 128, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyObject_Dict_GetItem(__pyx_t_1, __pyx_n_u_F_CONTIGUOUS); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 128, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_Dict_GetItem(__pyx_t_1, __pyx_n_u_F_CONTIGUOUS); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 128, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_3 = ((!__pyx_t_8) != 0); __pyx_t_5 = __pyx_t_3; __pyx_L21_bool_binop_done:; if (__pyx_t_5) { - /* "cc3d.pyx":129 + /* "cc3d.pyx":134 * * if not data.flags['C_CONTIGUOUS'] and not data.flags['F_CONTIGUOUS']: * data = np.copy(data, order=order) # <<<<<<<<<<<<<< * * shape = list(data.shape) */ - __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 129, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 134, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_copy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 129, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_copy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 134, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 129, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 134, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_data); __Pyx_GIVEREF(__pyx_v_data); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_data); - __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 129, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 134, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 129, __pyx_L1_error) - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 129, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 134, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 134, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; @@ -3952,7 +3964,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_4); __pyx_t_4 = 0; - /* "cc3d.pyx":128 + /* "cc3d.pyx":133 * data = data[..., np.newaxis ] * * if not data.flags['C_CONTIGUOUS'] and not data.flags['F_CONTIGUOUS']: # <<<<<<<<<<<<<< @@ -3961,42 +3973,42 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ } - /* "cc3d.pyx":131 + /* "cc3d.pyx":136 * data = np.copy(data, order=order) * * shape = list(data.shape) # <<<<<<<<<<<<<< * * if order == 'C': */ - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 131, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_7 = PySequence_List(__pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 131, __pyx_L1_error) + __pyx_t_7 = PySequence_List(__pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_shape = ((PyObject*)__pyx_t_7); __pyx_t_7 = 0; - /* "cc3d.pyx":133 + /* "cc3d.pyx":138 * shape = list(data.shape) * * if order == 'C': # <<<<<<<<<<<<<< * shape.reverse() * */ - __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_v_order, __pyx_n_u_C, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 133, __pyx_L1_error) + __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_v_order, __pyx_n_u_C, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 138, __pyx_L1_error) __pyx_t_3 = (__pyx_t_5 != 0); if (__pyx_t_3) { - /* "cc3d.pyx":134 + /* "cc3d.pyx":139 * * if order == 'C': * shape.reverse() # <<<<<<<<<<<<<< * * cdef int sx = shape[0] */ - __pyx_t_9 = PyList_Reverse(__pyx_v_shape); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 134, __pyx_L1_error) + __pyx_t_9 = PyList_Reverse(__pyx_v_shape); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 139, __pyx_L1_error) - /* "cc3d.pyx":133 + /* "cc3d.pyx":138 * shape = list(data.shape) * * if order == 'C': # <<<<<<<<<<<<<< @@ -4005,46 +4017,46 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ } - /* "cc3d.pyx":136 + /* "cc3d.pyx":141 * shape.reverse() * * cdef int sx = shape[0] # <<<<<<<<<<<<<< * cdef int sy = shape[1] * cdef int sz = shape[2] */ - __pyx_t_7 = __Pyx_GetItemInt_List(__pyx_v_shape, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 136, __pyx_L1_error) + __pyx_t_7 = __Pyx_GetItemInt_List(__pyx_v_shape, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 141, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_t_7); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 136, __pyx_L1_error) + __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_t_7); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 141, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_v_sx = __pyx_t_10; - /* "cc3d.pyx":137 + /* "cc3d.pyx":142 * * cdef int sx = shape[0] * cdef int sy = shape[1] # <<<<<<<<<<<<<< * cdef int sz = shape[2] * */ - __pyx_t_7 = __Pyx_GetItemInt_List(__pyx_v_shape, 1, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 137, __pyx_L1_error) + __pyx_t_7 = __Pyx_GetItemInt_List(__pyx_v_shape, 1, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 142, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_t_7); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 137, __pyx_L1_error) + __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_t_7); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 142, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_v_sy = __pyx_t_10; - /* "cc3d.pyx":138 + /* "cc3d.pyx":143 * cdef int sx = shape[0] * cdef int sy = shape[1] * cdef int sz = shape[2] # <<<<<<<<<<<<<< * * cdef uint8_t[:,:,:] arr_memview8u */ - __pyx_t_7 = __Pyx_GetItemInt_List(__pyx_v_shape, 2, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 138, __pyx_L1_error) + __pyx_t_7 = __Pyx_GetItemInt_List(__pyx_v_shape, 2, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_t_7); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 138, __pyx_L1_error) + __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_t_7); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_v_sz = __pyx_t_10; - /* "cc3d.pyx":145 + /* "cc3d.pyx":150 * cdef uint64_t[:,:,:] arr_memview64u * * cdef uint64_t voxels = sx * sy * sz # <<<<<<<<<<<<<< @@ -4053,46 +4065,46 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ __pyx_v_voxels = ((((uint64_t)__pyx_v_sx) * ((uint64_t)__pyx_v_sy)) * ((uint64_t)__pyx_v_sz)); - /* "cc3d.pyx":146 + /* "cc3d.pyx":151 * * cdef uint64_t voxels = sx * sy * sz * cdef cnp.ndarray[uint16_t, ndim=1] out_labels16 = np.array([], dtype=np.uint16) # <<<<<<<<<<<<<< * cdef cnp.ndarray[uint32_t, ndim=1] out_labels32 = np.array([], dtype=np.uint32) * cdef cnp.ndarray[uint64_t, ndim=1] out_labels64 = np.array([], dtype=np.uint64) */ - __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 146, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 151, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_array); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 146, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_array); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 151, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 146, __pyx_L1_error) + __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 151, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 146, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 151, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 146, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 151, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 151, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_uint16); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 146, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_uint16); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 151, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, __pyx_t_11) < 0) __PYX_ERR(0, 146, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, __pyx_t_11) < 0) __PYX_ERR(0, 151, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 146, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 151, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 146, __pyx_L1_error) + if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 151, __pyx_L1_error) __pyx_t_12 = ((PyArrayObject *)__pyx_t_11); { __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_out_labels16.rcbuffer->pybuffer, (PyObject*)__pyx_t_12, &__Pyx_TypeInfo_nn_uint16_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { __pyx_v_out_labels16 = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_out_labels16.rcbuffer->pybuffer.buf = NULL; - __PYX_ERR(0, 146, __pyx_L1_error) + __PYX_ERR(0, 151, __pyx_L1_error) } else {__pyx_pybuffernd_out_labels16.diminfo[0].strides = __pyx_pybuffernd_out_labels16.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_out_labels16.diminfo[0].shape = __pyx_pybuffernd_out_labels16.rcbuffer->pybuffer.shape[0]; } } @@ -4100,46 +4112,46 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p __pyx_v_out_labels16 = ((PyArrayObject *)__pyx_t_11); __pyx_t_11 = 0; - /* "cc3d.pyx":147 + /* "cc3d.pyx":152 * cdef uint64_t voxels = sx * sy * sz * cdef cnp.ndarray[uint16_t, ndim=1] out_labels16 = np.array([], dtype=np.uint16) * cdef cnp.ndarray[uint32_t, ndim=1] out_labels32 = np.array([], dtype=np.uint32) # <<<<<<<<<<<<<< * cdef cnp.ndarray[uint64_t, ndim=1] out_labels64 = np.array([], dtype=np.uint64) * */ - __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 147, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 152, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_array); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 147, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_array); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 152, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = PyList_New(0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 147, __pyx_L1_error) + __pyx_t_11 = PyList_New(0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 152, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 147, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 152, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 147, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 152, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 147, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 152, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_uint32); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 147, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_uint32); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 152, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_dtype, __pyx_t_1) < 0) __PYX_ERR(0, 147, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_dtype, __pyx_t_1) < 0) __PYX_ERR(0, 152, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_6, __pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 147, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_6, __pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 152, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 147, __pyx_L1_error) + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 152, __pyx_L1_error) __pyx_t_13 = ((PyArrayObject *)__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_out_labels32.rcbuffer->pybuffer, (PyObject*)__pyx_t_13, &__Pyx_TypeInfo_nn_uint32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { __pyx_v_out_labels32 = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_out_labels32.rcbuffer->pybuffer.buf = NULL; - __PYX_ERR(0, 147, __pyx_L1_error) + __PYX_ERR(0, 152, __pyx_L1_error) } else {__pyx_pybuffernd_out_labels32.diminfo[0].strides = __pyx_pybuffernd_out_labels32.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_out_labels32.diminfo[0].shape = __pyx_pybuffernd_out_labels32.rcbuffer->pybuffer.shape[0]; } } @@ -4147,46 +4159,46 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p __pyx_v_out_labels32 = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; - /* "cc3d.pyx":148 + /* "cc3d.pyx":153 * cdef cnp.ndarray[uint16_t, ndim=1] out_labels16 = np.array([], dtype=np.uint16) * cdef cnp.ndarray[uint32_t, ndim=1] out_labels32 = np.array([], dtype=np.uint32) * cdef cnp.ndarray[uint64_t, ndim=1] out_labels64 = np.array([], dtype=np.uint64) # <<<<<<<<<<<<<< * * if out_dtype == np.uint16: */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 148, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 153, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 148, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 153, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 148, __pyx_L1_error) + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 153, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 148, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 153, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 148, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 153, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 148, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 153, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_uint64); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 148, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_uint64); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 153, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(0, 148, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(0, 153, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 148, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 153, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 148, __pyx_L1_error) + if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 153, __pyx_L1_error) __pyx_t_14 = ((PyArrayObject *)__pyx_t_4); { __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_out_labels64.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_nn_uint64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { __pyx_v_out_labels64 = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_out_labels64.rcbuffer->pybuffer.buf = NULL; - __PYX_ERR(0, 148, __pyx_L1_error) + __PYX_ERR(0, 153, __pyx_L1_error) } else {__pyx_pybuffernd_out_labels64.diminfo[0].strides = __pyx_pybuffernd_out_labels64.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_out_labels64.diminfo[0].shape = __pyx_pybuffernd_out_labels64.rcbuffer->pybuffer.shape[0]; } } @@ -4194,58 +4206,58 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p __pyx_v_out_labels64 = ((PyArrayObject *)__pyx_t_4); __pyx_t_4 = 0; - /* "cc3d.pyx":150 + /* "cc3d.pyx":155 * cdef cnp.ndarray[uint64_t, ndim=1] out_labels64 = np.array([], dtype=np.uint64) * * if out_dtype == np.uint16: # <<<<<<<<<<<<<< * out_labels16 = np.zeros( (voxels,), dtype=out_dtype, order='C' ) * out_labels = out_labels16 */ - __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 150, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 155, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_uint16); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 150, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_uint16); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 155, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 150, __pyx_L1_error) + __pyx_t_4 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 155, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 150, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 155, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_3) { - /* "cc3d.pyx":151 + /* "cc3d.pyx":156 * * if out_dtype == np.uint16: * out_labels16 = np.zeros( (voxels,), dtype=out_dtype, order='C' ) # <<<<<<<<<<<<<< * out_labels = out_labels16 * elif out_dtype == np.uint32: */ - __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 151, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 156, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 151, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyInt_From_uint64_t(__pyx_v_voxels); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 151, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_uint64_t(__pyx_v_voxels); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 156, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 151, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 156, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 151, __pyx_L1_error) + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 156, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 151, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 156, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, __pyx_v_out_dtype) < 0) __PYX_ERR(0, 151, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_order, __pyx_n_u_C) < 0) __PYX_ERR(0, 151, __pyx_L1_error) - __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 151, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, __pyx_v_out_dtype) < 0) __PYX_ERR(0, 156, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_order, __pyx_n_u_C) < 0) __PYX_ERR(0, 156, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 156, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 151, __pyx_L1_error) + if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 156, __pyx_L1_error) __pyx_t_12 = ((PyArrayObject *)__pyx_t_11); { __Pyx_BufFmt_StackElem __pyx_stack[1]; @@ -4262,13 +4274,13 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p __pyx_t_15 = __pyx_t_16 = __pyx_t_17 = 0; } __pyx_pybuffernd_out_labels16.diminfo[0].strides = __pyx_pybuffernd_out_labels16.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_out_labels16.diminfo[0].shape = __pyx_pybuffernd_out_labels16.rcbuffer->pybuffer.shape[0]; - if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 151, __pyx_L1_error) + if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 156, __pyx_L1_error) } __pyx_t_12 = 0; __Pyx_DECREF_SET(__pyx_v_out_labels16, ((PyArrayObject *)__pyx_t_11)); __pyx_t_11 = 0; - /* "cc3d.pyx":152 + /* "cc3d.pyx":157 * if out_dtype == np.uint16: * out_labels16 = np.zeros( (voxels,), dtype=out_dtype, order='C' ) * out_labels = out_labels16 # <<<<<<<<<<<<<< @@ -4278,7 +4290,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p __Pyx_INCREF(((PyObject *)__pyx_v_out_labels16)); __pyx_v_out_labels = ((PyObject *)__pyx_v_out_labels16); - /* "cc3d.pyx":150 + /* "cc3d.pyx":155 * cdef cnp.ndarray[uint64_t, ndim=1] out_labels64 = np.array([], dtype=np.uint64) * * if out_dtype == np.uint16: # <<<<<<<<<<<<<< @@ -4288,58 +4300,58 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p goto __pyx_L24; } - /* "cc3d.pyx":153 + /* "cc3d.pyx":158 * out_labels16 = np.zeros( (voxels,), dtype=out_dtype, order='C' ) * out_labels = out_labels16 * elif out_dtype == np.uint32: # <<<<<<<<<<<<<< * out_labels32 = np.zeros( (voxels,), dtype=out_dtype, order='C' ) * out_labels = out_labels32 */ - __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 153, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 158, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_uint32); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 153, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_uint32); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 158, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 153, __pyx_L1_error) + __pyx_t_11 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 158, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 153, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 158, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (__pyx_t_3) { - /* "cc3d.pyx":154 + /* "cc3d.pyx":159 * out_labels = out_labels16 * elif out_dtype == np.uint32: * out_labels32 = np.zeros( (voxels,), dtype=out_dtype, order='C' ) # <<<<<<<<<<<<<< * out_labels = out_labels32 * elif out_dtype == np.uint64: */ - __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 154, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 154, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = __Pyx_PyInt_From_uint64_t(__pyx_v_voxels); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 154, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyInt_From_uint64_t(__pyx_v_voxels); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 154, __pyx_L1_error) + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 154, __pyx_L1_error) + __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 154, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_v_out_dtype) < 0) __PYX_ERR(0, 154, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_order, __pyx_n_u_C) < 0) __PYX_ERR(0, 154, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_11, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 154, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_v_out_dtype) < 0) __PYX_ERR(0, 159, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_order, __pyx_n_u_C) < 0) __PYX_ERR(0, 159, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_11, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 154, __pyx_L1_error) + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 159, __pyx_L1_error) __pyx_t_13 = ((PyArrayObject *)__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; @@ -4356,13 +4368,13 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p __pyx_t_17 = __pyx_t_16 = __pyx_t_15 = 0; } __pyx_pybuffernd_out_labels32.diminfo[0].strides = __pyx_pybuffernd_out_labels32.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_out_labels32.diminfo[0].shape = __pyx_pybuffernd_out_labels32.rcbuffer->pybuffer.shape[0]; - if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 154, __pyx_L1_error) + if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 159, __pyx_L1_error) } __pyx_t_13 = 0; __Pyx_DECREF_SET(__pyx_v_out_labels32, ((PyArrayObject *)__pyx_t_1)); __pyx_t_1 = 0; - /* "cc3d.pyx":155 + /* "cc3d.pyx":160 * elif out_dtype == np.uint32: * out_labels32 = np.zeros( (voxels,), dtype=out_dtype, order='C' ) * out_labels = out_labels32 # <<<<<<<<<<<<<< @@ -4372,7 +4384,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p __Pyx_INCREF(((PyObject *)__pyx_v_out_labels32)); __pyx_v_out_labels = ((PyObject *)__pyx_v_out_labels32); - /* "cc3d.pyx":153 + /* "cc3d.pyx":158 * out_labels16 = np.zeros( (voxels,), dtype=out_dtype, order='C' ) * out_labels = out_labels16 * elif out_dtype == np.uint32: # <<<<<<<<<<<<<< @@ -4382,58 +4394,58 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p goto __pyx_L24; } - /* "cc3d.pyx":156 + /* "cc3d.pyx":161 * out_labels32 = np.zeros( (voxels,), dtype=out_dtype, order='C' ) * out_labels = out_labels32 * elif out_dtype == np.uint64: # <<<<<<<<<<<<<< * out_labels64 = np.zeros( (voxels,), dtype=out_dtype, order='C' ) * out_labels = out_labels64 */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 161, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_uint64); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 156, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_uint64); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 161, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error) + __pyx_t_1 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 161, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 156, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 161, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_3) { - /* "cc3d.pyx":157 + /* "cc3d.pyx":162 * out_labels = out_labels32 * elif out_dtype == np.uint64: * out_labels64 = np.zeros( (voxels,), dtype=out_dtype, order='C' ) # <<<<<<<<<<<<<< * out_labels = out_labels64 * */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 162, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 157, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 162, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_uint64_t(__pyx_v_voxels); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_uint64_t(__pyx_v_voxels); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 162, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 157, __pyx_L1_error) + __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 162, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 162, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 157, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 162, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_dtype, __pyx_v_out_dtype) < 0) __PYX_ERR(0, 157, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_order, __pyx_n_u_C) < 0) __PYX_ERR(0, 157, __pyx_L1_error) - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, __pyx_t_11); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 157, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_dtype, __pyx_v_out_dtype) < 0) __PYX_ERR(0, 162, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_order, __pyx_n_u_C) < 0) __PYX_ERR(0, 162, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, __pyx_t_11); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 162, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 157, __pyx_L1_error) + if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 162, __pyx_L1_error) __pyx_t_14 = ((PyArrayObject *)__pyx_t_6); { __Pyx_BufFmt_StackElem __pyx_stack[1]; @@ -4450,13 +4462,13 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p __pyx_t_15 = __pyx_t_16 = __pyx_t_17 = 0; } __pyx_pybuffernd_out_labels64.diminfo[0].strides = __pyx_pybuffernd_out_labels64.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_out_labels64.diminfo[0].shape = __pyx_pybuffernd_out_labels64.rcbuffer->pybuffer.shape[0]; - if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 157, __pyx_L1_error) + if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 162, __pyx_L1_error) } __pyx_t_14 = 0; __Pyx_DECREF_SET(__pyx_v_out_labels64, ((PyArrayObject *)__pyx_t_6)); __pyx_t_6 = 0; - /* "cc3d.pyx":158 + /* "cc3d.pyx":163 * elif out_dtype == np.uint64: * out_labels64 = np.zeros( (voxels,), dtype=out_dtype, order='C' ) * out_labels = out_labels64 # <<<<<<<<<<<<<< @@ -4466,7 +4478,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p __Pyx_INCREF(((PyObject *)__pyx_v_out_labels64)); __pyx_v_out_labels = ((PyObject *)__pyx_v_out_labels64); - /* "cc3d.pyx":156 + /* "cc3d.pyx":161 * out_labels32 = np.zeros( (voxels,), dtype=out_dtype, order='C' ) * out_labels = out_labels32 * elif out_dtype == np.uint64: # <<<<<<<<<<<<<< @@ -4476,7 +4488,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p } __pyx_L24:; - /* "cc3d.pyx":160 + /* "cc3d.pyx":165 * out_labels = out_labels64 * * if max_labels <= 0: # <<<<<<<<<<<<<< @@ -4486,7 +4498,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p __pyx_t_3 = ((__pyx_v_max_labels <= 0) != 0); if (__pyx_t_3) { - /* "cc3d.pyx":161 + /* "cc3d.pyx":166 * * if max_labels <= 0: * max_labels = voxels # <<<<<<<<<<<<<< @@ -4495,7 +4507,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ __pyx_v_max_labels = __pyx_v_voxels; - /* "cc3d.pyx":160 + /* "cc3d.pyx":165 * out_labels = out_labels64 * * if max_labels <= 0: # <<<<<<<<<<<<<< @@ -4504,19 +4516,19 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ } - /* "cc3d.pyx":163 + /* "cc3d.pyx":168 * max_labels = voxels * * dtype = data.dtype # <<<<<<<<<<<<<< * * if dtype in (np.uint64, np.int64): */ - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 163, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 168, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_v_dtype = __pyx_t_6; __pyx_t_6 = 0; - /* "cc3d.pyx":165 + /* "cc3d.pyx":170 * dtype = data.dtype * * if dtype in (np.uint64, np.int64): # <<<<<<<<<<<<<< @@ -4525,28 +4537,28 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ __Pyx_INCREF(__pyx_v_dtype); __pyx_t_6 = __pyx_v_dtype; - __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 165, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 170, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_uint64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 165, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_uint64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 170, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = PyObject_RichCompare(__pyx_t_6, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 165, __pyx_L1_error) + __pyx_t_11 = PyObject_RichCompare(__pyx_t_6, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 170, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 165, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 170, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (!__pyx_t_5) { } else { __pyx_t_3 = __pyx_t_5; goto __pyx_L27_bool_binop_done; } - __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 165, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 170, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_int64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 165, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_int64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 170, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = PyObject_RichCompare(__pyx_t_6, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 165, __pyx_L1_error) + __pyx_t_11 = PyObject_RichCompare(__pyx_t_6, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 170, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 165, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 170, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_3 = __pyx_t_5; __pyx_L27_bool_binop_done:; @@ -4554,18 +4566,18 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p __pyx_t_5 = (__pyx_t_3 != 0); if (__pyx_t_5) { - /* "cc3d.pyx":166 + /* "cc3d.pyx":171 * * if dtype in (np.uint64, np.int64): * arr_memview64u = data.view(np.uint64) # <<<<<<<<<<<<<< * if out_dtype == np.uint16: * connected_components3d[uint64_t, uint16_t]( */ - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_view); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 166, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_view); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 171, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 166, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 171, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_uint64); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 166, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_uint64); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 171, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; @@ -4581,34 +4593,34 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p __pyx_t_6 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_11, __pyx_t_1, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 166, __pyx_L1_error) + if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 171, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_18 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_nn_uint64_t(__pyx_t_6, PyBUF_WRITABLE); if (unlikely(!__pyx_t_18.memview)) __PYX_ERR(0, 166, __pyx_L1_error) + __pyx_t_18 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_nn_uint64_t(__pyx_t_6, PyBUF_WRITABLE); if (unlikely(!__pyx_t_18.memview)) __PYX_ERR(0, 171, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_arr_memview64u = __pyx_t_18; __pyx_t_18.memview = NULL; __pyx_t_18.data = NULL; - /* "cc3d.pyx":167 + /* "cc3d.pyx":172 * if dtype in (np.uint64, np.int64): * arr_memview64u = data.view(np.uint64) * if out_dtype == np.uint16: # <<<<<<<<<<<<<< * connected_components3d[uint64_t, uint16_t]( * &arr_memview64u[0,0,0], */ - __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 167, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 172, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uint16); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 167, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uint16); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 172, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_11, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 167, __pyx_L1_error) + __pyx_t_6 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_11, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 172, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 167, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 172, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_5) { - /* "cc3d.pyx":169 + /* "cc3d.pyx":174 * if out_dtype == np.uint16: * connected_components3d[uint64_t, uint16_t]( * &arr_memview64u[0,0,0], # <<<<<<<<<<<<<< @@ -4633,10 +4645,10 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p } else if (unlikely(__pyx_t_21 >= __pyx_v_arr_memview64u.shape[2])) __pyx_t_10 = 2; if (unlikely(__pyx_t_10 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_10); - __PYX_ERR(0, 169, __pyx_L1_error) + __PYX_ERR(0, 174, __pyx_L1_error) } - /* "cc3d.pyx":171 + /* "cc3d.pyx":176 * &arr_memview64u[0,0,0], * sx, sy, sz, max_labels, connectivity, * &out_labels16[0] # <<<<<<<<<<<<<< @@ -4651,10 +4663,10 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p } else if (unlikely(__pyx_t_22 >= __pyx_pybuffernd_out_labels16.diminfo[0].shape)) __pyx_t_10 = 0; if (unlikely(__pyx_t_10 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_10); - __PYX_ERR(0, 171, __pyx_L1_error) + __PYX_ERR(0, 176, __pyx_L1_error) } - /* "cc3d.pyx":168 + /* "cc3d.pyx":173 * arr_memview64u = data.view(np.uint64) * if out_dtype == np.uint16: * connected_components3d[uint64_t, uint16_t]( # <<<<<<<<<<<<<< @@ -4663,7 +4675,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ (void)(cc3d::connected_components3d((&(*((uint64_t *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_arr_memview64u.data + __pyx_t_19 * __pyx_v_arr_memview64u.strides[0]) ) + __pyx_t_20 * __pyx_v_arr_memview64u.strides[1]) ) + __pyx_t_21 * __pyx_v_arr_memview64u.strides[2]) )))), __pyx_v_sx, __pyx_v_sy, __pyx_v_sz, __pyx_v_max_labels, __pyx_v_connectivity, ((uint16_t *)(&(*__Pyx_BufPtrStrided1d(uint16_t *, __pyx_pybuffernd_out_labels16.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_out_labels16.diminfo[0].strides)))))); - /* "cc3d.pyx":167 + /* "cc3d.pyx":172 * if dtype in (np.uint64, np.int64): * arr_memview64u = data.view(np.uint64) * if out_dtype == np.uint16: # <<<<<<<<<<<<<< @@ -4673,25 +4685,25 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p goto __pyx_L29; } - /* "cc3d.pyx":173 + /* "cc3d.pyx":178 * &out_labels16[0] * ) * elif out_dtype == np.uint32: # <<<<<<<<<<<<<< * connected_components3d[uint64_t, uint32_t]( * &arr_memview64u[0,0,0], */ - __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 173, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 178, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uint32); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 173, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uint32); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 178, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_11, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 173, __pyx_L1_error) + __pyx_t_6 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_11, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 178, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 173, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 178, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_5) { - /* "cc3d.pyx":175 + /* "cc3d.pyx":180 * elif out_dtype == np.uint32: * connected_components3d[uint64_t, uint32_t]( * &arr_memview64u[0,0,0], # <<<<<<<<<<<<<< @@ -4716,10 +4728,10 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p } else if (unlikely(__pyx_t_25 >= __pyx_v_arr_memview64u.shape[2])) __pyx_t_10 = 2; if (unlikely(__pyx_t_10 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_10); - __PYX_ERR(0, 175, __pyx_L1_error) + __PYX_ERR(0, 180, __pyx_L1_error) } - /* "cc3d.pyx":177 + /* "cc3d.pyx":182 * &arr_memview64u[0,0,0], * sx, sy, sz, max_labels, connectivity, * &out_labels32[0] # <<<<<<<<<<<<<< @@ -4734,10 +4746,10 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p } else if (unlikely(__pyx_t_26 >= __pyx_pybuffernd_out_labels32.diminfo[0].shape)) __pyx_t_10 = 0; if (unlikely(__pyx_t_10 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_10); - __PYX_ERR(0, 177, __pyx_L1_error) + __PYX_ERR(0, 182, __pyx_L1_error) } - /* "cc3d.pyx":174 + /* "cc3d.pyx":179 * ) * elif out_dtype == np.uint32: * connected_components3d[uint64_t, uint32_t]( # <<<<<<<<<<<<<< @@ -4746,7 +4758,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ (void)(cc3d::connected_components3d((&(*((uint64_t *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_arr_memview64u.data + __pyx_t_23 * __pyx_v_arr_memview64u.strides[0]) ) + __pyx_t_24 * __pyx_v_arr_memview64u.strides[1]) ) + __pyx_t_25 * __pyx_v_arr_memview64u.strides[2]) )))), __pyx_v_sx, __pyx_v_sy, __pyx_v_sz, __pyx_v_max_labels, __pyx_v_connectivity, ((uint32_t *)(&(*__Pyx_BufPtrStrided1d(uint32_t *, __pyx_pybuffernd_out_labels32.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_out_labels32.diminfo[0].strides)))))); - /* "cc3d.pyx":173 + /* "cc3d.pyx":178 * &out_labels16[0] * ) * elif out_dtype == np.uint32: # <<<<<<<<<<<<<< @@ -4756,25 +4768,25 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p goto __pyx_L29; } - /* "cc3d.pyx":179 + /* "cc3d.pyx":184 * &out_labels32[0] * ) * elif out_dtype == np.uint64: # <<<<<<<<<<<<<< * connected_components3d[uint64_t, uint64_t]( * &arr_memview64u[0,0,0], */ - __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 179, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uint64); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 179, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uint64); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_11, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 179, __pyx_L1_error) + __pyx_t_6 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_11, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 184, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 179, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 184, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_5) { - /* "cc3d.pyx":181 + /* "cc3d.pyx":186 * elif out_dtype == np.uint64: * connected_components3d[uint64_t, uint64_t]( * &arr_memview64u[0,0,0], # <<<<<<<<<<<<<< @@ -4799,10 +4811,10 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p } else if (unlikely(__pyx_t_29 >= __pyx_v_arr_memview64u.shape[2])) __pyx_t_10 = 2; if (unlikely(__pyx_t_10 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_10); - __PYX_ERR(0, 181, __pyx_L1_error) + __PYX_ERR(0, 186, __pyx_L1_error) } - /* "cc3d.pyx":183 + /* "cc3d.pyx":188 * &arr_memview64u[0,0,0], * sx, sy, sz, max_labels, connectivity, * &out_labels64[0] # <<<<<<<<<<<<<< @@ -4817,10 +4829,10 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p } else if (unlikely(__pyx_t_30 >= __pyx_pybuffernd_out_labels64.diminfo[0].shape)) __pyx_t_10 = 0; if (unlikely(__pyx_t_10 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_10); - __PYX_ERR(0, 183, __pyx_L1_error) + __PYX_ERR(0, 188, __pyx_L1_error) } - /* "cc3d.pyx":180 + /* "cc3d.pyx":185 * ) * elif out_dtype == np.uint64: * connected_components3d[uint64_t, uint64_t]( # <<<<<<<<<<<<<< @@ -4829,7 +4841,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ (void)(cc3d::connected_components3d((&(*((uint64_t *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_arr_memview64u.data + __pyx_t_27 * __pyx_v_arr_memview64u.strides[0]) ) + __pyx_t_28 * __pyx_v_arr_memview64u.strides[1]) ) + __pyx_t_29 * __pyx_v_arr_memview64u.strides[2]) )))), __pyx_v_sx, __pyx_v_sy, __pyx_v_sz, __pyx_v_max_labels, __pyx_v_connectivity, ((uint64_t *)(&(*__Pyx_BufPtrStrided1d(uint64_t *, __pyx_pybuffernd_out_labels64.rcbuffer->pybuffer.buf, __pyx_t_30, __pyx_pybuffernd_out_labels64.diminfo[0].strides)))))); - /* "cc3d.pyx":179 + /* "cc3d.pyx":184 * &out_labels32[0] * ) * elif out_dtype == np.uint64: # <<<<<<<<<<<<<< @@ -4839,7 +4851,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p } __pyx_L29:; - /* "cc3d.pyx":165 + /* "cc3d.pyx":170 * dtype = data.dtype * * if dtype in (np.uint64, np.int64): # <<<<<<<<<<<<<< @@ -4849,7 +4861,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p goto __pyx_L26; } - /* "cc3d.pyx":185 + /* "cc3d.pyx":190 * &out_labels64[0] * ) * elif dtype in (np.uint32, np.int32): # <<<<<<<<<<<<<< @@ -4858,28 +4870,28 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ __Pyx_INCREF(__pyx_v_dtype); __pyx_t_6 = __pyx_v_dtype; - __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 185, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_uint32); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 185, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_uint32); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = PyObject_RichCompare(__pyx_t_6, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 185, __pyx_L1_error) + __pyx_t_11 = PyObject_RichCompare(__pyx_t_6, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 185, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (!__pyx_t_3) { } else { __pyx_t_5 = __pyx_t_3; goto __pyx_L30_bool_binop_done; } - __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 185, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_int32); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 185, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_int32); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = PyObject_RichCompare(__pyx_t_6, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 185, __pyx_L1_error) + __pyx_t_11 = PyObject_RichCompare(__pyx_t_6, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 185, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_5 = __pyx_t_3; __pyx_L30_bool_binop_done:; @@ -4887,18 +4899,18 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p __pyx_t_3 = (__pyx_t_5 != 0); if (__pyx_t_3) { - /* "cc3d.pyx":186 + /* "cc3d.pyx":191 * ) * elif dtype in (np.uint32, np.int32): * arr_memview32u = data.view(np.uint32) # <<<<<<<<<<<<<< * if out_dtype == np.uint16: * connected_components3d[uint32_t, uint16_t]( */ - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_view); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 186, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_view); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 191, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 186, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 191, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_uint32); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 186, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_uint32); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 191, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; @@ -4914,34 +4926,34 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p __pyx_t_6 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_11, __pyx_t_4, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 186, __pyx_L1_error) + if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 191, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_31 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_nn_uint32_t(__pyx_t_6, PyBUF_WRITABLE); if (unlikely(!__pyx_t_31.memview)) __PYX_ERR(0, 186, __pyx_L1_error) + __pyx_t_31 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_nn_uint32_t(__pyx_t_6, PyBUF_WRITABLE); if (unlikely(!__pyx_t_31.memview)) __PYX_ERR(0, 191, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_arr_memview32u = __pyx_t_31; __pyx_t_31.memview = NULL; __pyx_t_31.data = NULL; - /* "cc3d.pyx":187 + /* "cc3d.pyx":192 * elif dtype in (np.uint32, np.int32): * arr_memview32u = data.view(np.uint32) * if out_dtype == np.uint16: # <<<<<<<<<<<<<< * connected_components3d[uint32_t, uint16_t]( * &arr_memview32u[0,0,0], */ - __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 187, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 192, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uint16); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 187, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uint16); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 192, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_11, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 187, __pyx_L1_error) + __pyx_t_6 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_11, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 192, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 187, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 192, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_3) { - /* "cc3d.pyx":189 + /* "cc3d.pyx":194 * if out_dtype == np.uint16: * connected_components3d[uint32_t, uint16_t]( * &arr_memview32u[0,0,0], # <<<<<<<<<<<<<< @@ -4966,10 +4978,10 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p } else if (unlikely(__pyx_t_34 >= __pyx_v_arr_memview32u.shape[2])) __pyx_t_10 = 2; if (unlikely(__pyx_t_10 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_10); - __PYX_ERR(0, 189, __pyx_L1_error) + __PYX_ERR(0, 194, __pyx_L1_error) } - /* "cc3d.pyx":191 + /* "cc3d.pyx":196 * &arr_memview32u[0,0,0], * sx, sy, sz, max_labels, connectivity, * &out_labels16[0] # <<<<<<<<<<<<<< @@ -4984,10 +4996,10 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p } else if (unlikely(__pyx_t_35 >= __pyx_pybuffernd_out_labels16.diminfo[0].shape)) __pyx_t_10 = 0; if (unlikely(__pyx_t_10 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_10); - __PYX_ERR(0, 191, __pyx_L1_error) + __PYX_ERR(0, 196, __pyx_L1_error) } - /* "cc3d.pyx":188 + /* "cc3d.pyx":193 * arr_memview32u = data.view(np.uint32) * if out_dtype == np.uint16: * connected_components3d[uint32_t, uint16_t]( # <<<<<<<<<<<<<< @@ -4996,7 +5008,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ (void)(cc3d::connected_components3d((&(*((uint32_t *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_arr_memview32u.data + __pyx_t_32 * __pyx_v_arr_memview32u.strides[0]) ) + __pyx_t_33 * __pyx_v_arr_memview32u.strides[1]) ) + __pyx_t_34 * __pyx_v_arr_memview32u.strides[2]) )))), __pyx_v_sx, __pyx_v_sy, __pyx_v_sz, __pyx_v_max_labels, __pyx_v_connectivity, ((uint16_t *)(&(*__Pyx_BufPtrStrided1d(uint16_t *, __pyx_pybuffernd_out_labels16.rcbuffer->pybuffer.buf, __pyx_t_35, __pyx_pybuffernd_out_labels16.diminfo[0].strides)))))); - /* "cc3d.pyx":187 + /* "cc3d.pyx":192 * elif dtype in (np.uint32, np.int32): * arr_memview32u = data.view(np.uint32) * if out_dtype == np.uint16: # <<<<<<<<<<<<<< @@ -5006,25 +5018,25 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p goto __pyx_L32; } - /* "cc3d.pyx":193 + /* "cc3d.pyx":198 * &out_labels16[0] * ) * elif out_dtype == np.uint32: # <<<<<<<<<<<<<< * connected_components3d[uint32_t, uint32_t]( * &arr_memview32u[0,0,0], */ - __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 193, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uint32); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 193, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uint32); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_11, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 193, __pyx_L1_error) + __pyx_t_6 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_11, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 198, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 193, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 198, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_3) { - /* "cc3d.pyx":195 + /* "cc3d.pyx":200 * elif out_dtype == np.uint32: * connected_components3d[uint32_t, uint32_t]( * &arr_memview32u[0,0,0], # <<<<<<<<<<<<<< @@ -5049,10 +5061,10 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p } else if (unlikely(__pyx_t_38 >= __pyx_v_arr_memview32u.shape[2])) __pyx_t_10 = 2; if (unlikely(__pyx_t_10 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_10); - __PYX_ERR(0, 195, __pyx_L1_error) + __PYX_ERR(0, 200, __pyx_L1_error) } - /* "cc3d.pyx":197 + /* "cc3d.pyx":202 * &arr_memview32u[0,0,0], * sx, sy, sz, max_labels, connectivity, * &out_labels32[0] # <<<<<<<<<<<<<< @@ -5067,10 +5079,10 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p } else if (unlikely(__pyx_t_39 >= __pyx_pybuffernd_out_labels32.diminfo[0].shape)) __pyx_t_10 = 0; if (unlikely(__pyx_t_10 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_10); - __PYX_ERR(0, 197, __pyx_L1_error) + __PYX_ERR(0, 202, __pyx_L1_error) } - /* "cc3d.pyx":194 + /* "cc3d.pyx":199 * ) * elif out_dtype == np.uint32: * connected_components3d[uint32_t, uint32_t]( # <<<<<<<<<<<<<< @@ -5079,7 +5091,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ (void)(cc3d::connected_components3d((&(*((uint32_t *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_arr_memview32u.data + __pyx_t_36 * __pyx_v_arr_memview32u.strides[0]) ) + __pyx_t_37 * __pyx_v_arr_memview32u.strides[1]) ) + __pyx_t_38 * __pyx_v_arr_memview32u.strides[2]) )))), __pyx_v_sx, __pyx_v_sy, __pyx_v_sz, __pyx_v_max_labels, __pyx_v_connectivity, ((uint32_t *)(&(*__Pyx_BufPtrStrided1d(uint32_t *, __pyx_pybuffernd_out_labels32.rcbuffer->pybuffer.buf, __pyx_t_39, __pyx_pybuffernd_out_labels32.diminfo[0].strides)))))); - /* "cc3d.pyx":193 + /* "cc3d.pyx":198 * &out_labels16[0] * ) * elif out_dtype == np.uint32: # <<<<<<<<<<<<<< @@ -5089,25 +5101,25 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p goto __pyx_L32; } - /* "cc3d.pyx":199 + /* "cc3d.pyx":204 * &out_labels32[0] * ) * elif out_dtype == np.uint64: # <<<<<<<<<<<<<< * connected_components3d[uint32_t, uint64_t]( * &arr_memview32u[0,0,0], */ - __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 199, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 204, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uint64); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 199, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uint64); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 204, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_11, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 199, __pyx_L1_error) + __pyx_t_6 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_11, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 204, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 199, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 204, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_3) { - /* "cc3d.pyx":201 + /* "cc3d.pyx":206 * elif out_dtype == np.uint64: * connected_components3d[uint32_t, uint64_t]( * &arr_memview32u[0,0,0], # <<<<<<<<<<<<<< @@ -5132,10 +5144,10 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p } else if (unlikely(__pyx_t_42 >= __pyx_v_arr_memview32u.shape[2])) __pyx_t_10 = 2; if (unlikely(__pyx_t_10 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_10); - __PYX_ERR(0, 201, __pyx_L1_error) + __PYX_ERR(0, 206, __pyx_L1_error) } - /* "cc3d.pyx":203 + /* "cc3d.pyx":208 * &arr_memview32u[0,0,0], * sx, sy, sz, max_labels, connectivity, * &out_labels64[0] # <<<<<<<<<<<<<< @@ -5150,10 +5162,10 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p } else if (unlikely(__pyx_t_43 >= __pyx_pybuffernd_out_labels64.diminfo[0].shape)) __pyx_t_10 = 0; if (unlikely(__pyx_t_10 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_10); - __PYX_ERR(0, 203, __pyx_L1_error) + __PYX_ERR(0, 208, __pyx_L1_error) } - /* "cc3d.pyx":200 + /* "cc3d.pyx":205 * ) * elif out_dtype == np.uint64: * connected_components3d[uint32_t, uint64_t]( # <<<<<<<<<<<<<< @@ -5162,7 +5174,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ (void)(cc3d::connected_components3d((&(*((uint32_t *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_arr_memview32u.data + __pyx_t_40 * __pyx_v_arr_memview32u.strides[0]) ) + __pyx_t_41 * __pyx_v_arr_memview32u.strides[1]) ) + __pyx_t_42 * __pyx_v_arr_memview32u.strides[2]) )))), __pyx_v_sx, __pyx_v_sy, __pyx_v_sz, __pyx_v_max_labels, __pyx_v_connectivity, ((uint64_t *)(&(*__Pyx_BufPtrStrided1d(uint64_t *, __pyx_pybuffernd_out_labels64.rcbuffer->pybuffer.buf, __pyx_t_43, __pyx_pybuffernd_out_labels64.diminfo[0].strides)))))); - /* "cc3d.pyx":199 + /* "cc3d.pyx":204 * &out_labels32[0] * ) * elif out_dtype == np.uint64: # <<<<<<<<<<<<<< @@ -5172,7 +5184,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p } __pyx_L32:; - /* "cc3d.pyx":185 + /* "cc3d.pyx":190 * &out_labels64[0] * ) * elif dtype in (np.uint32, np.int32): # <<<<<<<<<<<<<< @@ -5182,7 +5194,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p goto __pyx_L26; } - /* "cc3d.pyx":205 + /* "cc3d.pyx":210 * &out_labels64[0] * ) * elif dtype in (np.uint16, np.int16): # <<<<<<<<<<<<<< @@ -5191,28 +5203,28 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ __Pyx_INCREF(__pyx_v_dtype); __pyx_t_6 = __pyx_v_dtype; - __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 205, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 210, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_uint16); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 205, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_uint16); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 210, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = PyObject_RichCompare(__pyx_t_6, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 205, __pyx_L1_error) + __pyx_t_11 = PyObject_RichCompare(__pyx_t_6, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 210, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 205, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 210, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (!__pyx_t_5) { } else { __pyx_t_3 = __pyx_t_5; goto __pyx_L33_bool_binop_done; } - __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 205, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 210, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_int16); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 205, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_int16); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 210, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = PyObject_RichCompare(__pyx_t_6, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 205, __pyx_L1_error) + __pyx_t_11 = PyObject_RichCompare(__pyx_t_6, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 210, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 205, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 210, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_3 = __pyx_t_5; __pyx_L33_bool_binop_done:; @@ -5220,18 +5232,18 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p __pyx_t_5 = (__pyx_t_3 != 0); if (__pyx_t_5) { - /* "cc3d.pyx":206 + /* "cc3d.pyx":211 * ) * elif dtype in (np.uint16, np.int16): * arr_memview16u = data.view(np.uint16) # <<<<<<<<<<<<<< * if out_dtype == np.uint16: * connected_components3d[uint16_t, uint16_t]( */ - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_view); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 206, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_view); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 211, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 206, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_uint16); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 206, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_uint16); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 211, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; @@ -5247,34 +5259,34 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p __pyx_t_6 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_11, __pyx_t_1, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 206, __pyx_L1_error) + if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 211, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_44 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_nn_uint16_t(__pyx_t_6, PyBUF_WRITABLE); if (unlikely(!__pyx_t_44.memview)) __PYX_ERR(0, 206, __pyx_L1_error) + __pyx_t_44 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_nn_uint16_t(__pyx_t_6, PyBUF_WRITABLE); if (unlikely(!__pyx_t_44.memview)) __PYX_ERR(0, 211, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_arr_memview16u = __pyx_t_44; __pyx_t_44.memview = NULL; __pyx_t_44.data = NULL; - /* "cc3d.pyx":207 + /* "cc3d.pyx":212 * elif dtype in (np.uint16, np.int16): * arr_memview16u = data.view(np.uint16) * if out_dtype == np.uint16: # <<<<<<<<<<<<<< * connected_components3d[uint16_t, uint16_t]( * &arr_memview16u[0,0,0], */ - __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 207, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 212, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uint16); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 207, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uint16); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 212, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_11, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 207, __pyx_L1_error) + __pyx_t_6 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_11, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 212, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 207, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 212, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_5) { - /* "cc3d.pyx":209 + /* "cc3d.pyx":214 * if out_dtype == np.uint16: * connected_components3d[uint16_t, uint16_t]( * &arr_memview16u[0,0,0], # <<<<<<<<<<<<<< @@ -5299,10 +5311,10 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p } else if (unlikely(__pyx_t_47 >= __pyx_v_arr_memview16u.shape[2])) __pyx_t_10 = 2; if (unlikely(__pyx_t_10 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_10); - __PYX_ERR(0, 209, __pyx_L1_error) + __PYX_ERR(0, 214, __pyx_L1_error) } - /* "cc3d.pyx":211 + /* "cc3d.pyx":216 * &arr_memview16u[0,0,0], * sx, sy, sz, max_labels, connectivity, * &out_labels16[0] # <<<<<<<<<<<<<< @@ -5317,10 +5329,10 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p } else if (unlikely(__pyx_t_48 >= __pyx_pybuffernd_out_labels16.diminfo[0].shape)) __pyx_t_10 = 0; if (unlikely(__pyx_t_10 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_10); - __PYX_ERR(0, 211, __pyx_L1_error) + __PYX_ERR(0, 216, __pyx_L1_error) } - /* "cc3d.pyx":208 + /* "cc3d.pyx":213 * arr_memview16u = data.view(np.uint16) * if out_dtype == np.uint16: * connected_components3d[uint16_t, uint16_t]( # <<<<<<<<<<<<<< @@ -5329,7 +5341,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ (void)(cc3d::connected_components3d((&(*((uint16_t *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_arr_memview16u.data + __pyx_t_45 * __pyx_v_arr_memview16u.strides[0]) ) + __pyx_t_46 * __pyx_v_arr_memview16u.strides[1]) ) + __pyx_t_47 * __pyx_v_arr_memview16u.strides[2]) )))), __pyx_v_sx, __pyx_v_sy, __pyx_v_sz, __pyx_v_max_labels, __pyx_v_connectivity, ((uint16_t *)(&(*__Pyx_BufPtrStrided1d(uint16_t *, __pyx_pybuffernd_out_labels16.rcbuffer->pybuffer.buf, __pyx_t_48, __pyx_pybuffernd_out_labels16.diminfo[0].strides)))))); - /* "cc3d.pyx":207 + /* "cc3d.pyx":212 * elif dtype in (np.uint16, np.int16): * arr_memview16u = data.view(np.uint16) * if out_dtype == np.uint16: # <<<<<<<<<<<<<< @@ -5339,25 +5351,25 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p goto __pyx_L35; } - /* "cc3d.pyx":213 + /* "cc3d.pyx":218 * &out_labels16[0] * ) * elif out_dtype == np.uint32: # <<<<<<<<<<<<<< * connected_components3d[uint16_t, uint32_t]( * &arr_memview16u[0,0,0], */ - __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 213, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uint32); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 213, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uint32); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_11, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 213, __pyx_L1_error) + __pyx_t_6 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_11, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 218, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 213, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 218, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_5) { - /* "cc3d.pyx":215 + /* "cc3d.pyx":220 * elif out_dtype == np.uint32: * connected_components3d[uint16_t, uint32_t]( * &arr_memview16u[0,0,0], # <<<<<<<<<<<<<< @@ -5382,10 +5394,10 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p } else if (unlikely(__pyx_t_51 >= __pyx_v_arr_memview16u.shape[2])) __pyx_t_10 = 2; if (unlikely(__pyx_t_10 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_10); - __PYX_ERR(0, 215, __pyx_L1_error) + __PYX_ERR(0, 220, __pyx_L1_error) } - /* "cc3d.pyx":217 + /* "cc3d.pyx":222 * &arr_memview16u[0,0,0], * sx, sy, sz, max_labels, connectivity, * &out_labels32[0] # <<<<<<<<<<<<<< @@ -5400,10 +5412,10 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p } else if (unlikely(__pyx_t_52 >= __pyx_pybuffernd_out_labels32.diminfo[0].shape)) __pyx_t_10 = 0; if (unlikely(__pyx_t_10 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_10); - __PYX_ERR(0, 217, __pyx_L1_error) + __PYX_ERR(0, 222, __pyx_L1_error) } - /* "cc3d.pyx":214 + /* "cc3d.pyx":219 * ) * elif out_dtype == np.uint32: * connected_components3d[uint16_t, uint32_t]( # <<<<<<<<<<<<<< @@ -5412,7 +5424,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ (void)(cc3d::connected_components3d((&(*((uint16_t *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_arr_memview16u.data + __pyx_t_49 * __pyx_v_arr_memview16u.strides[0]) ) + __pyx_t_50 * __pyx_v_arr_memview16u.strides[1]) ) + __pyx_t_51 * __pyx_v_arr_memview16u.strides[2]) )))), __pyx_v_sx, __pyx_v_sy, __pyx_v_sz, __pyx_v_max_labels, __pyx_v_connectivity, ((uint32_t *)(&(*__Pyx_BufPtrStrided1d(uint32_t *, __pyx_pybuffernd_out_labels32.rcbuffer->pybuffer.buf, __pyx_t_52, __pyx_pybuffernd_out_labels32.diminfo[0].strides)))))); - /* "cc3d.pyx":213 + /* "cc3d.pyx":218 * &out_labels16[0] * ) * elif out_dtype == np.uint32: # <<<<<<<<<<<<<< @@ -5422,25 +5434,25 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p goto __pyx_L35; } - /* "cc3d.pyx":219 + /* "cc3d.pyx":224 * &out_labels32[0] * ) * elif out_dtype == np.uint64: # <<<<<<<<<<<<<< * connected_components3d[uint16_t, uint64_t]( * &arr_memview16u[0,0,0], */ - __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 219, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 224, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uint64); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 219, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uint64); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 224, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_11, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 219, __pyx_L1_error) + __pyx_t_6 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_11, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 224, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 219, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 224, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_5) { - /* "cc3d.pyx":221 + /* "cc3d.pyx":226 * elif out_dtype == np.uint64: * connected_components3d[uint16_t, uint64_t]( * &arr_memview16u[0,0,0], # <<<<<<<<<<<<<< @@ -5465,15 +5477,15 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p } else if (unlikely(__pyx_t_55 >= __pyx_v_arr_memview16u.shape[2])) __pyx_t_10 = 2; if (unlikely(__pyx_t_10 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_10); - __PYX_ERR(0, 221, __pyx_L1_error) + __PYX_ERR(0, 226, __pyx_L1_error) } - /* "cc3d.pyx":223 + /* "cc3d.pyx":228 * &arr_memview16u[0,0,0], * sx, sy, sz, max_labels, connectivity, * &out_labels64[0] # <<<<<<<<<<<<<< * ) - * elif dtype in (np.uint8, np.int8, np.bool): + * elif dtype in (np.uint8, np.int8) or (dtype == np.bool and connectivity != 8): */ __pyx_t_56 = 0; __pyx_t_10 = -1; @@ -5483,10 +5495,10 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p } else if (unlikely(__pyx_t_56 >= __pyx_pybuffernd_out_labels64.diminfo[0].shape)) __pyx_t_10 = 0; if (unlikely(__pyx_t_10 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_10); - __PYX_ERR(0, 223, __pyx_L1_error) + __PYX_ERR(0, 228, __pyx_L1_error) } - /* "cc3d.pyx":220 + /* "cc3d.pyx":225 * ) * elif out_dtype == np.uint64: * connected_components3d[uint16_t, uint64_t]( # <<<<<<<<<<<<<< @@ -5495,7 +5507,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ (void)(cc3d::connected_components3d((&(*((uint16_t *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_arr_memview16u.data + __pyx_t_53 * __pyx_v_arr_memview16u.strides[0]) ) + __pyx_t_54 * __pyx_v_arr_memview16u.strides[1]) ) + __pyx_t_55 * __pyx_v_arr_memview16u.strides[2]) )))), __pyx_v_sx, __pyx_v_sy, __pyx_v_sz, __pyx_v_max_labels, __pyx_v_connectivity, ((uint64_t *)(&(*__Pyx_BufPtrStrided1d(uint64_t *, __pyx_pybuffernd_out_labels64.rcbuffer->pybuffer.buf, __pyx_t_56, __pyx_pybuffernd_out_labels64.diminfo[0].strides)))))); - /* "cc3d.pyx":219 + /* "cc3d.pyx":224 * &out_labels32[0] * ) * elif out_dtype == np.uint64: # <<<<<<<<<<<<<< @@ -5505,7 +5517,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p } __pyx_L35:; - /* "cc3d.pyx":205 + /* "cc3d.pyx":210 * &out_labels64[0] * ) * elif dtype in (np.uint16, np.int16): # <<<<<<<<<<<<<< @@ -5515,70 +5527,78 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p goto __pyx_L26; } - /* "cc3d.pyx":225 + /* "cc3d.pyx":230 * &out_labels64[0] * ) - * elif dtype in (np.uint8, np.int8, np.bool): # <<<<<<<<<<<<<< + * elif dtype in (np.uint8, np.int8) or (dtype == np.bool and connectivity != 8): # <<<<<<<<<<<<<< * arr_memview8u = data.view(np.uint8) * if out_dtype == np.uint16: */ __Pyx_INCREF(__pyx_v_dtype); __pyx_t_6 = __pyx_v_dtype; - __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 225, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 230, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_uint8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 225, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_uint8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 230, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = PyObject_RichCompare(__pyx_t_6, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 225, __pyx_L1_error) + __pyx_t_11 = PyObject_RichCompare(__pyx_t_6, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 230, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 225, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 230, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - if (!__pyx_t_3) { + if (!__pyx_t_8) { } else { - __pyx_t_5 = __pyx_t_3; - goto __pyx_L36_bool_binop_done; + __pyx_t_3 = __pyx_t_8; + goto __pyx_L38_bool_binop_done; } - __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 225, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 230, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_int8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 225, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_int8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 230, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = PyObject_RichCompare(__pyx_t_6, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 225, __pyx_L1_error) + __pyx_t_11 = PyObject_RichCompare(__pyx_t_6, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 230, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 225, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 230, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - if (!__pyx_t_3) { + __pyx_t_3 = __pyx_t_8; + __pyx_L38_bool_binop_done:; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_8 = (__pyx_t_3 != 0); + if (!__pyx_t_8) { } else { - __pyx_t_5 = __pyx_t_3; + __pyx_t_5 = __pyx_t_8; goto __pyx_L36_bool_binop_done; } - __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 225, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 230, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_bool); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 230, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_bool); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 225, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = PyObject_RichCompare(__pyx_t_6, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 225, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 225, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_11, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 230, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_5 = __pyx_t_3; - __pyx_L36_bool_binop_done:; + __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 230, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_3 = (__pyx_t_5 != 0); - if (likely(__pyx_t_3)) { + if (__pyx_t_8) { + } else { + __pyx_t_5 = __pyx_t_8; + goto __pyx_L36_bool_binop_done; + } + __pyx_t_8 = ((__pyx_v_connectivity != 8) != 0); + __pyx_t_5 = __pyx_t_8; + __pyx_L36_bool_binop_done:; + if (__pyx_t_5) { - /* "cc3d.pyx":226 + /* "cc3d.pyx":231 * ) - * elif dtype in (np.uint8, np.int8, np.bool): + * elif dtype in (np.uint8, np.int8) or (dtype == np.bool and connectivity != 8): * arr_memview8u = data.view(np.uint8) # <<<<<<<<<<<<<< * if out_dtype == np.uint16: * connected_components3d[uint8_t, uint16_t]( */ - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_view); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 226, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_view); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 231, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 226, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 231, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_uint8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 226, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_uint8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 231, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; @@ -5594,34 +5614,34 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p __pyx_t_6 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_11, __pyx_t_4, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 226, __pyx_L1_error) + if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 231, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_57 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_nn_uint8_t(__pyx_t_6, PyBUF_WRITABLE); if (unlikely(!__pyx_t_57.memview)) __PYX_ERR(0, 226, __pyx_L1_error) + __pyx_t_57 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_nn_uint8_t(__pyx_t_6, PyBUF_WRITABLE); if (unlikely(!__pyx_t_57.memview)) __PYX_ERR(0, 231, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_arr_memview8u = __pyx_t_57; __pyx_t_57.memview = NULL; __pyx_t_57.data = NULL; - /* "cc3d.pyx":227 - * elif dtype in (np.uint8, np.int8, np.bool): + /* "cc3d.pyx":232 + * elif dtype in (np.uint8, np.int8) or (dtype == np.bool and connectivity != 8): * arr_memview8u = data.view(np.uint8) * if out_dtype == np.uint16: # <<<<<<<<<<<<<< * connected_components3d[uint8_t, uint16_t]( * &arr_memview8u[0,0,0], */ - __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 227, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 232, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uint16); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 227, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uint16); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 232, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_11, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 227, __pyx_L1_error) + __pyx_t_6 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_11, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 232, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 227, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 232, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (__pyx_t_3) { + if (__pyx_t_5) { - /* "cc3d.pyx":229 + /* "cc3d.pyx":234 * if out_dtype == np.uint16: * connected_components3d[uint8_t, uint16_t]( * &arr_memview8u[0,0,0], # <<<<<<<<<<<<<< @@ -5646,10 +5666,10 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p } else if (unlikely(__pyx_t_60 >= __pyx_v_arr_memview8u.shape[2])) __pyx_t_10 = 2; if (unlikely(__pyx_t_10 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_10); - __PYX_ERR(0, 229, __pyx_L1_error) + __PYX_ERR(0, 234, __pyx_L1_error) } - /* "cc3d.pyx":231 + /* "cc3d.pyx":236 * &arr_memview8u[0,0,0], * sx, sy, sz, max_labels, connectivity, * &out_labels16[0] # <<<<<<<<<<<<<< @@ -5664,10 +5684,10 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p } else if (unlikely(__pyx_t_61 >= __pyx_pybuffernd_out_labels16.diminfo[0].shape)) __pyx_t_10 = 0; if (unlikely(__pyx_t_10 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_10); - __PYX_ERR(0, 231, __pyx_L1_error) + __PYX_ERR(0, 236, __pyx_L1_error) } - /* "cc3d.pyx":228 + /* "cc3d.pyx":233 * arr_memview8u = data.view(np.uint8) * if out_dtype == np.uint16: * connected_components3d[uint8_t, uint16_t]( # <<<<<<<<<<<<<< @@ -5676,35 +5696,35 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ (void)(cc3d::connected_components3d((&(*((uint8_t *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_arr_memview8u.data + __pyx_t_58 * __pyx_v_arr_memview8u.strides[0]) ) + __pyx_t_59 * __pyx_v_arr_memview8u.strides[1]) ) + __pyx_t_60 * __pyx_v_arr_memview8u.strides[2]) )))), __pyx_v_sx, __pyx_v_sy, __pyx_v_sz, __pyx_v_max_labels, __pyx_v_connectivity, ((uint16_t *)(&(*__Pyx_BufPtrStrided1d(uint16_t *, __pyx_pybuffernd_out_labels16.rcbuffer->pybuffer.buf, __pyx_t_61, __pyx_pybuffernd_out_labels16.diminfo[0].strides)))))); - /* "cc3d.pyx":227 - * elif dtype in (np.uint8, np.int8, np.bool): + /* "cc3d.pyx":232 + * elif dtype in (np.uint8, np.int8) or (dtype == np.bool and connectivity != 8): * arr_memview8u = data.view(np.uint8) * if out_dtype == np.uint16: # <<<<<<<<<<<<<< * connected_components3d[uint8_t, uint16_t]( * &arr_memview8u[0,0,0], */ - goto __pyx_L39; + goto __pyx_L41; } - /* "cc3d.pyx":233 + /* "cc3d.pyx":238 * &out_labels16[0] * ) * elif out_dtype == np.uint32: # <<<<<<<<<<<<<< * connected_components3d[uint8_t, uint32_t]( * &arr_memview8u[0,0,0], */ - __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 233, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 238, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uint32); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 233, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uint32); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 238, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_11, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 233, __pyx_L1_error) + __pyx_t_6 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_11, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 238, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 233, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 238, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (__pyx_t_3) { + if (__pyx_t_5) { - /* "cc3d.pyx":235 + /* "cc3d.pyx":240 * elif out_dtype == np.uint32: * connected_components3d[uint8_t, uint32_t]( * &arr_memview8u[0,0,0], # <<<<<<<<<<<<<< @@ -5729,10 +5749,10 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p } else if (unlikely(__pyx_t_64 >= __pyx_v_arr_memview8u.shape[2])) __pyx_t_10 = 2; if (unlikely(__pyx_t_10 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_10); - __PYX_ERR(0, 235, __pyx_L1_error) + __PYX_ERR(0, 240, __pyx_L1_error) } - /* "cc3d.pyx":237 + /* "cc3d.pyx":242 * &arr_memview8u[0,0,0], * sx, sy, sz, max_labels, connectivity, * &out_labels32[0] # <<<<<<<<<<<<<< @@ -5747,10 +5767,10 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p } else if (unlikely(__pyx_t_65 >= __pyx_pybuffernd_out_labels32.diminfo[0].shape)) __pyx_t_10 = 0; if (unlikely(__pyx_t_10 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_10); - __PYX_ERR(0, 237, __pyx_L1_error) + __PYX_ERR(0, 242, __pyx_L1_error) } - /* "cc3d.pyx":234 + /* "cc3d.pyx":239 * ) * elif out_dtype == np.uint32: * connected_components3d[uint8_t, uint32_t]( # <<<<<<<<<<<<<< @@ -5759,35 +5779,35 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ (void)(cc3d::connected_components3d((&(*((uint8_t *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_arr_memview8u.data + __pyx_t_62 * __pyx_v_arr_memview8u.strides[0]) ) + __pyx_t_63 * __pyx_v_arr_memview8u.strides[1]) ) + __pyx_t_64 * __pyx_v_arr_memview8u.strides[2]) )))), __pyx_v_sx, __pyx_v_sy, __pyx_v_sz, __pyx_v_max_labels, __pyx_v_connectivity, ((uint32_t *)(&(*__Pyx_BufPtrStrided1d(uint32_t *, __pyx_pybuffernd_out_labels32.rcbuffer->pybuffer.buf, __pyx_t_65, __pyx_pybuffernd_out_labels32.diminfo[0].strides)))))); - /* "cc3d.pyx":233 + /* "cc3d.pyx":238 * &out_labels16[0] * ) * elif out_dtype == np.uint32: # <<<<<<<<<<<<<< * connected_components3d[uint8_t, uint32_t]( * &arr_memview8u[0,0,0], */ - goto __pyx_L39; + goto __pyx_L41; } - /* "cc3d.pyx":239 + /* "cc3d.pyx":244 * &out_labels32[0] * ) * elif out_dtype == np.uint64: # <<<<<<<<<<<<<< * connected_components3d[uint8_t, uint64_t]( * &arr_memview8u[0,0,0], */ - __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 239, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 244, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uint64); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 239, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uint64); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 244, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_11, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 239, __pyx_L1_error) + __pyx_t_6 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_11, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 244, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 239, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 244, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (__pyx_t_3) { + if (__pyx_t_5) { - /* "cc3d.pyx":241 + /* "cc3d.pyx":246 * elif out_dtype == np.uint64: * connected_components3d[uint8_t, uint64_t]( * &arr_memview8u[0,0,0], # <<<<<<<<<<<<<< @@ -5812,15 +5832,15 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p } else if (unlikely(__pyx_t_68 >= __pyx_v_arr_memview8u.shape[2])) __pyx_t_10 = 2; if (unlikely(__pyx_t_10 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_10); - __PYX_ERR(0, 241, __pyx_L1_error) + __PYX_ERR(0, 246, __pyx_L1_error) } - /* "cc3d.pyx":243 + /* "cc3d.pyx":248 * &arr_memview8u[0,0,0], * sx, sy, sz, max_labels, connectivity, * &out_labels64[0] # <<<<<<<<<<<<<< * ) - * else: + * elif dtype == np.bool and connectivity == 8: */ __pyx_t_69 = 0; __pyx_t_10 = -1; @@ -5830,10 +5850,10 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p } else if (unlikely(__pyx_t_69 >= __pyx_pybuffernd_out_labels64.diminfo[0].shape)) __pyx_t_10 = 0; if (unlikely(__pyx_t_10 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_10); - __PYX_ERR(0, 243, __pyx_L1_error) + __PYX_ERR(0, 248, __pyx_L1_error) } - /* "cc3d.pyx":240 + /* "cc3d.pyx":245 * ) * elif out_dtype == np.uint64: * connected_components3d[uint8_t, uint64_t]( # <<<<<<<<<<<<<< @@ -5842,7 +5862,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ (void)(cc3d::connected_components3d((&(*((uint8_t *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_arr_memview8u.data + __pyx_t_66 * __pyx_v_arr_memview8u.strides[0]) ) + __pyx_t_67 * __pyx_v_arr_memview8u.strides[1]) ) + __pyx_t_68 * __pyx_v_arr_memview8u.strides[2]) )))), __pyx_v_sx, __pyx_v_sy, __pyx_v_sz, __pyx_v_max_labels, __pyx_v_connectivity, ((uint64_t *)(&(*__Pyx_BufPtrStrided1d(uint64_t *, __pyx_pybuffernd_out_labels64.rcbuffer->pybuffer.buf, __pyx_t_69, __pyx_pybuffernd_out_labels64.diminfo[0].strides)))))); - /* "cc3d.pyx":239 + /* "cc3d.pyx":244 * &out_labels32[0] * ) * elif out_dtype == np.uint64: # <<<<<<<<<<<<<< @@ -5850,28 +5870,58 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p * &arr_memview8u[0,0,0], */ } - __pyx_L39:; + __pyx_L41:; - /* "cc3d.pyx":225 + /* "cc3d.pyx":230 * &out_labels64[0] * ) - * elif dtype in (np.uint8, np.int8, np.bool): # <<<<<<<<<<<<<< + * elif dtype in (np.uint8, np.int8) or (dtype == np.bool and connectivity != 8): # <<<<<<<<<<<<<< * arr_memview8u = data.view(np.uint8) * if out_dtype == np.uint16: */ goto __pyx_L26; } - /* "cc3d.pyx":246 + /* "cc3d.pyx":250 + * &out_labels64[0] * ) - * else: - * raise TypeError("Type {} not currently supported.".format(dtype)) # <<<<<<<<<<<<<< - * - * if dims == 3: + * elif dtype == np.bool and connectivity == 8: # <<<<<<<<<<<<<< + * arr_memview8u = data.view(np.uint8) + * if out_dtype == np.uint16: */ - /*else*/ { - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Type_not_currently_supported, __pyx_n_s_format); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 246, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 250, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_bool); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 250, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_11, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 250, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 250, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (__pyx_t_8) { + } else { + __pyx_t_5 = __pyx_t_8; + goto __pyx_L42_bool_binop_done; + } + __pyx_t_8 = ((__pyx_v_connectivity == 8) != 0); + __pyx_t_5 = __pyx_t_8; + __pyx_L42_bool_binop_done:; + if (likely(__pyx_t_5)) { + + /* "cc3d.pyx":251 + * ) + * elif dtype == np.bool and connectivity == 8: + * arr_memview8u = data.view(np.uint8) # <<<<<<<<<<<<<< + * if out_dtype == np.uint16: + * connected_components2d_8_bbdt[uint8_t, uint16_t]( + */ + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_view); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 251, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 251, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_uint8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 251, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_11); @@ -5882,45 +5932,336 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p __Pyx_DECREF_SET(__pyx_t_11, function); } } - __pyx_t_6 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_11, __pyx_t_1, __pyx_v_dtype) : __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_v_dtype); + __pyx_t_6 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_11, __pyx_t_1, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 246, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 251, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 246, __pyx_L1_error) + __pyx_t_57 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_nn_uint8_t(__pyx_t_6, PyBUF_WRITABLE); if (unlikely(!__pyx_t_57.memview)) __PYX_ERR(0, 251, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_v_arr_memview8u = __pyx_t_57; + __pyx_t_57.memview = NULL; + __pyx_t_57.data = NULL; + + /* "cc3d.pyx":252 + * elif dtype == np.bool and connectivity == 8: + * arr_memview8u = data.view(np.uint8) + * if out_dtype == np.uint16: # <<<<<<<<<<<<<< + * connected_components2d_8_bbdt[uint8_t, uint16_t]( + * &arr_memview8u[0,0,0], + */ + __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 252, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uint16); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 252, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_11, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 252, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 252, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (__pyx_t_5) { + + /* "cc3d.pyx":254 + * if out_dtype == np.uint16: + * connected_components2d_8_bbdt[uint8_t, uint16_t]( + * &arr_memview8u[0,0,0], # <<<<<<<<<<<<<< + * sx, sy, sz, max_labels, + * &out_labels16[0] + */ + __pyx_t_70 = 0; + __pyx_t_71 = 0; + __pyx_t_72 = 0; + __pyx_t_10 = -1; + if (__pyx_t_70 < 0) { + __pyx_t_70 += __pyx_v_arr_memview8u.shape[0]; + if (unlikely(__pyx_t_70 < 0)) __pyx_t_10 = 0; + } else if (unlikely(__pyx_t_70 >= __pyx_v_arr_memview8u.shape[0])) __pyx_t_10 = 0; + if (__pyx_t_71 < 0) { + __pyx_t_71 += __pyx_v_arr_memview8u.shape[1]; + if (unlikely(__pyx_t_71 < 0)) __pyx_t_10 = 1; + } else if (unlikely(__pyx_t_71 >= __pyx_v_arr_memview8u.shape[1])) __pyx_t_10 = 1; + if (__pyx_t_72 < 0) { + __pyx_t_72 += __pyx_v_arr_memview8u.shape[2]; + if (unlikely(__pyx_t_72 < 0)) __pyx_t_10 = 2; + } else if (unlikely(__pyx_t_72 >= __pyx_v_arr_memview8u.shape[2])) __pyx_t_10 = 2; + if (unlikely(__pyx_t_10 != -1)) { + __Pyx_RaiseBufferIndexError(__pyx_t_10); + __PYX_ERR(0, 254, __pyx_L1_error) + } + + /* "cc3d.pyx":256 + * &arr_memview8u[0,0,0], + * sx, sy, sz, max_labels, + * &out_labels16[0] # <<<<<<<<<<<<<< + * ) + * elif out_dtype == np.uint32: + */ + __pyx_t_73 = 0; + __pyx_t_10 = -1; + if (__pyx_t_73 < 0) { + __pyx_t_73 += __pyx_pybuffernd_out_labels16.diminfo[0].shape; + if (unlikely(__pyx_t_73 < 0)) __pyx_t_10 = 0; + } else if (unlikely(__pyx_t_73 >= __pyx_pybuffernd_out_labels16.diminfo[0].shape)) __pyx_t_10 = 0; + if (unlikely(__pyx_t_10 != -1)) { + __Pyx_RaiseBufferIndexError(__pyx_t_10); + __PYX_ERR(0, 256, __pyx_L1_error) + } + + /* "cc3d.pyx":253 + * arr_memview8u = data.view(np.uint8) + * if out_dtype == np.uint16: + * connected_components2d_8_bbdt[uint8_t, uint16_t]( # <<<<<<<<<<<<<< + * &arr_memview8u[0,0,0], + * sx, sy, sz, max_labels, + */ + (void)(cc3d::connected_components2d_8_bbdt((&(*((uint8_t *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_arr_memview8u.data + __pyx_t_70 * __pyx_v_arr_memview8u.strides[0]) ) + __pyx_t_71 * __pyx_v_arr_memview8u.strides[1]) ) + __pyx_t_72 * __pyx_v_arr_memview8u.strides[2]) )))), __pyx_v_sx, __pyx_v_sy, __pyx_v_sz, __pyx_v_max_labels, ((uint16_t *)(&(*__Pyx_BufPtrStrided1d(uint16_t *, __pyx_pybuffernd_out_labels16.rcbuffer->pybuffer.buf, __pyx_t_73, __pyx_pybuffernd_out_labels16.diminfo[0].strides)))))); + + /* "cc3d.pyx":252 + * elif dtype == np.bool and connectivity == 8: + * arr_memview8u = data.view(np.uint8) + * if out_dtype == np.uint16: # <<<<<<<<<<<<<< + * connected_components2d_8_bbdt[uint8_t, uint16_t]( + * &arr_memview8u[0,0,0], + */ + goto __pyx_L44; + } + + /* "cc3d.pyx":258 + * &out_labels16[0] + * ) + * elif out_dtype == np.uint32: # <<<<<<<<<<<<<< + * connected_components2d_8_bbdt[uint8_t, uint32_t]( + * &arr_memview8u[0,0,0], + */ + __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 258, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uint32); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 258, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_11, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 258, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 258, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (__pyx_t_5) { + + /* "cc3d.pyx":260 + * elif out_dtype == np.uint32: + * connected_components2d_8_bbdt[uint8_t, uint32_t]( + * &arr_memview8u[0,0,0], # <<<<<<<<<<<<<< + * sx, sy, sz, max_labels, + * &out_labels32[0] + */ + __pyx_t_74 = 0; + __pyx_t_75 = 0; + __pyx_t_76 = 0; + __pyx_t_10 = -1; + if (__pyx_t_74 < 0) { + __pyx_t_74 += __pyx_v_arr_memview8u.shape[0]; + if (unlikely(__pyx_t_74 < 0)) __pyx_t_10 = 0; + } else if (unlikely(__pyx_t_74 >= __pyx_v_arr_memview8u.shape[0])) __pyx_t_10 = 0; + if (__pyx_t_75 < 0) { + __pyx_t_75 += __pyx_v_arr_memview8u.shape[1]; + if (unlikely(__pyx_t_75 < 0)) __pyx_t_10 = 1; + } else if (unlikely(__pyx_t_75 >= __pyx_v_arr_memview8u.shape[1])) __pyx_t_10 = 1; + if (__pyx_t_76 < 0) { + __pyx_t_76 += __pyx_v_arr_memview8u.shape[2]; + if (unlikely(__pyx_t_76 < 0)) __pyx_t_10 = 2; + } else if (unlikely(__pyx_t_76 >= __pyx_v_arr_memview8u.shape[2])) __pyx_t_10 = 2; + if (unlikely(__pyx_t_10 != -1)) { + __Pyx_RaiseBufferIndexError(__pyx_t_10); + __PYX_ERR(0, 260, __pyx_L1_error) + } + + /* "cc3d.pyx":262 + * &arr_memview8u[0,0,0], + * sx, sy, sz, max_labels, + * &out_labels32[0] # <<<<<<<<<<<<<< + * ) + * elif out_dtype == np.uint64: + */ + __pyx_t_77 = 0; + __pyx_t_10 = -1; + if (__pyx_t_77 < 0) { + __pyx_t_77 += __pyx_pybuffernd_out_labels32.diminfo[0].shape; + if (unlikely(__pyx_t_77 < 0)) __pyx_t_10 = 0; + } else if (unlikely(__pyx_t_77 >= __pyx_pybuffernd_out_labels32.diminfo[0].shape)) __pyx_t_10 = 0; + if (unlikely(__pyx_t_10 != -1)) { + __Pyx_RaiseBufferIndexError(__pyx_t_10); + __PYX_ERR(0, 262, __pyx_L1_error) + } + + /* "cc3d.pyx":259 + * ) + * elif out_dtype == np.uint32: + * connected_components2d_8_bbdt[uint8_t, uint32_t]( # <<<<<<<<<<<<<< + * &arr_memview8u[0,0,0], + * sx, sy, sz, max_labels, + */ + (void)(cc3d::connected_components2d_8_bbdt((&(*((uint8_t *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_arr_memview8u.data + __pyx_t_74 * __pyx_v_arr_memview8u.strides[0]) ) + __pyx_t_75 * __pyx_v_arr_memview8u.strides[1]) ) + __pyx_t_76 * __pyx_v_arr_memview8u.strides[2]) )))), __pyx_v_sx, __pyx_v_sy, __pyx_v_sz, __pyx_v_max_labels, ((uint32_t *)(&(*__Pyx_BufPtrStrided1d(uint32_t *, __pyx_pybuffernd_out_labels32.rcbuffer->pybuffer.buf, __pyx_t_77, __pyx_pybuffernd_out_labels32.diminfo[0].strides)))))); + + /* "cc3d.pyx":258 + * &out_labels16[0] + * ) + * elif out_dtype == np.uint32: # <<<<<<<<<<<<<< + * connected_components2d_8_bbdt[uint8_t, uint32_t]( + * &arr_memview8u[0,0,0], + */ + goto __pyx_L44; + } + + /* "cc3d.pyx":264 + * &out_labels32[0] + * ) + * elif out_dtype == np.uint64: # <<<<<<<<<<<<<< + * connected_components2d_8_bbdt[uint8_t, uint64_t]( + * &arr_memview8u[0,0,0], + */ + __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 264, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uint64); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 264, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = PyObject_RichCompare(__pyx_v_out_dtype, __pyx_t_11, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 264, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 264, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (__pyx_t_5) { + + /* "cc3d.pyx":266 + * elif out_dtype == np.uint64: + * connected_components2d_8_bbdt[uint8_t, uint64_t]( + * &arr_memview8u[0,0,0], # <<<<<<<<<<<<<< + * sx, sy, sz, max_labels, + * &out_labels64[0] + */ + __pyx_t_78 = 0; + __pyx_t_79 = 0; + __pyx_t_80 = 0; + __pyx_t_10 = -1; + if (__pyx_t_78 < 0) { + __pyx_t_78 += __pyx_v_arr_memview8u.shape[0]; + if (unlikely(__pyx_t_78 < 0)) __pyx_t_10 = 0; + } else if (unlikely(__pyx_t_78 >= __pyx_v_arr_memview8u.shape[0])) __pyx_t_10 = 0; + if (__pyx_t_79 < 0) { + __pyx_t_79 += __pyx_v_arr_memview8u.shape[1]; + if (unlikely(__pyx_t_79 < 0)) __pyx_t_10 = 1; + } else if (unlikely(__pyx_t_79 >= __pyx_v_arr_memview8u.shape[1])) __pyx_t_10 = 1; + if (__pyx_t_80 < 0) { + __pyx_t_80 += __pyx_v_arr_memview8u.shape[2]; + if (unlikely(__pyx_t_80 < 0)) __pyx_t_10 = 2; + } else if (unlikely(__pyx_t_80 >= __pyx_v_arr_memview8u.shape[2])) __pyx_t_10 = 2; + if (unlikely(__pyx_t_10 != -1)) { + __Pyx_RaiseBufferIndexError(__pyx_t_10); + __PYX_ERR(0, 266, __pyx_L1_error) + } + + /* "cc3d.pyx":268 + * &arr_memview8u[0,0,0], + * sx, sy, sz, max_labels, + * &out_labels64[0] # <<<<<<<<<<<<<< + * ) + * else: + */ + __pyx_t_81 = 0; + __pyx_t_10 = -1; + if (__pyx_t_81 < 0) { + __pyx_t_81 += __pyx_pybuffernd_out_labels64.diminfo[0].shape; + if (unlikely(__pyx_t_81 < 0)) __pyx_t_10 = 0; + } else if (unlikely(__pyx_t_81 >= __pyx_pybuffernd_out_labels64.diminfo[0].shape)) __pyx_t_10 = 0; + if (unlikely(__pyx_t_10 != -1)) { + __Pyx_RaiseBufferIndexError(__pyx_t_10); + __PYX_ERR(0, 268, __pyx_L1_error) + } + + /* "cc3d.pyx":265 + * ) + * elif out_dtype == np.uint64: + * connected_components2d_8_bbdt[uint8_t, uint64_t]( # <<<<<<<<<<<<<< + * &arr_memview8u[0,0,0], + * sx, sy, sz, max_labels, + */ + (void)(cc3d::connected_components2d_8_bbdt((&(*((uint8_t *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_arr_memview8u.data + __pyx_t_78 * __pyx_v_arr_memview8u.strides[0]) ) + __pyx_t_79 * __pyx_v_arr_memview8u.strides[1]) ) + __pyx_t_80 * __pyx_v_arr_memview8u.strides[2]) )))), __pyx_v_sx, __pyx_v_sy, __pyx_v_sz, __pyx_v_max_labels, ((uint64_t *)(&(*__Pyx_BufPtrStrided1d(uint64_t *, __pyx_pybuffernd_out_labels64.rcbuffer->pybuffer.buf, __pyx_t_81, __pyx_pybuffernd_out_labels64.diminfo[0].strides)))))); + + /* "cc3d.pyx":264 + * &out_labels32[0] + * ) + * elif out_dtype == np.uint64: # <<<<<<<<<<<<<< + * connected_components2d_8_bbdt[uint8_t, uint64_t]( + * &arr_memview8u[0,0,0], + */ + } + __pyx_L44:; + + /* "cc3d.pyx":250 + * &out_labels64[0] + * ) + * elif dtype == np.bool and connectivity == 8: # <<<<<<<<<<<<<< + * arr_memview8u = data.view(np.uint8) + * if out_dtype == np.uint16: + */ + goto __pyx_L26; + } + + /* "cc3d.pyx":271 + * ) + * else: + * raise TypeError("Type {} not currently supported.".format(dtype)) # <<<<<<<<<<<<<< + * + * if dims == 3: + */ + /*else*/ { + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Type_not_currently_supported, __pyx_n_s_format); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 271, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_11); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_11, function); + } + } + __pyx_t_6 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_11, __pyx_t_4, __pyx_v_dtype) : __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_v_dtype); + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 271, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 271, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_Raise(__pyx_t_11, 0, 0, 0); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __PYX_ERR(0, 246, __pyx_L1_error) + __PYX_ERR(0, 271, __pyx_L1_error) } __pyx_L26:; - /* "cc3d.pyx":248 + /* "cc3d.pyx":273 * raise TypeError("Type {} not currently supported.".format(dtype)) * * if dims == 3: # <<<<<<<<<<<<<< * if order == 'C': * return out_labels.reshape( (sz, sy, sx), order=order) */ - __pyx_t_11 = __Pyx_PyInt_EqObjC(__pyx_v_dims, __pyx_int_3, 3, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 248, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyInt_EqObjC(__pyx_v_dims, __pyx_int_3, 3, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 273, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 248, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 273, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - if (__pyx_t_3) { + if (__pyx_t_5) { - /* "cc3d.pyx":249 + /* "cc3d.pyx":274 * * if dims == 3: * if order == 'C': # <<<<<<<<<<<<<< * return out_labels.reshape( (sz, sy, sx), order=order) * else: */ - __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_v_order, __pyx_n_u_C, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 249, __pyx_L1_error) - __pyx_t_5 = (__pyx_t_3 != 0); - if (__pyx_t_5) { + __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_v_order, __pyx_n_u_C, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 274, __pyx_L1_error) + __pyx_t_8 = (__pyx_t_5 != 0); + if (__pyx_t_8) { - /* "cc3d.pyx":250 + /* "cc3d.pyx":275 * if dims == 3: * if order == 'C': * return out_labels.reshape( (sz, sy, sx), order=order) # <<<<<<<<<<<<<< @@ -5928,44 +6269,44 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p * return out_labels.reshape( (sx, sy, sz), order=order) */ __Pyx_XDECREF(__pyx_r); - if (unlikely(!__pyx_v_out_labels)) { __Pyx_RaiseUnboundLocalError("out_labels"); __PYX_ERR(0, 250, __pyx_L1_error) } - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_out_labels, __pyx_n_s_reshape); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 250, __pyx_L1_error) + if (unlikely(!__pyx_v_out_labels)) { __Pyx_RaiseUnboundLocalError("out_labels"); __PYX_ERR(0, 275, __pyx_L1_error) } + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_out_labels, __pyx_n_s_reshape); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 275, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_sz); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 250, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_sz); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 275, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_sy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 250, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_sx); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 250, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_sy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 275, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 250, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_sx); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 275, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 275, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_1); __pyx_t_6 = 0; - __pyx_t_1 = 0; __pyx_t_4 = 0; - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 250, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 275, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_7); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 250, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 275, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 250, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 250, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 275, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_1, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 275, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; + __pyx_r = __pyx_t_4; + __pyx_t_4 = 0; goto __pyx_L0; - /* "cc3d.pyx":249 + /* "cc3d.pyx":274 * * if dims == 3: * if order == 'C': # <<<<<<<<<<<<<< @@ -5974,7 +6315,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ } - /* "cc3d.pyx":252 + /* "cc3d.pyx":277 * return out_labels.reshape( (sz, sy, sx), order=order) * else: * return out_labels.reshape( (sx, sy, sz), order=order) # <<<<<<<<<<<<<< @@ -5983,45 +6324,45 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ /*else*/ { __Pyx_XDECREF(__pyx_r); - if (unlikely(!__pyx_v_out_labels)) { __Pyx_RaiseUnboundLocalError("out_labels"); __PYX_ERR(0, 252, __pyx_L1_error) } - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_out_labels, __pyx_n_s_reshape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 252, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_sx); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 252, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_sy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 252, __pyx_L1_error) + if (unlikely(!__pyx_v_out_labels)) { __Pyx_RaiseUnboundLocalError("out_labels"); __PYX_ERR(0, 277, __pyx_L1_error) } + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_out_labels, __pyx_n_s_reshape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 277, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_sz); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 252, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_sx); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 277, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_sy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 277, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_sz); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 277, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 252, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 277, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_11); __pyx_t_7 = 0; - __pyx_t_4 = 0; + __pyx_t_1 = 0; __pyx_t_11 = 0; - __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 252, __pyx_L1_error) + __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 277, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 252, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 277, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 252, __pyx_L1_error) - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 252, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 277, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_11, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 277, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_r = __pyx_t_4; - __pyx_t_4 = 0; + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; goto __pyx_L0; } - /* "cc3d.pyx":248 + /* "cc3d.pyx":273 * raise TypeError("Type {} not currently supported.".format(dtype)) * * if dims == 3: # <<<<<<<<<<<<<< @@ -6030,31 +6371,31 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ } - /* "cc3d.pyx":253 + /* "cc3d.pyx":278 * else: * return out_labels.reshape( (sx, sy, sz), order=order) * elif dims == 2: # <<<<<<<<<<<<<< * if order == 'C': * return out_labels.reshape( (sy, sx), order=order) */ - __pyx_t_4 = __Pyx_PyInt_EqObjC(__pyx_v_dims, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 253, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 253, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_5) { + __pyx_t_1 = __Pyx_PyInt_EqObjC(__pyx_v_dims, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 278, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 278, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_8) { - /* "cc3d.pyx":254 + /* "cc3d.pyx":279 * return out_labels.reshape( (sx, sy, sz), order=order) * elif dims == 2: * if order == 'C': # <<<<<<<<<<<<<< * return out_labels.reshape( (sy, sx), order=order) * else: */ - __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_v_order, __pyx_n_u_C, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 254, __pyx_L1_error) - __pyx_t_3 = (__pyx_t_5 != 0); - if (__pyx_t_3) { + __pyx_t_8 = (__Pyx_PyUnicode_Equals(__pyx_v_order, __pyx_n_u_C, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 279, __pyx_L1_error) + __pyx_t_5 = (__pyx_t_8 != 0); + if (__pyx_t_5) { - /* "cc3d.pyx":255 + /* "cc3d.pyx":280 * elif dims == 2: * if order == 'C': * return out_labels.reshape( (sy, sx), order=order) # <<<<<<<<<<<<<< @@ -6062,39 +6403,39 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p * return out_labels.reshape( (sx, sy), order=order) */ __Pyx_XDECREF(__pyx_r); - if (unlikely(!__pyx_v_out_labels)) { __Pyx_RaiseUnboundLocalError("out_labels"); __PYX_ERR(0, 255, __pyx_L1_error) } - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_out_labels, __pyx_n_s_reshape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 255, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_sy); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 255, __pyx_L1_error) + if (unlikely(!__pyx_v_out_labels)) { __Pyx_RaiseUnboundLocalError("out_labels"); __PYX_ERR(0, 280, __pyx_L1_error) } + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_out_labels, __pyx_n_s_reshape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 280, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_sy); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_sx); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 255, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_sx); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 255, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 280, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_11); - PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_11); __pyx_t_6 = 0; __pyx_t_11 = 0; - __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 255, __pyx_L1_error) + __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 255, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 255, __pyx_L1_error) - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_11, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 255, __pyx_L1_error) + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 280, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 280, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_r = __pyx_t_6; __pyx_t_6 = 0; goto __pyx_L0; - /* "cc3d.pyx":254 + /* "cc3d.pyx":279 * return out_labels.reshape( (sx, sy, sz), order=order) * elif dims == 2: * if order == 'C': # <<<<<<<<<<<<<< @@ -6103,7 +6444,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ } - /* "cc3d.pyx":257 + /* "cc3d.pyx":282 * return out_labels.reshape( (sy, sx), order=order) * else: * return out_labels.reshape( (sx, sy), order=order) # <<<<<<<<<<<<<< @@ -6112,40 +6453,40 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ /*else*/ { __Pyx_XDECREF(__pyx_r); - if (unlikely(!__pyx_v_out_labels)) { __Pyx_RaiseUnboundLocalError("out_labels"); __PYX_ERR(0, 257, __pyx_L1_error) } - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_out_labels, __pyx_n_s_reshape); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 257, __pyx_L1_error) + if (unlikely(!__pyx_v_out_labels)) { __Pyx_RaiseUnboundLocalError("out_labels"); __PYX_ERR(0, 282, __pyx_L1_error) } + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_out_labels, __pyx_n_s_reshape); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 282, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_sx); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 257, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_sy); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 257, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 257, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_sx); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 282, __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_11); - PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_11); - __pyx_t_1 = 0; - __pyx_t_11 = 0; - __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 257, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_sy); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 282, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 282, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_11); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 257, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 257, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_11, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 257, __pyx_L1_error) + __pyx_t_11 = 0; + __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 282, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 282, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 282, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_11, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 282, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_r = __pyx_t_4; + __pyx_t_4 = 0; goto __pyx_L0; } - /* "cc3d.pyx":253 + /* "cc3d.pyx":278 * else: * return out_labels.reshape( (sx, sy, sz), order=order) * elif dims == 2: # <<<<<<<<<<<<<< @@ -6154,7 +6495,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ } - /* "cc3d.pyx":259 + /* "cc3d.pyx":284 * return out_labels.reshape( (sx, sy), order=order) * else: * return out_labels.reshape( (sx), order=order) # <<<<<<<<<<<<<< @@ -6163,30 +6504,30 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p */ /*else*/ { __Pyx_XDECREF(__pyx_r); - if (unlikely(!__pyx_v_out_labels)) { __Pyx_RaiseUnboundLocalError("out_labels"); __PYX_ERR(0, 259, __pyx_L1_error) } - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_out_labels, __pyx_n_s_reshape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 259, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_sx); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 259, __pyx_L1_error) + if (unlikely(!__pyx_v_out_labels)) { __Pyx_RaiseUnboundLocalError("out_labels"); __PYX_ERR(0, 284, __pyx_L1_error) } + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_out_labels, __pyx_n_s_reshape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 259, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_sx); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 284, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 259, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 259, __pyx_L1_error) - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 259, __pyx_L1_error) + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 284, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 284, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_11, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_6; __pyx_t_6 = 0; goto __pyx_L0; } - /* "cc3d.pyx":73 + /* "cc3d.pyx":78 * pass * * def connected_components( # <<<<<<<<<<<<<< @@ -6240,7 +6581,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p return __pyx_r; } -/* "cc3d.pyx":261 +/* "cc3d.pyx":286 * return out_labels.reshape( (sx), order=order) * * def region_graph( # <<<<<<<<<<<<<< @@ -6294,17 +6635,17 @@ static PyObject *__pyx_pw_4cc3d_3region_graph(PyObject *__pyx_self, PyObject *__ case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_kwargs)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 2); __PYX_ERR(0, 261, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 2); __PYX_ERR(0, 286, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_defaults)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 3); __PYX_ERR(0, 261, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 3); __PYX_ERR(0, 286, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_fused_cpdef") < 0)) __PYX_ERR(0, 261, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_fused_cpdef") < 0)) __PYX_ERR(0, 286, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; @@ -6321,7 +6662,7 @@ static PyObject *__pyx_pw_4cc3d_3region_graph(PyObject *__pyx_self, PyObject *__ } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 261, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 286, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("cc3d.__pyx_fused_cpdef", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -6380,7 +6721,7 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self int __pyx_t_18; __Pyx_RefNannySetupContext("region_graph", 0); __Pyx_INCREF(__pyx_v_kwargs); - __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); @@ -6394,7 +6735,7 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_2 = __pyx_t_4; goto __pyx_L4_bool_binop_done; } - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_kwargs); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_kwargs); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 286, __pyx_L1_error) __pyx_t_3 = ((!__pyx_t_4) != 0); __pyx_t_2 = __pyx_t_3; __pyx_L4_bool_binop_done:; @@ -6402,7 +6743,7 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self __Pyx_INCREF(Py_None); __Pyx_DECREF_SET(__pyx_v_kwargs, Py_None); } - __pyx_t_1 = ((PyObject *)__Pyx_ImportNumPyArrayTypeIfAvailable()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__Pyx_ImportNumPyArrayTypeIfAvailable()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_ndarray = ((PyTypeObject*)__pyx_t_1); __pyx_t_1 = 0; @@ -6417,16 +6758,16 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_v____pyx_int64_t_is_signed = (!((((int64_t)-1L) > 0) != 0)); if (unlikely(__pyx_v_args == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(0, 261, __pyx_L1_error) + __PYX_ERR(0, 286, __pyx_L1_error) } - __pyx_t_5 = PyTuple_GET_SIZE(((PyObject*)__pyx_v_args)); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_5 = PyTuple_GET_SIZE(((PyObject*)__pyx_v_args)); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 286, __pyx_L1_error) __pyx_t_2 = ((0 < __pyx_t_5) != 0); if (__pyx_t_2) { if (unlikely(__pyx_v_args == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 261, __pyx_L1_error) + __PYX_ERR(0, 286, __pyx_L1_error) } - __pyx_t_1 = __Pyx_GetItemInt_Tuple(((PyObject*)__pyx_v_args), 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetItemInt_Tuple(((PyObject*)__pyx_v_args), 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_arg = __pyx_t_1; __pyx_t_1 = 0; @@ -6441,18 +6782,18 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self } if (unlikely(__pyx_v_kwargs == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); - __PYX_ERR(0, 261, __pyx_L1_error) + __PYX_ERR(0, 286, __pyx_L1_error) } - __pyx_t_4 = (__Pyx_PyDict_ContainsTF(__pyx_n_s_labels, ((PyObject*)__pyx_v_kwargs), Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_4 = (__Pyx_PyDict_ContainsTF(__pyx_n_s_labels, ((PyObject*)__pyx_v_kwargs), Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 286, __pyx_L1_error) __pyx_t_3 = (__pyx_t_4 != 0); __pyx_t_2 = __pyx_t_3; __pyx_L7_bool_binop_done:; if (__pyx_t_2) { if (unlikely(__pyx_v_kwargs == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 261, __pyx_L1_error) + __PYX_ERR(0, 286, __pyx_L1_error) } - __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject*)__pyx_v_kwargs), __pyx_n_s_labels); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject*)__pyx_v_kwargs), __pyx_n_s_labels); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_arg = __pyx_t_1; __pyx_t_1 = 0; @@ -6461,12 +6802,12 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self /*else*/ { if (unlikely(__pyx_v_args == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(0, 261, __pyx_L1_error) + __PYX_ERR(0, 286, __pyx_L1_error) } - __pyx_t_5 = PyTuple_GET_SIZE(((PyObject*)__pyx_v_args)); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 261, __pyx_L1_error) - __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_5 = PyTuple_GET_SIZE(((PyObject*)__pyx_v_args)); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 286, __pyx_L1_error) + __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); @@ -6477,15 +6818,15 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Expected_at_least_d_argument_s_g, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Expected_at_least_d_argument_s_g, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __PYX_ERR(0, 261, __pyx_L1_error) + __PYX_ERR(0, 286, __pyx_L1_error) } __pyx_L6:; while (1) { @@ -6495,7 +6836,7 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_arg, __pyx_v_ndarray); __pyx_t_2 = (__pyx_t_3 != 0); if (__pyx_t_2) { - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_v_dtype = __pyx_t_6; __pyx_t_6 = 0; @@ -6504,14 +6845,14 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_2 = __pyx_memoryview_check(__pyx_v_arg); __pyx_t_3 = (__pyx_t_2 != 0); if (__pyx_t_3) { - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_base); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_base); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_v_arg_base = __pyx_t_6; __pyx_t_6 = 0; __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_arg_base, __pyx_v_ndarray); __pyx_t_2 = (__pyx_t_3 != 0); if (__pyx_t_2) { - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg_base, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg_base, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_v_dtype = __pyx_t_6; __pyx_t_6 = 0; @@ -6533,14 +6874,14 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_2 = (__pyx_v_dtype != Py_None); __pyx_t_3 = (__pyx_t_2 != 0); if (__pyx_t_3) { - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_itemsize = __pyx_t_5; - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = __Pyx_PyObject_Ord(__pyx_t_6); if (unlikely(__pyx_t_7 == ((long)(long)(Py_UCS4)-1))) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_Ord(__pyx_t_6); if (unlikely(__pyx_t_7 == ((long)(long)(Py_UCS4)-1))) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_kind = __pyx_t_7; __pyx_v_dtype_signed = (__pyx_v_kind == 'i'); @@ -6553,9 +6894,9 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_3 = __pyx_t_2; goto __pyx_L16_bool_binop_done; } - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_2 = ((((Py_ssize_t)__pyx_t_5) == 3) != 0); if (__pyx_t_2) { @@ -6567,7 +6908,7 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_3 = __pyx_t_2; __pyx_L16_bool_binop_done:; if (__pyx_t_3) { - if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_uint8_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 261, __pyx_L1_error) + if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_uint8_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 286, __pyx_L1_error) goto __pyx_L10_break; } __pyx_t_2 = (((sizeof(uint16_t)) == __pyx_v_itemsize) != 0); @@ -6576,9 +6917,9 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_3 = __pyx_t_2; goto __pyx_L20_bool_binop_done; } - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_2 = ((((Py_ssize_t)__pyx_t_5) == 3) != 0); if (__pyx_t_2) { @@ -6590,7 +6931,7 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_3 = __pyx_t_2; __pyx_L20_bool_binop_done:; if (__pyx_t_3) { - if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_uint16_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 261, __pyx_L1_error) + if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_uint16_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 286, __pyx_L1_error) goto __pyx_L10_break; } __pyx_t_2 = (((sizeof(uint32_t)) == __pyx_v_itemsize) != 0); @@ -6599,9 +6940,9 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_3 = __pyx_t_2; goto __pyx_L24_bool_binop_done; } - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_2 = ((((Py_ssize_t)__pyx_t_5) == 3) != 0); if (__pyx_t_2) { @@ -6613,7 +6954,7 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_3 = __pyx_t_2; __pyx_L24_bool_binop_done:; if (__pyx_t_3) { - if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_uint32_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 261, __pyx_L1_error) + if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_uint32_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 286, __pyx_L1_error) goto __pyx_L10_break; } __pyx_t_2 = (((sizeof(uint64_t)) == __pyx_v_itemsize) != 0); @@ -6622,9 +6963,9 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_3 = __pyx_t_2; goto __pyx_L28_bool_binop_done; } - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_2 = ((((Py_ssize_t)__pyx_t_5) == 3) != 0); if (__pyx_t_2) { @@ -6636,7 +6977,7 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_3 = __pyx_t_2; __pyx_L28_bool_binop_done:; if (__pyx_t_3) { - if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_uint64_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 261, __pyx_L1_error) + if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_uint64_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 286, __pyx_L1_error) goto __pyx_L10_break; } __pyx_t_2 = (((sizeof(int8_t)) == __pyx_v_itemsize) != 0); @@ -6645,9 +6986,9 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_3 = __pyx_t_2; goto __pyx_L32_bool_binop_done; } - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_2 = ((((Py_ssize_t)__pyx_t_5) == 3) != 0); if (__pyx_t_2) { @@ -6659,7 +7000,7 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_3 = __pyx_t_2; __pyx_L32_bool_binop_done:; if (__pyx_t_3) { - if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int8_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 261, __pyx_L1_error) + if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int8_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 286, __pyx_L1_error) goto __pyx_L10_break; } __pyx_t_2 = (((sizeof(int16_t)) == __pyx_v_itemsize) != 0); @@ -6668,9 +7009,9 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_3 = __pyx_t_2; goto __pyx_L36_bool_binop_done; } - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_2 = ((((Py_ssize_t)__pyx_t_5) == 3) != 0); if (__pyx_t_2) { @@ -6682,7 +7023,7 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_3 = __pyx_t_2; __pyx_L36_bool_binop_done:; if (__pyx_t_3) { - if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int16_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 261, __pyx_L1_error) + if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int16_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 286, __pyx_L1_error) goto __pyx_L10_break; } __pyx_t_2 = (((sizeof(int32_t)) == __pyx_v_itemsize) != 0); @@ -6691,9 +7032,9 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_3 = __pyx_t_2; goto __pyx_L40_bool_binop_done; } - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_2 = ((((Py_ssize_t)__pyx_t_5) == 3) != 0); if (__pyx_t_2) { @@ -6705,7 +7046,7 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_3 = __pyx_t_2; __pyx_L40_bool_binop_done:; if (__pyx_t_3) { - if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int32_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 261, __pyx_L1_error) + if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int32_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 286, __pyx_L1_error) goto __pyx_L10_break; } __pyx_t_2 = (((sizeof(int64_t)) == __pyx_v_itemsize) != 0); @@ -6714,9 +7055,9 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_3 = __pyx_t_2; goto __pyx_L44_bool_binop_done; } - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_2 = ((((Py_ssize_t)__pyx_t_5) == 3) != 0); if (__pyx_t_2) { @@ -6728,7 +7069,7 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_3 = __pyx_t_2; __pyx_L44_bool_binop_done:; if (__pyx_t_3) { - if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int64_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 261, __pyx_L1_error) + if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int64_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 286, __pyx_L1_error) goto __pyx_L10_break; } break; @@ -6757,7 +7098,7 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_3 = (__pyx_v_memslice.memview != 0); if (__pyx_t_3) { __PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1); - if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_uint8_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 261, __pyx_L1_error) + if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_uint8_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 286, __pyx_L1_error) goto __pyx_L10_break; } /*else*/ { @@ -6779,7 +7120,7 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_3 = (__pyx_v_memslice.memview != 0); if (__pyx_t_3) { __PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1); - if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_uint16_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 261, __pyx_L1_error) + if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_uint16_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 286, __pyx_L1_error) goto __pyx_L10_break; } /*else*/ { @@ -6801,7 +7142,7 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_3 = (__pyx_v_memslice.memview != 0); if (__pyx_t_3) { __PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1); - if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_uint32_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 261, __pyx_L1_error) + if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_uint32_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 286, __pyx_L1_error) goto __pyx_L10_break; } /*else*/ { @@ -6823,7 +7164,7 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_3 = (__pyx_v_memslice.memview != 0); if (__pyx_t_3) { __PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1); - if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_uint64_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 261, __pyx_L1_error) + if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_uint64_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 286, __pyx_L1_error) goto __pyx_L10_break; } /*else*/ { @@ -6845,7 +7186,7 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_3 = (__pyx_v_memslice.memview != 0); if (__pyx_t_3) { __PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1); - if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int8_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 261, __pyx_L1_error) + if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int8_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 286, __pyx_L1_error) goto __pyx_L10_break; } /*else*/ { @@ -6867,7 +7208,7 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_3 = (__pyx_v_memslice.memview != 0); if (__pyx_t_3) { __PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1); - if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int16_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 261, __pyx_L1_error) + if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int16_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 286, __pyx_L1_error) goto __pyx_L10_break; } /*else*/ { @@ -6889,7 +7230,7 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_3 = (__pyx_v_memslice.memview != 0); if (__pyx_t_3) { __PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1); - if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int32_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 261, __pyx_L1_error) + if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int32_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 286, __pyx_L1_error) goto __pyx_L10_break; } /*else*/ { @@ -6911,27 +7252,27 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_3 = (__pyx_v_memslice.memview != 0); if (__pyx_t_3) { __PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1); - if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int64_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 261, __pyx_L1_error) + if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int64_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 286, __pyx_L1_error) goto __pyx_L10_break; } /*else*/ { PyErr_Clear(); } } - if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, Py_None, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 261, __pyx_L1_error) + if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, Py_None, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 286, __pyx_L1_error) goto __pyx_L10_break; } __pyx_L10_break:; - __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_v_candidates = ((PyObject*)__pyx_t_6); __pyx_t_6 = 0; __pyx_t_5 = 0; if (unlikely(__pyx_v_signatures == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); - __PYX_ERR(0, 261, __pyx_L1_error) + __PYX_ERR(0, 286, __pyx_L1_error) } - __pyx_t_1 = __Pyx_dict_iterator(((PyObject*)__pyx_v_signatures), 1, ((PyObject *)NULL), (&__pyx_t_9), (&__pyx_t_10)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_1 = __Pyx_dict_iterator(((PyObject*)__pyx_v_signatures), 1, ((PyObject *)NULL), (&__pyx_t_9), (&__pyx_t_10)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = __pyx_t_1; @@ -6939,12 +7280,12 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self while (1) { __pyx_t_11 = __Pyx_dict_iter_next(__pyx_t_6, __pyx_t_9, &__pyx_t_5, &__pyx_t_1, NULL, NULL, __pyx_t_10); if (unlikely(__pyx_t_11 == 0)) break; - if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 261, __pyx_L1_error) + if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_sig, __pyx_t_1); __pyx_t_1 = 0; __pyx_v_match_found = 0; - __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_sig, __pyx_n_s_strip); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_sig, __pyx_n_s_strip); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_14 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) { @@ -6958,10 +7299,10 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self } __pyx_t_12 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_13, __pyx_t_14, __pyx_kp_s__6) : __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_kp_s__6); __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; - if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 261, __pyx_L1_error) + if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; - __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_split); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_split); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = NULL; @@ -6976,27 +7317,27 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self } __pyx_t_1 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_13, __pyx_t_12, __pyx_kp_s__7) : __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_kp_s__7); __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error) + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF_SET(__pyx_v_src_sig, __pyx_t_1); __pyx_t_1 = 0; - __pyx_t_15 = PyList_GET_SIZE(__pyx_v_dest_sig); if (unlikely(__pyx_t_15 == ((Py_ssize_t)-1))) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_15 = PyList_GET_SIZE(__pyx_v_dest_sig); if (unlikely(__pyx_t_15 == ((Py_ssize_t)-1))) __PYX_ERR(0, 286, __pyx_L1_error) __pyx_t_16 = __pyx_t_15; for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) { __pyx_v_i = __pyx_t_17; - __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_dest_sig, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_dest_sig, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_dst_type, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = (__pyx_v_dst_type != Py_None); __pyx_t_2 = (__pyx_t_3 != 0); if (__pyx_t_2) { - __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_src_sig, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_src_sig, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_13 = PyObject_RichCompare(__pyx_t_1, __pyx_v_dst_type, Py_EQ); __Pyx_XGOTREF(__pyx_t_13); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_13 = PyObject_RichCompare(__pyx_t_1, __pyx_v_dst_type, Py_EQ); __Pyx_XGOTREF(__pyx_t_13); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; if (__pyx_t_2) { __pyx_v_match_found = 1; @@ -7012,37 +7353,37 @@ static PyObject *__pyx_pf_4cc3d_2region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_L82_break:; __pyx_t_2 = (__pyx_v_match_found != 0); if (__pyx_t_2) { - __pyx_t_18 = __Pyx_PyList_Append(__pyx_v_candidates, __pyx_v_sig); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_18 = __Pyx_PyList_Append(__pyx_v_candidates, __pyx_v_sig); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(0, 286, __pyx_L1_error) } } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_2 = (PyList_GET_SIZE(__pyx_v_candidates) != 0); __pyx_t_3 = ((!__pyx_t_2) != 0); if (__pyx_t_3) { - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __PYX_ERR(0, 261, __pyx_L1_error) + __PYX_ERR(0, 286, __pyx_L1_error) } - __pyx_t_9 = PyList_GET_SIZE(__pyx_v_candidates); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_9 = PyList_GET_SIZE(__pyx_v_candidates); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 286, __pyx_L1_error) __pyx_t_3 = ((__pyx_t_9 > 1) != 0); if (__pyx_t_3) { - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __PYX_ERR(0, 261, __pyx_L1_error) + __PYX_ERR(0, 286, __pyx_L1_error) } /*else*/ { __Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_signatures == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 261, __pyx_L1_error) + __PYX_ERR(0, 286, __pyx_L1_error) } - __pyx_t_6 = __Pyx_GetItemInt_List(__pyx_v_candidates, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_6 = __Pyx_GetItemInt_List(__pyx_v_candidates, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_13 = __Pyx_PyDict_GetItem(((PyObject*)__pyx_v_signatures), __pyx_t_6); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_13 = __Pyx_PyDict_GetItem(((PyObject*)__pyx_v_signatures), __pyx_t_6); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_r = __pyx_t_13; @@ -7082,14 +7423,14 @@ static PyObject *__pyx_pf_4cc3d_38__defaults__(CYTHON_UNUSED PyObject *__pyx_sel PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("__defaults__", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__Pyx_CyFunction_Defaults(__pyx_defaults8, __pyx_self)->__pyx_arg_connectivity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__Pyx_CyFunction_Defaults(__pyx_defaults8, __pyx_self)->__pyx_arg_connectivity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); @@ -7150,7 +7491,7 @@ static PyObject *__pyx_fuse_0__pyx_pw_4cc3d_5region_graph(PyObject *__pyx_self, } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "region_graph") < 0)) __PYX_ERR(0, 261, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "region_graph") < 0)) __PYX_ERR(0, 286, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -7163,20 +7504,20 @@ static PyObject *__pyx_fuse_0__pyx_pw_4cc3d_5region_graph(PyObject *__pyx_self, } __pyx_v_labels = ((PyArrayObject *)values[0]); if (values[1]) { - __pyx_v_connectivity = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_connectivity == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 263, __pyx_L3_error) + __pyx_v_connectivity = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_connectivity == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 288, __pyx_L3_error) } else { __pyx_v_connectivity = __pyx_dynamic_args->__pyx_arg_connectivity; } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("region_graph", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 261, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("region_graph", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 286, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("cc3d.region_graph", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_labels), __pyx_ptype_5numpy_ndarray, 1, "labels", 0))) __PYX_ERR(0, 262, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_labels), __pyx_ptype_5numpy_ndarray, 1, "labels", 0))) __PYX_ERR(0, 287, __pyx_L1_error) __pyx_r = __pyx_pf_4cc3d_4region_graph(__pyx_self, __pyx_v_labels, __pyx_v_connectivity); /* function exit code */ @@ -7221,11 +7562,11 @@ static PyObject *__pyx_pf_4cc3d_4region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_pybuffernd_labels.rcbuffer = &__pyx_pybuffer_labels; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_labels.rcbuffer->pybuffer, (PyObject*)__pyx_v_labels, &__Pyx_TypeInfo_nn_uint8_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 1, __pyx_stack) == -1)) __PYX_ERR(0, 261, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_labels.rcbuffer->pybuffer, (PyObject*)__pyx_v_labels, &__Pyx_TypeInfo_nn_uint8_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 1, __pyx_stack) == -1)) __PYX_ERR(0, 286, __pyx_L1_error) } __pyx_pybuffernd_labels.diminfo[0].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_labels.diminfo[0].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_labels.diminfo[1].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_labels.diminfo[1].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_labels.diminfo[2].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_labels.diminfo[2].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[2]; - /* "cc3d.pyx":275 + /* "cc3d.pyx":300 * Returns: set of edges * """ * if connectivity not in (6, 18, 26): # <<<<<<<<<<<<<< @@ -7245,29 +7586,29 @@ static PyObject *__pyx_pf_4cc3d_4region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_2 = (__pyx_t_1 != 0); if (unlikely(__pyx_t_2)) { - /* "cc3d.pyx":276 + /* "cc3d.pyx":301 * """ * if connectivity not in (6, 18, 26): * raise ValueError("Only 6, 18, and 26 connectivities are supported. Got: " + str(connectivity)) # <<<<<<<<<<<<<< * * labels = np.asfortranarray(labels) */ - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_connectivity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_connectivity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Only_6_18_and_26_connectivities_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Only_6_18_and_26_connectivities_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __PYX_ERR(0, 276, __pyx_L1_error) + __PYX_ERR(0, 301, __pyx_L1_error) - /* "cc3d.pyx":275 + /* "cc3d.pyx":300 * Returns: set of edges * """ * if connectivity not in (6, 18, 26): # <<<<<<<<<<<<<< @@ -7276,16 +7617,16 @@ static PyObject *__pyx_pf_4cc3d_4region_graph(CYTHON_UNUSED PyObject *__pyx_self */ } - /* "cc3d.pyx":278 + /* "cc3d.pyx":303 * raise ValueError("Only 6, 18, and 26 connectivities are supported. Got: " + str(connectivity)) * * labels = np.asfortranarray(labels) # <<<<<<<<<<<<<< * * cdef vector[INTEGER] res = extract_region_graph( */ - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 278, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_asfortranarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 278, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_asfortranarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; @@ -7300,10 +7641,10 @@ static PyObject *__pyx_pf_4cc3d_4region_graph(CYTHON_UNUSED PyObject *__pyx_self } __pyx_t_4 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_3, ((PyObject *)__pyx_v_labels)) : __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_labels)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 278, __pyx_L1_error) + if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 278, __pyx_L1_error) + if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 303, __pyx_L1_error) __pyx_t_6 = ((PyArrayObject *)__pyx_t_4); { __Pyx_BufFmt_StackElem __pyx_stack[1]; @@ -7320,13 +7661,13 @@ static PyObject *__pyx_pf_4cc3d_4region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_8 = __pyx_t_9 = __pyx_t_10 = 0; } __pyx_pybuffernd_labels.diminfo[0].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_labels.diminfo[0].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_labels.diminfo[1].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_labels.diminfo[1].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_labels.diminfo[2].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_labels.diminfo[2].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[2]; - if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 278, __pyx_L1_error) + if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 303, __pyx_L1_error) } __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_labels, ((PyArrayObject *)__pyx_t_4)); __pyx_t_4 = 0; - /* "cc3d.pyx":281 + /* "cc3d.pyx":306 * * cdef vector[INTEGER] res = extract_region_graph( * &labels[0,0,0], # <<<<<<<<<<<<<< @@ -7351,10 +7692,10 @@ static PyObject *__pyx_pf_4cc3d_4region_graph(CYTHON_UNUSED PyObject *__pyx_self } else if (unlikely(__pyx_t_13 >= __pyx_pybuffernd_labels.diminfo[2].shape)) __pyx_t_7 = 2; if (unlikely(__pyx_t_7 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_7); - __PYX_ERR(0, 281, __pyx_L1_error) + __PYX_ERR(0, 306, __pyx_L1_error) } - /* "cc3d.pyx":280 + /* "cc3d.pyx":305 * labels = np.asfortranarray(labels) * * cdef vector[INTEGER] res = extract_region_graph( # <<<<<<<<<<<<<< @@ -7363,19 +7704,19 @@ static PyObject *__pyx_pf_4cc3d_4region_graph(CYTHON_UNUSED PyObject *__pyx_self */ __pyx_v_res = ((std::vector )cc3d::extract_region_graph(((uint8_t *)(&(*__Pyx_BufPtrStrided3d(uint8_t *, __pyx_pybuffernd_labels.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_labels.diminfo[0].strides, __pyx_t_12, __pyx_pybuffernd_labels.diminfo[1].strides, __pyx_t_13, __pyx_pybuffernd_labels.diminfo[2].strides)))), (__pyx_v_labels->dimensions[0]), (__pyx_v_labels->dimensions[1]), (__pyx_v_labels->dimensions[2]), __pyx_v_connectivity)); - /* "cc3d.pyx":286 + /* "cc3d.pyx":311 * ) * * output = set() # <<<<<<<<<<<<<< * cdef size_t i = 0 * */ - __pyx_t_4 = PySet_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 286, __pyx_L1_error) + __pyx_t_4 = PySet_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 311, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_v_output = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; - /* "cc3d.pyx":287 + /* "cc3d.pyx":312 * * output = set() * cdef size_t i = 0 # <<<<<<<<<<<<<< @@ -7384,7 +7725,7 @@ static PyObject *__pyx_pf_4cc3d_4region_graph(CYTHON_UNUSED PyObject *__pyx_self */ __pyx_v_i = 0; - /* "cc3d.pyx":289 + /* "cc3d.pyx":314 * cdef size_t i = 0 * * for i in range(res.size() // 2): # <<<<<<<<<<<<<< @@ -7396,18 +7737,18 @@ static PyObject *__pyx_pf_4cc3d_4region_graph(CYTHON_UNUSED PyObject *__pyx_self for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) { __pyx_v_i = __pyx_t_16; - /* "cc3d.pyx":291 + /* "cc3d.pyx":316 * for i in range(res.size() // 2): * output.add( * (res[i * 2], res[i*2 + 1]) # <<<<<<<<<<<<<< * ) * */ - __pyx_t_4 = __Pyx_PyInt_From_uint8_t((__pyx_v_res[(__pyx_v_i * 2)])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 291, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_uint8_t((__pyx_v_res[(__pyx_v_i * 2)])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 316, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyInt_From_uint8_t((__pyx_v_res[((__pyx_v_i * 2) + 1)])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 291, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyInt_From_uint8_t((__pyx_v_res[((__pyx_v_i * 2) + 1)])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 316, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 291, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 316, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); @@ -7416,18 +7757,18 @@ static PyObject *__pyx_pf_4cc3d_4region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_4 = 0; __pyx_t_5 = 0; - /* "cc3d.pyx":290 + /* "cc3d.pyx":315 * * for i in range(res.size() // 2): * output.add( # <<<<<<<<<<<<<< * (res[i * 2], res[i*2 + 1]) * ) */ - __pyx_t_17 = PySet_Add(__pyx_v_output, __pyx_t_3); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 290, __pyx_L1_error) + __pyx_t_17 = PySet_Add(__pyx_v_output, __pyx_t_3); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 315, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } - /* "cc3d.pyx":294 + /* "cc3d.pyx":319 * ) * * return output # <<<<<<<<<<<<<< @@ -7439,7 +7780,7 @@ static PyObject *__pyx_pf_4cc3d_4region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_r = __pyx_v_output; goto __pyx_L0; - /* "cc3d.pyx":261 + /* "cc3d.pyx":286 * return out_labels.reshape( (sx), order=order) * * def region_graph( # <<<<<<<<<<<<<< @@ -7478,14 +7819,14 @@ static PyObject *__pyx_pf_4cc3d_40__defaults__(CYTHON_UNUSED PyObject *__pyx_sel PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("__defaults__", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__Pyx_CyFunction_Defaults(__pyx_defaults9, __pyx_self)->__pyx_arg_connectivity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__Pyx_CyFunction_Defaults(__pyx_defaults9, __pyx_self)->__pyx_arg_connectivity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); @@ -7546,7 +7887,7 @@ static PyObject *__pyx_fuse_1__pyx_pw_4cc3d_7region_graph(PyObject *__pyx_self, } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "region_graph") < 0)) __PYX_ERR(0, 261, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "region_graph") < 0)) __PYX_ERR(0, 286, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -7559,20 +7900,20 @@ static PyObject *__pyx_fuse_1__pyx_pw_4cc3d_7region_graph(PyObject *__pyx_self, } __pyx_v_labels = ((PyArrayObject *)values[0]); if (values[1]) { - __pyx_v_connectivity = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_connectivity == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 263, __pyx_L3_error) + __pyx_v_connectivity = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_connectivity == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 288, __pyx_L3_error) } else { __pyx_v_connectivity = __pyx_dynamic_args->__pyx_arg_connectivity; } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("region_graph", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 261, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("region_graph", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 286, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("cc3d.region_graph", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_labels), __pyx_ptype_5numpy_ndarray, 1, "labels", 0))) __PYX_ERR(0, 262, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_labels), __pyx_ptype_5numpy_ndarray, 1, "labels", 0))) __PYX_ERR(0, 287, __pyx_L1_error) __pyx_r = __pyx_pf_4cc3d_6region_graph(__pyx_self, __pyx_v_labels, __pyx_v_connectivity); /* function exit code */ @@ -7617,11 +7958,11 @@ static PyObject *__pyx_pf_4cc3d_6region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_pybuffernd_labels.rcbuffer = &__pyx_pybuffer_labels; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_labels.rcbuffer->pybuffer, (PyObject*)__pyx_v_labels, &__Pyx_TypeInfo_nn_uint16_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 1, __pyx_stack) == -1)) __PYX_ERR(0, 261, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_labels.rcbuffer->pybuffer, (PyObject*)__pyx_v_labels, &__Pyx_TypeInfo_nn_uint16_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 1, __pyx_stack) == -1)) __PYX_ERR(0, 286, __pyx_L1_error) } __pyx_pybuffernd_labels.diminfo[0].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_labels.diminfo[0].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_labels.diminfo[1].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_labels.diminfo[1].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_labels.diminfo[2].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_labels.diminfo[2].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[2]; - /* "cc3d.pyx":275 + /* "cc3d.pyx":300 * Returns: set of edges * """ * if connectivity not in (6, 18, 26): # <<<<<<<<<<<<<< @@ -7641,29 +7982,29 @@ static PyObject *__pyx_pf_4cc3d_6region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_2 = (__pyx_t_1 != 0); if (unlikely(__pyx_t_2)) { - /* "cc3d.pyx":276 + /* "cc3d.pyx":301 * """ * if connectivity not in (6, 18, 26): * raise ValueError("Only 6, 18, and 26 connectivities are supported. Got: " + str(connectivity)) # <<<<<<<<<<<<<< * * labels = np.asfortranarray(labels) */ - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_connectivity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_connectivity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Only_6_18_and_26_connectivities_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Only_6_18_and_26_connectivities_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __PYX_ERR(0, 276, __pyx_L1_error) + __PYX_ERR(0, 301, __pyx_L1_error) - /* "cc3d.pyx":275 + /* "cc3d.pyx":300 * Returns: set of edges * """ * if connectivity not in (6, 18, 26): # <<<<<<<<<<<<<< @@ -7672,16 +8013,16 @@ static PyObject *__pyx_pf_4cc3d_6region_graph(CYTHON_UNUSED PyObject *__pyx_self */ } - /* "cc3d.pyx":278 + /* "cc3d.pyx":303 * raise ValueError("Only 6, 18, and 26 connectivities are supported. Got: " + str(connectivity)) * * labels = np.asfortranarray(labels) # <<<<<<<<<<<<<< * * cdef vector[INTEGER] res = extract_region_graph( */ - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 278, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_asfortranarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 278, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_asfortranarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; @@ -7696,10 +8037,10 @@ static PyObject *__pyx_pf_4cc3d_6region_graph(CYTHON_UNUSED PyObject *__pyx_self } __pyx_t_4 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_3, ((PyObject *)__pyx_v_labels)) : __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_labels)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 278, __pyx_L1_error) + if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 278, __pyx_L1_error) + if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 303, __pyx_L1_error) __pyx_t_6 = ((PyArrayObject *)__pyx_t_4); { __Pyx_BufFmt_StackElem __pyx_stack[1]; @@ -7716,13 +8057,13 @@ static PyObject *__pyx_pf_4cc3d_6region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_8 = __pyx_t_9 = __pyx_t_10 = 0; } __pyx_pybuffernd_labels.diminfo[0].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_labels.diminfo[0].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_labels.diminfo[1].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_labels.diminfo[1].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_labels.diminfo[2].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_labels.diminfo[2].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[2]; - if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 278, __pyx_L1_error) + if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 303, __pyx_L1_error) } __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_labels, ((PyArrayObject *)__pyx_t_4)); __pyx_t_4 = 0; - /* "cc3d.pyx":281 + /* "cc3d.pyx":306 * * cdef vector[INTEGER] res = extract_region_graph( * &labels[0,0,0], # <<<<<<<<<<<<<< @@ -7747,10 +8088,10 @@ static PyObject *__pyx_pf_4cc3d_6region_graph(CYTHON_UNUSED PyObject *__pyx_self } else if (unlikely(__pyx_t_13 >= __pyx_pybuffernd_labels.diminfo[2].shape)) __pyx_t_7 = 2; if (unlikely(__pyx_t_7 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_7); - __PYX_ERR(0, 281, __pyx_L1_error) + __PYX_ERR(0, 306, __pyx_L1_error) } - /* "cc3d.pyx":280 + /* "cc3d.pyx":305 * labels = np.asfortranarray(labels) * * cdef vector[INTEGER] res = extract_region_graph( # <<<<<<<<<<<<<< @@ -7759,19 +8100,19 @@ static PyObject *__pyx_pf_4cc3d_6region_graph(CYTHON_UNUSED PyObject *__pyx_self */ __pyx_v_res = ((std::vector )cc3d::extract_region_graph(((uint16_t *)(&(*__Pyx_BufPtrStrided3d(uint16_t *, __pyx_pybuffernd_labels.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_labels.diminfo[0].strides, __pyx_t_12, __pyx_pybuffernd_labels.diminfo[1].strides, __pyx_t_13, __pyx_pybuffernd_labels.diminfo[2].strides)))), (__pyx_v_labels->dimensions[0]), (__pyx_v_labels->dimensions[1]), (__pyx_v_labels->dimensions[2]), __pyx_v_connectivity)); - /* "cc3d.pyx":286 + /* "cc3d.pyx":311 * ) * * output = set() # <<<<<<<<<<<<<< * cdef size_t i = 0 * */ - __pyx_t_4 = PySet_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 286, __pyx_L1_error) + __pyx_t_4 = PySet_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 311, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_v_output = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; - /* "cc3d.pyx":287 + /* "cc3d.pyx":312 * * output = set() * cdef size_t i = 0 # <<<<<<<<<<<<<< @@ -7780,7 +8121,7 @@ static PyObject *__pyx_pf_4cc3d_6region_graph(CYTHON_UNUSED PyObject *__pyx_self */ __pyx_v_i = 0; - /* "cc3d.pyx":289 + /* "cc3d.pyx":314 * cdef size_t i = 0 * * for i in range(res.size() // 2): # <<<<<<<<<<<<<< @@ -7792,18 +8133,18 @@ static PyObject *__pyx_pf_4cc3d_6region_graph(CYTHON_UNUSED PyObject *__pyx_self for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) { __pyx_v_i = __pyx_t_16; - /* "cc3d.pyx":291 + /* "cc3d.pyx":316 * for i in range(res.size() // 2): * output.add( * (res[i * 2], res[i*2 + 1]) # <<<<<<<<<<<<<< * ) * */ - __pyx_t_4 = __Pyx_PyInt_From_uint16_t((__pyx_v_res[(__pyx_v_i * 2)])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 291, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_uint16_t((__pyx_v_res[(__pyx_v_i * 2)])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 316, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyInt_From_uint16_t((__pyx_v_res[((__pyx_v_i * 2) + 1)])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 291, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyInt_From_uint16_t((__pyx_v_res[((__pyx_v_i * 2) + 1)])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 316, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 291, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 316, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); @@ -7812,18 +8153,18 @@ static PyObject *__pyx_pf_4cc3d_6region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_4 = 0; __pyx_t_5 = 0; - /* "cc3d.pyx":290 + /* "cc3d.pyx":315 * * for i in range(res.size() // 2): * output.add( # <<<<<<<<<<<<<< * (res[i * 2], res[i*2 + 1]) * ) */ - __pyx_t_17 = PySet_Add(__pyx_v_output, __pyx_t_3); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 290, __pyx_L1_error) + __pyx_t_17 = PySet_Add(__pyx_v_output, __pyx_t_3); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 315, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } - /* "cc3d.pyx":294 + /* "cc3d.pyx":319 * ) * * return output # <<<<<<<<<<<<<< @@ -7835,7 +8176,7 @@ static PyObject *__pyx_pf_4cc3d_6region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_r = __pyx_v_output; goto __pyx_L0; - /* "cc3d.pyx":261 + /* "cc3d.pyx":286 * return out_labels.reshape( (sx), order=order) * * def region_graph( # <<<<<<<<<<<<<< @@ -7874,14 +8215,14 @@ static PyObject *__pyx_pf_4cc3d_42__defaults__(CYTHON_UNUSED PyObject *__pyx_sel PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("__defaults__", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__Pyx_CyFunction_Defaults(__pyx_defaults10, __pyx_self)->__pyx_arg_connectivity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__Pyx_CyFunction_Defaults(__pyx_defaults10, __pyx_self)->__pyx_arg_connectivity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); @@ -7942,7 +8283,7 @@ static PyObject *__pyx_fuse_2__pyx_pw_4cc3d_9region_graph(PyObject *__pyx_self, } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "region_graph") < 0)) __PYX_ERR(0, 261, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "region_graph") < 0)) __PYX_ERR(0, 286, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -7955,20 +8296,20 @@ static PyObject *__pyx_fuse_2__pyx_pw_4cc3d_9region_graph(PyObject *__pyx_self, } __pyx_v_labels = ((PyArrayObject *)values[0]); if (values[1]) { - __pyx_v_connectivity = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_connectivity == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 263, __pyx_L3_error) + __pyx_v_connectivity = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_connectivity == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 288, __pyx_L3_error) } else { __pyx_v_connectivity = __pyx_dynamic_args->__pyx_arg_connectivity; } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("region_graph", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 261, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("region_graph", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 286, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("cc3d.region_graph", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_labels), __pyx_ptype_5numpy_ndarray, 1, "labels", 0))) __PYX_ERR(0, 262, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_labels), __pyx_ptype_5numpy_ndarray, 1, "labels", 0))) __PYX_ERR(0, 287, __pyx_L1_error) __pyx_r = __pyx_pf_4cc3d_8region_graph(__pyx_self, __pyx_v_labels, __pyx_v_connectivity); /* function exit code */ @@ -8013,11 +8354,11 @@ static PyObject *__pyx_pf_4cc3d_8region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_pybuffernd_labels.rcbuffer = &__pyx_pybuffer_labels; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_labels.rcbuffer->pybuffer, (PyObject*)__pyx_v_labels, &__Pyx_TypeInfo_nn_uint32_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 1, __pyx_stack) == -1)) __PYX_ERR(0, 261, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_labels.rcbuffer->pybuffer, (PyObject*)__pyx_v_labels, &__Pyx_TypeInfo_nn_uint32_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 1, __pyx_stack) == -1)) __PYX_ERR(0, 286, __pyx_L1_error) } __pyx_pybuffernd_labels.diminfo[0].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_labels.diminfo[0].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_labels.diminfo[1].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_labels.diminfo[1].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_labels.diminfo[2].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_labels.diminfo[2].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[2]; - /* "cc3d.pyx":275 + /* "cc3d.pyx":300 * Returns: set of edges * """ * if connectivity not in (6, 18, 26): # <<<<<<<<<<<<<< @@ -8037,29 +8378,29 @@ static PyObject *__pyx_pf_4cc3d_8region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_2 = (__pyx_t_1 != 0); if (unlikely(__pyx_t_2)) { - /* "cc3d.pyx":276 + /* "cc3d.pyx":301 * """ * if connectivity not in (6, 18, 26): * raise ValueError("Only 6, 18, and 26 connectivities are supported. Got: " + str(connectivity)) # <<<<<<<<<<<<<< * * labels = np.asfortranarray(labels) */ - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_connectivity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_connectivity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Only_6_18_and_26_connectivities_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Only_6_18_and_26_connectivities_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __PYX_ERR(0, 276, __pyx_L1_error) + __PYX_ERR(0, 301, __pyx_L1_error) - /* "cc3d.pyx":275 + /* "cc3d.pyx":300 * Returns: set of edges * """ * if connectivity not in (6, 18, 26): # <<<<<<<<<<<<<< @@ -8068,16 +8409,16 @@ static PyObject *__pyx_pf_4cc3d_8region_graph(CYTHON_UNUSED PyObject *__pyx_self */ } - /* "cc3d.pyx":278 + /* "cc3d.pyx":303 * raise ValueError("Only 6, 18, and 26 connectivities are supported. Got: " + str(connectivity)) * * labels = np.asfortranarray(labels) # <<<<<<<<<<<<<< * * cdef vector[INTEGER] res = extract_region_graph( */ - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 278, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_asfortranarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 278, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_asfortranarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; @@ -8092,10 +8433,10 @@ static PyObject *__pyx_pf_4cc3d_8region_graph(CYTHON_UNUSED PyObject *__pyx_self } __pyx_t_4 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_3, ((PyObject *)__pyx_v_labels)) : __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_labels)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 278, __pyx_L1_error) + if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 278, __pyx_L1_error) + if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 303, __pyx_L1_error) __pyx_t_6 = ((PyArrayObject *)__pyx_t_4); { __Pyx_BufFmt_StackElem __pyx_stack[1]; @@ -8112,13 +8453,13 @@ static PyObject *__pyx_pf_4cc3d_8region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_8 = __pyx_t_9 = __pyx_t_10 = 0; } __pyx_pybuffernd_labels.diminfo[0].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_labels.diminfo[0].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_labels.diminfo[1].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_labels.diminfo[1].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_labels.diminfo[2].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_labels.diminfo[2].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[2]; - if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 278, __pyx_L1_error) + if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 303, __pyx_L1_error) } __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_labels, ((PyArrayObject *)__pyx_t_4)); __pyx_t_4 = 0; - /* "cc3d.pyx":281 + /* "cc3d.pyx":306 * * cdef vector[INTEGER] res = extract_region_graph( * &labels[0,0,0], # <<<<<<<<<<<<<< @@ -8143,10 +8484,10 @@ static PyObject *__pyx_pf_4cc3d_8region_graph(CYTHON_UNUSED PyObject *__pyx_self } else if (unlikely(__pyx_t_13 >= __pyx_pybuffernd_labels.diminfo[2].shape)) __pyx_t_7 = 2; if (unlikely(__pyx_t_7 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_7); - __PYX_ERR(0, 281, __pyx_L1_error) + __PYX_ERR(0, 306, __pyx_L1_error) } - /* "cc3d.pyx":280 + /* "cc3d.pyx":305 * labels = np.asfortranarray(labels) * * cdef vector[INTEGER] res = extract_region_graph( # <<<<<<<<<<<<<< @@ -8155,19 +8496,19 @@ static PyObject *__pyx_pf_4cc3d_8region_graph(CYTHON_UNUSED PyObject *__pyx_self */ __pyx_v_res = ((std::vector )cc3d::extract_region_graph(((uint32_t *)(&(*__Pyx_BufPtrStrided3d(uint32_t *, __pyx_pybuffernd_labels.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_labels.diminfo[0].strides, __pyx_t_12, __pyx_pybuffernd_labels.diminfo[1].strides, __pyx_t_13, __pyx_pybuffernd_labels.diminfo[2].strides)))), (__pyx_v_labels->dimensions[0]), (__pyx_v_labels->dimensions[1]), (__pyx_v_labels->dimensions[2]), __pyx_v_connectivity)); - /* "cc3d.pyx":286 + /* "cc3d.pyx":311 * ) * * output = set() # <<<<<<<<<<<<<< * cdef size_t i = 0 * */ - __pyx_t_4 = PySet_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 286, __pyx_L1_error) + __pyx_t_4 = PySet_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 311, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_v_output = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; - /* "cc3d.pyx":287 + /* "cc3d.pyx":312 * * output = set() * cdef size_t i = 0 # <<<<<<<<<<<<<< @@ -8176,7 +8517,7 @@ static PyObject *__pyx_pf_4cc3d_8region_graph(CYTHON_UNUSED PyObject *__pyx_self */ __pyx_v_i = 0; - /* "cc3d.pyx":289 + /* "cc3d.pyx":314 * cdef size_t i = 0 * * for i in range(res.size() // 2): # <<<<<<<<<<<<<< @@ -8188,18 +8529,18 @@ static PyObject *__pyx_pf_4cc3d_8region_graph(CYTHON_UNUSED PyObject *__pyx_self for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) { __pyx_v_i = __pyx_t_16; - /* "cc3d.pyx":291 + /* "cc3d.pyx":316 * for i in range(res.size() // 2): * output.add( * (res[i * 2], res[i*2 + 1]) # <<<<<<<<<<<<<< * ) * */ - __pyx_t_4 = __Pyx_PyInt_From_uint32_t((__pyx_v_res[(__pyx_v_i * 2)])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 291, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_uint32_t((__pyx_v_res[(__pyx_v_i * 2)])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 316, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyInt_From_uint32_t((__pyx_v_res[((__pyx_v_i * 2) + 1)])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 291, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyInt_From_uint32_t((__pyx_v_res[((__pyx_v_i * 2) + 1)])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 316, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 291, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 316, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); @@ -8208,18 +8549,18 @@ static PyObject *__pyx_pf_4cc3d_8region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_4 = 0; __pyx_t_5 = 0; - /* "cc3d.pyx":290 + /* "cc3d.pyx":315 * * for i in range(res.size() // 2): * output.add( # <<<<<<<<<<<<<< * (res[i * 2], res[i*2 + 1]) * ) */ - __pyx_t_17 = PySet_Add(__pyx_v_output, __pyx_t_3); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 290, __pyx_L1_error) + __pyx_t_17 = PySet_Add(__pyx_v_output, __pyx_t_3); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 315, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } - /* "cc3d.pyx":294 + /* "cc3d.pyx":319 * ) * * return output # <<<<<<<<<<<<<< @@ -8231,7 +8572,7 @@ static PyObject *__pyx_pf_4cc3d_8region_graph(CYTHON_UNUSED PyObject *__pyx_self __pyx_r = __pyx_v_output; goto __pyx_L0; - /* "cc3d.pyx":261 + /* "cc3d.pyx":286 * return out_labels.reshape( (sx), order=order) * * def region_graph( # <<<<<<<<<<<<<< @@ -8270,14 +8611,14 @@ static PyObject *__pyx_pf_4cc3d_44__defaults__(CYTHON_UNUSED PyObject *__pyx_sel PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("__defaults__", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__Pyx_CyFunction_Defaults(__pyx_defaults11, __pyx_self)->__pyx_arg_connectivity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__Pyx_CyFunction_Defaults(__pyx_defaults11, __pyx_self)->__pyx_arg_connectivity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); @@ -8338,7 +8679,7 @@ static PyObject *__pyx_fuse_3__pyx_pw_4cc3d_11region_graph(PyObject *__pyx_self, } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "region_graph") < 0)) __PYX_ERR(0, 261, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "region_graph") < 0)) __PYX_ERR(0, 286, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -8351,20 +8692,20 @@ static PyObject *__pyx_fuse_3__pyx_pw_4cc3d_11region_graph(PyObject *__pyx_self, } __pyx_v_labels = ((PyArrayObject *)values[0]); if (values[1]) { - __pyx_v_connectivity = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_connectivity == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 263, __pyx_L3_error) + __pyx_v_connectivity = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_connectivity == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 288, __pyx_L3_error) } else { __pyx_v_connectivity = __pyx_dynamic_args->__pyx_arg_connectivity; } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("region_graph", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 261, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("region_graph", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 286, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("cc3d.region_graph", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_labels), __pyx_ptype_5numpy_ndarray, 1, "labels", 0))) __PYX_ERR(0, 262, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_labels), __pyx_ptype_5numpy_ndarray, 1, "labels", 0))) __PYX_ERR(0, 287, __pyx_L1_error) __pyx_r = __pyx_pf_4cc3d_10region_graph(__pyx_self, __pyx_v_labels, __pyx_v_connectivity); /* function exit code */ @@ -8409,11 +8750,11 @@ static PyObject *__pyx_pf_4cc3d_10region_graph(CYTHON_UNUSED PyObject *__pyx_sel __pyx_pybuffernd_labels.rcbuffer = &__pyx_pybuffer_labels; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_labels.rcbuffer->pybuffer, (PyObject*)__pyx_v_labels, &__Pyx_TypeInfo_nn_uint64_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 1, __pyx_stack) == -1)) __PYX_ERR(0, 261, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_labels.rcbuffer->pybuffer, (PyObject*)__pyx_v_labels, &__Pyx_TypeInfo_nn_uint64_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 1, __pyx_stack) == -1)) __PYX_ERR(0, 286, __pyx_L1_error) } __pyx_pybuffernd_labels.diminfo[0].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_labels.diminfo[0].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_labels.diminfo[1].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_labels.diminfo[1].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_labels.diminfo[2].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_labels.diminfo[2].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[2]; - /* "cc3d.pyx":275 + /* "cc3d.pyx":300 * Returns: set of edges * """ * if connectivity not in (6, 18, 26): # <<<<<<<<<<<<<< @@ -8433,29 +8774,29 @@ static PyObject *__pyx_pf_4cc3d_10region_graph(CYTHON_UNUSED PyObject *__pyx_sel __pyx_t_2 = (__pyx_t_1 != 0); if (unlikely(__pyx_t_2)) { - /* "cc3d.pyx":276 + /* "cc3d.pyx":301 * """ * if connectivity not in (6, 18, 26): * raise ValueError("Only 6, 18, and 26 connectivities are supported. Got: " + str(connectivity)) # <<<<<<<<<<<<<< * * labels = np.asfortranarray(labels) */ - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_connectivity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_connectivity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Only_6_18_and_26_connectivities_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Only_6_18_and_26_connectivities_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __PYX_ERR(0, 276, __pyx_L1_error) + __PYX_ERR(0, 301, __pyx_L1_error) - /* "cc3d.pyx":275 + /* "cc3d.pyx":300 * Returns: set of edges * """ * if connectivity not in (6, 18, 26): # <<<<<<<<<<<<<< @@ -8464,16 +8805,16 @@ static PyObject *__pyx_pf_4cc3d_10region_graph(CYTHON_UNUSED PyObject *__pyx_sel */ } - /* "cc3d.pyx":278 + /* "cc3d.pyx":303 * raise ValueError("Only 6, 18, and 26 connectivities are supported. Got: " + str(connectivity)) * * labels = np.asfortranarray(labels) # <<<<<<<<<<<<<< * * cdef vector[INTEGER] res = extract_region_graph( */ - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 278, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_asfortranarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 278, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_asfortranarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; @@ -8488,10 +8829,10 @@ static PyObject *__pyx_pf_4cc3d_10region_graph(CYTHON_UNUSED PyObject *__pyx_sel } __pyx_t_4 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_3, ((PyObject *)__pyx_v_labels)) : __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_labels)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 278, __pyx_L1_error) + if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 278, __pyx_L1_error) + if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 303, __pyx_L1_error) __pyx_t_6 = ((PyArrayObject *)__pyx_t_4); { __Pyx_BufFmt_StackElem __pyx_stack[1]; @@ -8508,13 +8849,13 @@ static PyObject *__pyx_pf_4cc3d_10region_graph(CYTHON_UNUSED PyObject *__pyx_sel __pyx_t_8 = __pyx_t_9 = __pyx_t_10 = 0; } __pyx_pybuffernd_labels.diminfo[0].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_labels.diminfo[0].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_labels.diminfo[1].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_labels.diminfo[1].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_labels.diminfo[2].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_labels.diminfo[2].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[2]; - if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 278, __pyx_L1_error) + if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 303, __pyx_L1_error) } __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_labels, ((PyArrayObject *)__pyx_t_4)); __pyx_t_4 = 0; - /* "cc3d.pyx":281 + /* "cc3d.pyx":306 * * cdef vector[INTEGER] res = extract_region_graph( * &labels[0,0,0], # <<<<<<<<<<<<<< @@ -8539,10 +8880,10 @@ static PyObject *__pyx_pf_4cc3d_10region_graph(CYTHON_UNUSED PyObject *__pyx_sel } else if (unlikely(__pyx_t_13 >= __pyx_pybuffernd_labels.diminfo[2].shape)) __pyx_t_7 = 2; if (unlikely(__pyx_t_7 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_7); - __PYX_ERR(0, 281, __pyx_L1_error) + __PYX_ERR(0, 306, __pyx_L1_error) } - /* "cc3d.pyx":280 + /* "cc3d.pyx":305 * labels = np.asfortranarray(labels) * * cdef vector[INTEGER] res = extract_region_graph( # <<<<<<<<<<<<<< @@ -8551,19 +8892,19 @@ static PyObject *__pyx_pf_4cc3d_10region_graph(CYTHON_UNUSED PyObject *__pyx_sel */ __pyx_v_res = ((std::vector )cc3d::extract_region_graph(((uint64_t *)(&(*__Pyx_BufPtrStrided3d(uint64_t *, __pyx_pybuffernd_labels.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_labels.diminfo[0].strides, __pyx_t_12, __pyx_pybuffernd_labels.diminfo[1].strides, __pyx_t_13, __pyx_pybuffernd_labels.diminfo[2].strides)))), (__pyx_v_labels->dimensions[0]), (__pyx_v_labels->dimensions[1]), (__pyx_v_labels->dimensions[2]), __pyx_v_connectivity)); - /* "cc3d.pyx":286 + /* "cc3d.pyx":311 * ) * * output = set() # <<<<<<<<<<<<<< * cdef size_t i = 0 * */ - __pyx_t_4 = PySet_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 286, __pyx_L1_error) + __pyx_t_4 = PySet_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 311, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_v_output = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; - /* "cc3d.pyx":287 + /* "cc3d.pyx":312 * * output = set() * cdef size_t i = 0 # <<<<<<<<<<<<<< @@ -8572,7 +8913,7 @@ static PyObject *__pyx_pf_4cc3d_10region_graph(CYTHON_UNUSED PyObject *__pyx_sel */ __pyx_v_i = 0; - /* "cc3d.pyx":289 + /* "cc3d.pyx":314 * cdef size_t i = 0 * * for i in range(res.size() // 2): # <<<<<<<<<<<<<< @@ -8584,18 +8925,18 @@ static PyObject *__pyx_pf_4cc3d_10region_graph(CYTHON_UNUSED PyObject *__pyx_sel for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) { __pyx_v_i = __pyx_t_16; - /* "cc3d.pyx":291 + /* "cc3d.pyx":316 * for i in range(res.size() // 2): * output.add( * (res[i * 2], res[i*2 + 1]) # <<<<<<<<<<<<<< * ) * */ - __pyx_t_4 = __Pyx_PyInt_From_uint64_t((__pyx_v_res[(__pyx_v_i * 2)])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 291, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_uint64_t((__pyx_v_res[(__pyx_v_i * 2)])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 316, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyInt_From_uint64_t((__pyx_v_res[((__pyx_v_i * 2) + 1)])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 291, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyInt_From_uint64_t((__pyx_v_res[((__pyx_v_i * 2) + 1)])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 316, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 291, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 316, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); @@ -8604,18 +8945,18 @@ static PyObject *__pyx_pf_4cc3d_10region_graph(CYTHON_UNUSED PyObject *__pyx_sel __pyx_t_4 = 0; __pyx_t_5 = 0; - /* "cc3d.pyx":290 + /* "cc3d.pyx":315 * * for i in range(res.size() // 2): * output.add( # <<<<<<<<<<<<<< * (res[i * 2], res[i*2 + 1]) * ) */ - __pyx_t_17 = PySet_Add(__pyx_v_output, __pyx_t_3); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 290, __pyx_L1_error) + __pyx_t_17 = PySet_Add(__pyx_v_output, __pyx_t_3); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 315, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } - /* "cc3d.pyx":294 + /* "cc3d.pyx":319 * ) * * return output # <<<<<<<<<<<<<< @@ -8627,7 +8968,7 @@ static PyObject *__pyx_pf_4cc3d_10region_graph(CYTHON_UNUSED PyObject *__pyx_sel __pyx_r = __pyx_v_output; goto __pyx_L0; - /* "cc3d.pyx":261 + /* "cc3d.pyx":286 * return out_labels.reshape( (sx), order=order) * * def region_graph( # <<<<<<<<<<<<<< @@ -8666,14 +9007,14 @@ static PyObject *__pyx_pf_4cc3d_46__defaults__(CYTHON_UNUSED PyObject *__pyx_sel PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("__defaults__", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__Pyx_CyFunction_Defaults(__pyx_defaults12, __pyx_self)->__pyx_arg_connectivity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__Pyx_CyFunction_Defaults(__pyx_defaults12, __pyx_self)->__pyx_arg_connectivity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); @@ -8734,7 +9075,7 @@ static PyObject *__pyx_fuse_4__pyx_pw_4cc3d_13region_graph(PyObject *__pyx_self, } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "region_graph") < 0)) __PYX_ERR(0, 261, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "region_graph") < 0)) __PYX_ERR(0, 286, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -8747,20 +9088,20 @@ static PyObject *__pyx_fuse_4__pyx_pw_4cc3d_13region_graph(PyObject *__pyx_self, } __pyx_v_labels = ((PyArrayObject *)values[0]); if (values[1]) { - __pyx_v_connectivity = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_connectivity == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 263, __pyx_L3_error) + __pyx_v_connectivity = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_connectivity == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 288, __pyx_L3_error) } else { __pyx_v_connectivity = __pyx_dynamic_args->__pyx_arg_connectivity; } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("region_graph", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 261, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("region_graph", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 286, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("cc3d.region_graph", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_labels), __pyx_ptype_5numpy_ndarray, 1, "labels", 0))) __PYX_ERR(0, 262, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_labels), __pyx_ptype_5numpy_ndarray, 1, "labels", 0))) __PYX_ERR(0, 287, __pyx_L1_error) __pyx_r = __pyx_pf_4cc3d_12region_graph(__pyx_self, __pyx_v_labels, __pyx_v_connectivity); /* function exit code */ @@ -8805,11 +9146,11 @@ static PyObject *__pyx_pf_4cc3d_12region_graph(CYTHON_UNUSED PyObject *__pyx_sel __pyx_pybuffernd_labels.rcbuffer = &__pyx_pybuffer_labels; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_labels.rcbuffer->pybuffer, (PyObject*)__pyx_v_labels, &__Pyx_TypeInfo_nn_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 1, __pyx_stack) == -1)) __PYX_ERR(0, 261, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_labels.rcbuffer->pybuffer, (PyObject*)__pyx_v_labels, &__Pyx_TypeInfo_nn_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 1, __pyx_stack) == -1)) __PYX_ERR(0, 286, __pyx_L1_error) } __pyx_pybuffernd_labels.diminfo[0].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_labels.diminfo[0].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_labels.diminfo[1].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_labels.diminfo[1].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_labels.diminfo[2].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_labels.diminfo[2].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[2]; - /* "cc3d.pyx":275 + /* "cc3d.pyx":300 * Returns: set of edges * """ * if connectivity not in (6, 18, 26): # <<<<<<<<<<<<<< @@ -8829,29 +9170,29 @@ static PyObject *__pyx_pf_4cc3d_12region_graph(CYTHON_UNUSED PyObject *__pyx_sel __pyx_t_2 = (__pyx_t_1 != 0); if (unlikely(__pyx_t_2)) { - /* "cc3d.pyx":276 + /* "cc3d.pyx":301 * """ * if connectivity not in (6, 18, 26): * raise ValueError("Only 6, 18, and 26 connectivities are supported. Got: " + str(connectivity)) # <<<<<<<<<<<<<< * * labels = np.asfortranarray(labels) */ - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_connectivity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_connectivity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Only_6_18_and_26_connectivities_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Only_6_18_and_26_connectivities_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __PYX_ERR(0, 276, __pyx_L1_error) + __PYX_ERR(0, 301, __pyx_L1_error) - /* "cc3d.pyx":275 + /* "cc3d.pyx":300 * Returns: set of edges * """ * if connectivity not in (6, 18, 26): # <<<<<<<<<<<<<< @@ -8860,16 +9201,16 @@ static PyObject *__pyx_pf_4cc3d_12region_graph(CYTHON_UNUSED PyObject *__pyx_sel */ } - /* "cc3d.pyx":278 + /* "cc3d.pyx":303 * raise ValueError("Only 6, 18, and 26 connectivities are supported. Got: " + str(connectivity)) * * labels = np.asfortranarray(labels) # <<<<<<<<<<<<<< * * cdef vector[INTEGER] res = extract_region_graph( */ - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 278, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_asfortranarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 278, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_asfortranarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; @@ -8884,10 +9225,10 @@ static PyObject *__pyx_pf_4cc3d_12region_graph(CYTHON_UNUSED PyObject *__pyx_sel } __pyx_t_4 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_3, ((PyObject *)__pyx_v_labels)) : __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_labels)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 278, __pyx_L1_error) + if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 278, __pyx_L1_error) + if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 303, __pyx_L1_error) __pyx_t_6 = ((PyArrayObject *)__pyx_t_4); { __Pyx_BufFmt_StackElem __pyx_stack[1]; @@ -8904,13 +9245,13 @@ static PyObject *__pyx_pf_4cc3d_12region_graph(CYTHON_UNUSED PyObject *__pyx_sel __pyx_t_8 = __pyx_t_9 = __pyx_t_10 = 0; } __pyx_pybuffernd_labels.diminfo[0].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_labels.diminfo[0].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_labels.diminfo[1].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_labels.diminfo[1].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_labels.diminfo[2].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_labels.diminfo[2].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[2]; - if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 278, __pyx_L1_error) + if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 303, __pyx_L1_error) } __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_labels, ((PyArrayObject *)__pyx_t_4)); __pyx_t_4 = 0; - /* "cc3d.pyx":281 + /* "cc3d.pyx":306 * * cdef vector[INTEGER] res = extract_region_graph( * &labels[0,0,0], # <<<<<<<<<<<<<< @@ -8935,10 +9276,10 @@ static PyObject *__pyx_pf_4cc3d_12region_graph(CYTHON_UNUSED PyObject *__pyx_sel } else if (unlikely(__pyx_t_13 >= __pyx_pybuffernd_labels.diminfo[2].shape)) __pyx_t_7 = 2; if (unlikely(__pyx_t_7 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_7); - __PYX_ERR(0, 281, __pyx_L1_error) + __PYX_ERR(0, 306, __pyx_L1_error) } - /* "cc3d.pyx":280 + /* "cc3d.pyx":305 * labels = np.asfortranarray(labels) * * cdef vector[INTEGER] res = extract_region_graph( # <<<<<<<<<<<<<< @@ -8947,19 +9288,19 @@ static PyObject *__pyx_pf_4cc3d_12region_graph(CYTHON_UNUSED PyObject *__pyx_sel */ __pyx_v_res = ((std::vector )cc3d::extract_region_graph(((int8_t *)(&(*__Pyx_BufPtrStrided3d(int8_t *, __pyx_pybuffernd_labels.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_labels.diminfo[0].strides, __pyx_t_12, __pyx_pybuffernd_labels.diminfo[1].strides, __pyx_t_13, __pyx_pybuffernd_labels.diminfo[2].strides)))), (__pyx_v_labels->dimensions[0]), (__pyx_v_labels->dimensions[1]), (__pyx_v_labels->dimensions[2]), __pyx_v_connectivity)); - /* "cc3d.pyx":286 + /* "cc3d.pyx":311 * ) * * output = set() # <<<<<<<<<<<<<< * cdef size_t i = 0 * */ - __pyx_t_4 = PySet_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 286, __pyx_L1_error) + __pyx_t_4 = PySet_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 311, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_v_output = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; - /* "cc3d.pyx":287 + /* "cc3d.pyx":312 * * output = set() * cdef size_t i = 0 # <<<<<<<<<<<<<< @@ -8968,7 +9309,7 @@ static PyObject *__pyx_pf_4cc3d_12region_graph(CYTHON_UNUSED PyObject *__pyx_sel */ __pyx_v_i = 0; - /* "cc3d.pyx":289 + /* "cc3d.pyx":314 * cdef size_t i = 0 * * for i in range(res.size() // 2): # <<<<<<<<<<<<<< @@ -8980,18 +9321,18 @@ static PyObject *__pyx_pf_4cc3d_12region_graph(CYTHON_UNUSED PyObject *__pyx_sel for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) { __pyx_v_i = __pyx_t_16; - /* "cc3d.pyx":291 + /* "cc3d.pyx":316 * for i in range(res.size() // 2): * output.add( * (res[i * 2], res[i*2 + 1]) # <<<<<<<<<<<<<< * ) * */ - __pyx_t_4 = __Pyx_PyInt_From_int8_t((__pyx_v_res[(__pyx_v_i * 2)])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 291, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_int8_t((__pyx_v_res[(__pyx_v_i * 2)])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 316, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyInt_From_int8_t((__pyx_v_res[((__pyx_v_i * 2) + 1)])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 291, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyInt_From_int8_t((__pyx_v_res[((__pyx_v_i * 2) + 1)])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 316, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 291, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 316, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); @@ -9000,18 +9341,18 @@ static PyObject *__pyx_pf_4cc3d_12region_graph(CYTHON_UNUSED PyObject *__pyx_sel __pyx_t_4 = 0; __pyx_t_5 = 0; - /* "cc3d.pyx":290 + /* "cc3d.pyx":315 * * for i in range(res.size() // 2): * output.add( # <<<<<<<<<<<<<< * (res[i * 2], res[i*2 + 1]) * ) */ - __pyx_t_17 = PySet_Add(__pyx_v_output, __pyx_t_3); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 290, __pyx_L1_error) + __pyx_t_17 = PySet_Add(__pyx_v_output, __pyx_t_3); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 315, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } - /* "cc3d.pyx":294 + /* "cc3d.pyx":319 * ) * * return output # <<<<<<<<<<<<<< @@ -9023,7 +9364,7 @@ static PyObject *__pyx_pf_4cc3d_12region_graph(CYTHON_UNUSED PyObject *__pyx_sel __pyx_r = __pyx_v_output; goto __pyx_L0; - /* "cc3d.pyx":261 + /* "cc3d.pyx":286 * return out_labels.reshape( (sx), order=order) * * def region_graph( # <<<<<<<<<<<<<< @@ -9062,14 +9403,14 @@ static PyObject *__pyx_pf_4cc3d_48__defaults__(CYTHON_UNUSED PyObject *__pyx_sel PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("__defaults__", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__Pyx_CyFunction_Defaults(__pyx_defaults13, __pyx_self)->__pyx_arg_connectivity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__Pyx_CyFunction_Defaults(__pyx_defaults13, __pyx_self)->__pyx_arg_connectivity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); @@ -9130,7 +9471,7 @@ static PyObject *__pyx_fuse_5__pyx_pw_4cc3d_15region_graph(PyObject *__pyx_self, } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "region_graph") < 0)) __PYX_ERR(0, 261, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "region_graph") < 0)) __PYX_ERR(0, 286, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -9143,20 +9484,20 @@ static PyObject *__pyx_fuse_5__pyx_pw_4cc3d_15region_graph(PyObject *__pyx_self, } __pyx_v_labels = ((PyArrayObject *)values[0]); if (values[1]) { - __pyx_v_connectivity = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_connectivity == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 263, __pyx_L3_error) + __pyx_v_connectivity = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_connectivity == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 288, __pyx_L3_error) } else { __pyx_v_connectivity = __pyx_dynamic_args->__pyx_arg_connectivity; } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("region_graph", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 261, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("region_graph", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 286, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("cc3d.region_graph", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_labels), __pyx_ptype_5numpy_ndarray, 1, "labels", 0))) __PYX_ERR(0, 262, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_labels), __pyx_ptype_5numpy_ndarray, 1, "labels", 0))) __PYX_ERR(0, 287, __pyx_L1_error) __pyx_r = __pyx_pf_4cc3d_14region_graph(__pyx_self, __pyx_v_labels, __pyx_v_connectivity); /* function exit code */ @@ -9201,11 +9542,11 @@ static PyObject *__pyx_pf_4cc3d_14region_graph(CYTHON_UNUSED PyObject *__pyx_sel __pyx_pybuffernd_labels.rcbuffer = &__pyx_pybuffer_labels; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_labels.rcbuffer->pybuffer, (PyObject*)__pyx_v_labels, &__Pyx_TypeInfo_nn_int16_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 1, __pyx_stack) == -1)) __PYX_ERR(0, 261, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_labels.rcbuffer->pybuffer, (PyObject*)__pyx_v_labels, &__Pyx_TypeInfo_nn_int16_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 1, __pyx_stack) == -1)) __PYX_ERR(0, 286, __pyx_L1_error) } __pyx_pybuffernd_labels.diminfo[0].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_labels.diminfo[0].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_labels.diminfo[1].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_labels.diminfo[1].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_labels.diminfo[2].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_labels.diminfo[2].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[2]; - /* "cc3d.pyx":275 + /* "cc3d.pyx":300 * Returns: set of edges * """ * if connectivity not in (6, 18, 26): # <<<<<<<<<<<<<< @@ -9225,29 +9566,29 @@ static PyObject *__pyx_pf_4cc3d_14region_graph(CYTHON_UNUSED PyObject *__pyx_sel __pyx_t_2 = (__pyx_t_1 != 0); if (unlikely(__pyx_t_2)) { - /* "cc3d.pyx":276 + /* "cc3d.pyx":301 * """ * if connectivity not in (6, 18, 26): * raise ValueError("Only 6, 18, and 26 connectivities are supported. Got: " + str(connectivity)) # <<<<<<<<<<<<<< * * labels = np.asfortranarray(labels) */ - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_connectivity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_connectivity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Only_6_18_and_26_connectivities_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Only_6_18_and_26_connectivities_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __PYX_ERR(0, 276, __pyx_L1_error) + __PYX_ERR(0, 301, __pyx_L1_error) - /* "cc3d.pyx":275 + /* "cc3d.pyx":300 * Returns: set of edges * """ * if connectivity not in (6, 18, 26): # <<<<<<<<<<<<<< @@ -9256,16 +9597,16 @@ static PyObject *__pyx_pf_4cc3d_14region_graph(CYTHON_UNUSED PyObject *__pyx_sel */ } - /* "cc3d.pyx":278 + /* "cc3d.pyx":303 * raise ValueError("Only 6, 18, and 26 connectivities are supported. Got: " + str(connectivity)) * * labels = np.asfortranarray(labels) # <<<<<<<<<<<<<< * * cdef vector[INTEGER] res = extract_region_graph( */ - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 278, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_asfortranarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 278, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_asfortranarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; @@ -9280,10 +9621,10 @@ static PyObject *__pyx_pf_4cc3d_14region_graph(CYTHON_UNUSED PyObject *__pyx_sel } __pyx_t_4 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_3, ((PyObject *)__pyx_v_labels)) : __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_labels)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 278, __pyx_L1_error) + if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 278, __pyx_L1_error) + if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 303, __pyx_L1_error) __pyx_t_6 = ((PyArrayObject *)__pyx_t_4); { __Pyx_BufFmt_StackElem __pyx_stack[1]; @@ -9300,13 +9641,13 @@ static PyObject *__pyx_pf_4cc3d_14region_graph(CYTHON_UNUSED PyObject *__pyx_sel __pyx_t_8 = __pyx_t_9 = __pyx_t_10 = 0; } __pyx_pybuffernd_labels.diminfo[0].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_labels.diminfo[0].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_labels.diminfo[1].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_labels.diminfo[1].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_labels.diminfo[2].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_labels.diminfo[2].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[2]; - if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 278, __pyx_L1_error) + if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 303, __pyx_L1_error) } __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_labels, ((PyArrayObject *)__pyx_t_4)); __pyx_t_4 = 0; - /* "cc3d.pyx":281 + /* "cc3d.pyx":306 * * cdef vector[INTEGER] res = extract_region_graph( * &labels[0,0,0], # <<<<<<<<<<<<<< @@ -9331,10 +9672,10 @@ static PyObject *__pyx_pf_4cc3d_14region_graph(CYTHON_UNUSED PyObject *__pyx_sel } else if (unlikely(__pyx_t_13 >= __pyx_pybuffernd_labels.diminfo[2].shape)) __pyx_t_7 = 2; if (unlikely(__pyx_t_7 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_7); - __PYX_ERR(0, 281, __pyx_L1_error) + __PYX_ERR(0, 306, __pyx_L1_error) } - /* "cc3d.pyx":280 + /* "cc3d.pyx":305 * labels = np.asfortranarray(labels) * * cdef vector[INTEGER] res = extract_region_graph( # <<<<<<<<<<<<<< @@ -9343,19 +9684,19 @@ static PyObject *__pyx_pf_4cc3d_14region_graph(CYTHON_UNUSED PyObject *__pyx_sel */ __pyx_v_res = ((std::vector )cc3d::extract_region_graph(((int16_t *)(&(*__Pyx_BufPtrStrided3d(int16_t *, __pyx_pybuffernd_labels.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_labels.diminfo[0].strides, __pyx_t_12, __pyx_pybuffernd_labels.diminfo[1].strides, __pyx_t_13, __pyx_pybuffernd_labels.diminfo[2].strides)))), (__pyx_v_labels->dimensions[0]), (__pyx_v_labels->dimensions[1]), (__pyx_v_labels->dimensions[2]), __pyx_v_connectivity)); - /* "cc3d.pyx":286 + /* "cc3d.pyx":311 * ) * * output = set() # <<<<<<<<<<<<<< * cdef size_t i = 0 * */ - __pyx_t_4 = PySet_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 286, __pyx_L1_error) + __pyx_t_4 = PySet_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 311, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_v_output = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; - /* "cc3d.pyx":287 + /* "cc3d.pyx":312 * * output = set() * cdef size_t i = 0 # <<<<<<<<<<<<<< @@ -9364,7 +9705,7 @@ static PyObject *__pyx_pf_4cc3d_14region_graph(CYTHON_UNUSED PyObject *__pyx_sel */ __pyx_v_i = 0; - /* "cc3d.pyx":289 + /* "cc3d.pyx":314 * cdef size_t i = 0 * * for i in range(res.size() // 2): # <<<<<<<<<<<<<< @@ -9376,18 +9717,18 @@ static PyObject *__pyx_pf_4cc3d_14region_graph(CYTHON_UNUSED PyObject *__pyx_sel for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) { __pyx_v_i = __pyx_t_16; - /* "cc3d.pyx":291 + /* "cc3d.pyx":316 * for i in range(res.size() // 2): * output.add( * (res[i * 2], res[i*2 + 1]) # <<<<<<<<<<<<<< * ) * */ - __pyx_t_4 = __Pyx_PyInt_From_int16_t((__pyx_v_res[(__pyx_v_i * 2)])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 291, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_int16_t((__pyx_v_res[(__pyx_v_i * 2)])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 316, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyInt_From_int16_t((__pyx_v_res[((__pyx_v_i * 2) + 1)])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 291, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyInt_From_int16_t((__pyx_v_res[((__pyx_v_i * 2) + 1)])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 316, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 291, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 316, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); @@ -9396,18 +9737,18 @@ static PyObject *__pyx_pf_4cc3d_14region_graph(CYTHON_UNUSED PyObject *__pyx_sel __pyx_t_4 = 0; __pyx_t_5 = 0; - /* "cc3d.pyx":290 + /* "cc3d.pyx":315 * * for i in range(res.size() // 2): * output.add( # <<<<<<<<<<<<<< * (res[i * 2], res[i*2 + 1]) * ) */ - __pyx_t_17 = PySet_Add(__pyx_v_output, __pyx_t_3); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 290, __pyx_L1_error) + __pyx_t_17 = PySet_Add(__pyx_v_output, __pyx_t_3); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 315, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } - /* "cc3d.pyx":294 + /* "cc3d.pyx":319 * ) * * return output # <<<<<<<<<<<<<< @@ -9419,7 +9760,7 @@ static PyObject *__pyx_pf_4cc3d_14region_graph(CYTHON_UNUSED PyObject *__pyx_sel __pyx_r = __pyx_v_output; goto __pyx_L0; - /* "cc3d.pyx":261 + /* "cc3d.pyx":286 * return out_labels.reshape( (sx), order=order) * * def region_graph( # <<<<<<<<<<<<<< @@ -9458,14 +9799,14 @@ static PyObject *__pyx_pf_4cc3d_50__defaults__(CYTHON_UNUSED PyObject *__pyx_sel PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("__defaults__", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__Pyx_CyFunction_Defaults(__pyx_defaults14, __pyx_self)->__pyx_arg_connectivity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__Pyx_CyFunction_Defaults(__pyx_defaults14, __pyx_self)->__pyx_arg_connectivity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); @@ -9526,7 +9867,7 @@ static PyObject *__pyx_fuse_6__pyx_pw_4cc3d_17region_graph(PyObject *__pyx_self, } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "region_graph") < 0)) __PYX_ERR(0, 261, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "region_graph") < 0)) __PYX_ERR(0, 286, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -9539,20 +9880,20 @@ static PyObject *__pyx_fuse_6__pyx_pw_4cc3d_17region_graph(PyObject *__pyx_self, } __pyx_v_labels = ((PyArrayObject *)values[0]); if (values[1]) { - __pyx_v_connectivity = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_connectivity == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 263, __pyx_L3_error) + __pyx_v_connectivity = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_connectivity == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 288, __pyx_L3_error) } else { __pyx_v_connectivity = __pyx_dynamic_args->__pyx_arg_connectivity; } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("region_graph", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 261, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("region_graph", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 286, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("cc3d.region_graph", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_labels), __pyx_ptype_5numpy_ndarray, 1, "labels", 0))) __PYX_ERR(0, 262, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_labels), __pyx_ptype_5numpy_ndarray, 1, "labels", 0))) __PYX_ERR(0, 287, __pyx_L1_error) __pyx_r = __pyx_pf_4cc3d_16region_graph(__pyx_self, __pyx_v_labels, __pyx_v_connectivity); /* function exit code */ @@ -9597,11 +9938,11 @@ static PyObject *__pyx_pf_4cc3d_16region_graph(CYTHON_UNUSED PyObject *__pyx_sel __pyx_pybuffernd_labels.rcbuffer = &__pyx_pybuffer_labels; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_labels.rcbuffer->pybuffer, (PyObject*)__pyx_v_labels, &__Pyx_TypeInfo_nn_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 1, __pyx_stack) == -1)) __PYX_ERR(0, 261, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_labels.rcbuffer->pybuffer, (PyObject*)__pyx_v_labels, &__Pyx_TypeInfo_nn_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 1, __pyx_stack) == -1)) __PYX_ERR(0, 286, __pyx_L1_error) } __pyx_pybuffernd_labels.diminfo[0].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_labels.diminfo[0].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_labels.diminfo[1].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_labels.diminfo[1].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_labels.diminfo[2].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_labels.diminfo[2].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[2]; - /* "cc3d.pyx":275 + /* "cc3d.pyx":300 * Returns: set of edges * """ * if connectivity not in (6, 18, 26): # <<<<<<<<<<<<<< @@ -9621,29 +9962,29 @@ static PyObject *__pyx_pf_4cc3d_16region_graph(CYTHON_UNUSED PyObject *__pyx_sel __pyx_t_2 = (__pyx_t_1 != 0); if (unlikely(__pyx_t_2)) { - /* "cc3d.pyx":276 + /* "cc3d.pyx":301 * """ * if connectivity not in (6, 18, 26): * raise ValueError("Only 6, 18, and 26 connectivities are supported. Got: " + str(connectivity)) # <<<<<<<<<<<<<< * * labels = np.asfortranarray(labels) */ - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_connectivity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_connectivity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Only_6_18_and_26_connectivities_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Only_6_18_and_26_connectivities_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __PYX_ERR(0, 276, __pyx_L1_error) + __PYX_ERR(0, 301, __pyx_L1_error) - /* "cc3d.pyx":275 + /* "cc3d.pyx":300 * Returns: set of edges * """ * if connectivity not in (6, 18, 26): # <<<<<<<<<<<<<< @@ -9652,16 +9993,16 @@ static PyObject *__pyx_pf_4cc3d_16region_graph(CYTHON_UNUSED PyObject *__pyx_sel */ } - /* "cc3d.pyx":278 + /* "cc3d.pyx":303 * raise ValueError("Only 6, 18, and 26 connectivities are supported. Got: " + str(connectivity)) * * labels = np.asfortranarray(labels) # <<<<<<<<<<<<<< * * cdef vector[INTEGER] res = extract_region_graph( */ - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 278, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_asfortranarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 278, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_asfortranarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; @@ -9676,10 +10017,10 @@ static PyObject *__pyx_pf_4cc3d_16region_graph(CYTHON_UNUSED PyObject *__pyx_sel } __pyx_t_4 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_3, ((PyObject *)__pyx_v_labels)) : __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_labels)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 278, __pyx_L1_error) + if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 278, __pyx_L1_error) + if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 303, __pyx_L1_error) __pyx_t_6 = ((PyArrayObject *)__pyx_t_4); { __Pyx_BufFmt_StackElem __pyx_stack[1]; @@ -9696,13 +10037,13 @@ static PyObject *__pyx_pf_4cc3d_16region_graph(CYTHON_UNUSED PyObject *__pyx_sel __pyx_t_8 = __pyx_t_9 = __pyx_t_10 = 0; } __pyx_pybuffernd_labels.diminfo[0].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_labels.diminfo[0].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_labels.diminfo[1].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_labels.diminfo[1].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_labels.diminfo[2].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_labels.diminfo[2].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[2]; - if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 278, __pyx_L1_error) + if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 303, __pyx_L1_error) } __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_labels, ((PyArrayObject *)__pyx_t_4)); __pyx_t_4 = 0; - /* "cc3d.pyx":281 + /* "cc3d.pyx":306 * * cdef vector[INTEGER] res = extract_region_graph( * &labels[0,0,0], # <<<<<<<<<<<<<< @@ -9727,10 +10068,10 @@ static PyObject *__pyx_pf_4cc3d_16region_graph(CYTHON_UNUSED PyObject *__pyx_sel } else if (unlikely(__pyx_t_13 >= __pyx_pybuffernd_labels.diminfo[2].shape)) __pyx_t_7 = 2; if (unlikely(__pyx_t_7 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_7); - __PYX_ERR(0, 281, __pyx_L1_error) + __PYX_ERR(0, 306, __pyx_L1_error) } - /* "cc3d.pyx":280 + /* "cc3d.pyx":305 * labels = np.asfortranarray(labels) * * cdef vector[INTEGER] res = extract_region_graph( # <<<<<<<<<<<<<< @@ -9739,19 +10080,19 @@ static PyObject *__pyx_pf_4cc3d_16region_graph(CYTHON_UNUSED PyObject *__pyx_sel */ __pyx_v_res = ((std::vector )cc3d::extract_region_graph(((int32_t *)(&(*__Pyx_BufPtrStrided3d(int32_t *, __pyx_pybuffernd_labels.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_labels.diminfo[0].strides, __pyx_t_12, __pyx_pybuffernd_labels.diminfo[1].strides, __pyx_t_13, __pyx_pybuffernd_labels.diminfo[2].strides)))), (__pyx_v_labels->dimensions[0]), (__pyx_v_labels->dimensions[1]), (__pyx_v_labels->dimensions[2]), __pyx_v_connectivity)); - /* "cc3d.pyx":286 + /* "cc3d.pyx":311 * ) * * output = set() # <<<<<<<<<<<<<< * cdef size_t i = 0 * */ - __pyx_t_4 = PySet_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 286, __pyx_L1_error) + __pyx_t_4 = PySet_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 311, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_v_output = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; - /* "cc3d.pyx":287 + /* "cc3d.pyx":312 * * output = set() * cdef size_t i = 0 # <<<<<<<<<<<<<< @@ -9760,7 +10101,7 @@ static PyObject *__pyx_pf_4cc3d_16region_graph(CYTHON_UNUSED PyObject *__pyx_sel */ __pyx_v_i = 0; - /* "cc3d.pyx":289 + /* "cc3d.pyx":314 * cdef size_t i = 0 * * for i in range(res.size() // 2): # <<<<<<<<<<<<<< @@ -9772,18 +10113,18 @@ static PyObject *__pyx_pf_4cc3d_16region_graph(CYTHON_UNUSED PyObject *__pyx_sel for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) { __pyx_v_i = __pyx_t_16; - /* "cc3d.pyx":291 + /* "cc3d.pyx":316 * for i in range(res.size() // 2): * output.add( * (res[i * 2], res[i*2 + 1]) # <<<<<<<<<<<<<< * ) * */ - __pyx_t_4 = __Pyx_PyInt_From_int32_t((__pyx_v_res[(__pyx_v_i * 2)])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 291, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_int32_t((__pyx_v_res[(__pyx_v_i * 2)])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 316, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyInt_From_int32_t((__pyx_v_res[((__pyx_v_i * 2) + 1)])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 291, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyInt_From_int32_t((__pyx_v_res[((__pyx_v_i * 2) + 1)])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 316, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 291, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 316, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); @@ -9792,18 +10133,18 @@ static PyObject *__pyx_pf_4cc3d_16region_graph(CYTHON_UNUSED PyObject *__pyx_sel __pyx_t_4 = 0; __pyx_t_5 = 0; - /* "cc3d.pyx":290 + /* "cc3d.pyx":315 * * for i in range(res.size() // 2): * output.add( # <<<<<<<<<<<<<< * (res[i * 2], res[i*2 + 1]) * ) */ - __pyx_t_17 = PySet_Add(__pyx_v_output, __pyx_t_3); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 290, __pyx_L1_error) + __pyx_t_17 = PySet_Add(__pyx_v_output, __pyx_t_3); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 315, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } - /* "cc3d.pyx":294 + /* "cc3d.pyx":319 * ) * * return output # <<<<<<<<<<<<<< @@ -9815,7 +10156,7 @@ static PyObject *__pyx_pf_4cc3d_16region_graph(CYTHON_UNUSED PyObject *__pyx_sel __pyx_r = __pyx_v_output; goto __pyx_L0; - /* "cc3d.pyx":261 + /* "cc3d.pyx":286 * return out_labels.reshape( (sx), order=order) * * def region_graph( # <<<<<<<<<<<<<< @@ -9854,14 +10195,14 @@ static PyObject *__pyx_pf_4cc3d_52__defaults__(CYTHON_UNUSED PyObject *__pyx_sel PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("__defaults__", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__Pyx_CyFunction_Defaults(__pyx_defaults15, __pyx_self)->__pyx_arg_connectivity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__Pyx_CyFunction_Defaults(__pyx_defaults15, __pyx_self)->__pyx_arg_connectivity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); @@ -9922,7 +10263,7 @@ static PyObject *__pyx_fuse_7__pyx_pw_4cc3d_19region_graph(PyObject *__pyx_self, } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "region_graph") < 0)) __PYX_ERR(0, 261, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "region_graph") < 0)) __PYX_ERR(0, 286, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -9935,20 +10276,20 @@ static PyObject *__pyx_fuse_7__pyx_pw_4cc3d_19region_graph(PyObject *__pyx_self, } __pyx_v_labels = ((PyArrayObject *)values[0]); if (values[1]) { - __pyx_v_connectivity = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_connectivity == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 263, __pyx_L3_error) + __pyx_v_connectivity = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_connectivity == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 288, __pyx_L3_error) } else { __pyx_v_connectivity = __pyx_dynamic_args->__pyx_arg_connectivity; } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("region_graph", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 261, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("region_graph", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 286, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("cc3d.region_graph", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_labels), __pyx_ptype_5numpy_ndarray, 1, "labels", 0))) __PYX_ERR(0, 262, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_labels), __pyx_ptype_5numpy_ndarray, 1, "labels", 0))) __PYX_ERR(0, 287, __pyx_L1_error) __pyx_r = __pyx_pf_4cc3d_18region_graph(__pyx_self, __pyx_v_labels, __pyx_v_connectivity); /* function exit code */ @@ -9993,11 +10334,11 @@ static PyObject *__pyx_pf_4cc3d_18region_graph(CYTHON_UNUSED PyObject *__pyx_sel __pyx_pybuffernd_labels.rcbuffer = &__pyx_pybuffer_labels; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_labels.rcbuffer->pybuffer, (PyObject*)__pyx_v_labels, &__Pyx_TypeInfo_nn_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 1, __pyx_stack) == -1)) __PYX_ERR(0, 261, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_labels.rcbuffer->pybuffer, (PyObject*)__pyx_v_labels, &__Pyx_TypeInfo_nn_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 1, __pyx_stack) == -1)) __PYX_ERR(0, 286, __pyx_L1_error) } __pyx_pybuffernd_labels.diminfo[0].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_labels.diminfo[0].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_labels.diminfo[1].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_labels.diminfo[1].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_labels.diminfo[2].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_labels.diminfo[2].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[2]; - /* "cc3d.pyx":275 + /* "cc3d.pyx":300 * Returns: set of edges * """ * if connectivity not in (6, 18, 26): # <<<<<<<<<<<<<< @@ -10017,29 +10358,29 @@ static PyObject *__pyx_pf_4cc3d_18region_graph(CYTHON_UNUSED PyObject *__pyx_sel __pyx_t_2 = (__pyx_t_1 != 0); if (unlikely(__pyx_t_2)) { - /* "cc3d.pyx":276 + /* "cc3d.pyx":301 * """ * if connectivity not in (6, 18, 26): * raise ValueError("Only 6, 18, and 26 connectivities are supported. Got: " + str(connectivity)) # <<<<<<<<<<<<<< * * labels = np.asfortranarray(labels) */ - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_connectivity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_connectivity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Only_6_18_and_26_connectivities_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Only_6_18_and_26_connectivities_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __PYX_ERR(0, 276, __pyx_L1_error) + __PYX_ERR(0, 301, __pyx_L1_error) - /* "cc3d.pyx":275 + /* "cc3d.pyx":300 * Returns: set of edges * """ * if connectivity not in (6, 18, 26): # <<<<<<<<<<<<<< @@ -10048,16 +10389,16 @@ static PyObject *__pyx_pf_4cc3d_18region_graph(CYTHON_UNUSED PyObject *__pyx_sel */ } - /* "cc3d.pyx":278 + /* "cc3d.pyx":303 * raise ValueError("Only 6, 18, and 26 connectivities are supported. Got: " + str(connectivity)) * * labels = np.asfortranarray(labels) # <<<<<<<<<<<<<< * * cdef vector[INTEGER] res = extract_region_graph( */ - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 278, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_asfortranarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 278, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_asfortranarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; @@ -10072,10 +10413,10 @@ static PyObject *__pyx_pf_4cc3d_18region_graph(CYTHON_UNUSED PyObject *__pyx_sel } __pyx_t_4 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_3, ((PyObject *)__pyx_v_labels)) : __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_labels)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 278, __pyx_L1_error) + if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 278, __pyx_L1_error) + if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 303, __pyx_L1_error) __pyx_t_6 = ((PyArrayObject *)__pyx_t_4); { __Pyx_BufFmt_StackElem __pyx_stack[1]; @@ -10092,13 +10433,13 @@ static PyObject *__pyx_pf_4cc3d_18region_graph(CYTHON_UNUSED PyObject *__pyx_sel __pyx_t_8 = __pyx_t_9 = __pyx_t_10 = 0; } __pyx_pybuffernd_labels.diminfo[0].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_labels.diminfo[0].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_labels.diminfo[1].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_labels.diminfo[1].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_labels.diminfo[2].strides = __pyx_pybuffernd_labels.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_labels.diminfo[2].shape = __pyx_pybuffernd_labels.rcbuffer->pybuffer.shape[2]; - if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 278, __pyx_L1_error) + if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 303, __pyx_L1_error) } __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_labels, ((PyArrayObject *)__pyx_t_4)); __pyx_t_4 = 0; - /* "cc3d.pyx":281 + /* "cc3d.pyx":306 * * cdef vector[INTEGER] res = extract_region_graph( * &labels[0,0,0], # <<<<<<<<<<<<<< @@ -10123,10 +10464,10 @@ static PyObject *__pyx_pf_4cc3d_18region_graph(CYTHON_UNUSED PyObject *__pyx_sel } else if (unlikely(__pyx_t_13 >= __pyx_pybuffernd_labels.diminfo[2].shape)) __pyx_t_7 = 2; if (unlikely(__pyx_t_7 != -1)) { __Pyx_RaiseBufferIndexError(__pyx_t_7); - __PYX_ERR(0, 281, __pyx_L1_error) + __PYX_ERR(0, 306, __pyx_L1_error) } - /* "cc3d.pyx":280 + /* "cc3d.pyx":305 * labels = np.asfortranarray(labels) * * cdef vector[INTEGER] res = extract_region_graph( # <<<<<<<<<<<<<< @@ -10135,19 +10476,19 @@ static PyObject *__pyx_pf_4cc3d_18region_graph(CYTHON_UNUSED PyObject *__pyx_sel */ __pyx_v_res = ((std::vector )cc3d::extract_region_graph(((int64_t *)(&(*__Pyx_BufPtrStrided3d(int64_t *, __pyx_pybuffernd_labels.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_labels.diminfo[0].strides, __pyx_t_12, __pyx_pybuffernd_labels.diminfo[1].strides, __pyx_t_13, __pyx_pybuffernd_labels.diminfo[2].strides)))), (__pyx_v_labels->dimensions[0]), (__pyx_v_labels->dimensions[1]), (__pyx_v_labels->dimensions[2]), __pyx_v_connectivity)); - /* "cc3d.pyx":286 + /* "cc3d.pyx":311 * ) * * output = set() # <<<<<<<<<<<<<< * cdef size_t i = 0 * */ - __pyx_t_4 = PySet_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 286, __pyx_L1_error) + __pyx_t_4 = PySet_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 311, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_v_output = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; - /* "cc3d.pyx":287 + /* "cc3d.pyx":312 * * output = set() * cdef size_t i = 0 # <<<<<<<<<<<<<< @@ -10156,7 +10497,7 @@ static PyObject *__pyx_pf_4cc3d_18region_graph(CYTHON_UNUSED PyObject *__pyx_sel */ __pyx_v_i = 0; - /* "cc3d.pyx":289 + /* "cc3d.pyx":314 * cdef size_t i = 0 * * for i in range(res.size() // 2): # <<<<<<<<<<<<<< @@ -10168,18 +10509,18 @@ static PyObject *__pyx_pf_4cc3d_18region_graph(CYTHON_UNUSED PyObject *__pyx_sel for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) { __pyx_v_i = __pyx_t_16; - /* "cc3d.pyx":291 + /* "cc3d.pyx":316 * for i in range(res.size() // 2): * output.add( * (res[i * 2], res[i*2 + 1]) # <<<<<<<<<<<<<< * ) * */ - __pyx_t_4 = __Pyx_PyInt_From_int64_t((__pyx_v_res[(__pyx_v_i * 2)])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 291, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_int64_t((__pyx_v_res[(__pyx_v_i * 2)])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 316, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyInt_From_int64_t((__pyx_v_res[((__pyx_v_i * 2) + 1)])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 291, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyInt_From_int64_t((__pyx_v_res[((__pyx_v_i * 2) + 1)])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 316, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 291, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 316, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); @@ -10188,18 +10529,18 @@ static PyObject *__pyx_pf_4cc3d_18region_graph(CYTHON_UNUSED PyObject *__pyx_sel __pyx_t_4 = 0; __pyx_t_5 = 0; - /* "cc3d.pyx":290 + /* "cc3d.pyx":315 * * for i in range(res.size() // 2): * output.add( # <<<<<<<<<<<<<< * (res[i * 2], res[i*2 + 1]) * ) */ - __pyx_t_17 = PySet_Add(__pyx_v_output, __pyx_t_3); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 290, __pyx_L1_error) + __pyx_t_17 = PySet_Add(__pyx_v_output, __pyx_t_3); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 315, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } - /* "cc3d.pyx":294 + /* "cc3d.pyx":319 * ) * * return output # <<<<<<<<<<<<<< @@ -10211,7 +10552,7 @@ static PyObject *__pyx_pf_4cc3d_18region_graph(CYTHON_UNUSED PyObject *__pyx_sel __pyx_r = __pyx_v_output; goto __pyx_L0; - /* "cc3d.pyx":261 + /* "cc3d.pyx":286 * return out_labels.reshape( (sx), order=order) * * def region_graph( # <<<<<<<<<<<<<< @@ -27067,9 +27408,9 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {0, 0, 0, 0, 0, 0, 0} }; static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 107, __pyx_L1_error) - __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 113, __pyx_L1_error) - __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 112, __pyx_L1_error) + __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 118, __pyx_L1_error) + __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 286, __pyx_L1_error) __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(1, 109, __pyx_L1_error) __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(2, 856, __pyx_L1_error) __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(2, 1038, __pyx_L1_error) @@ -27086,39 +27427,39 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - /* "cc3d.pyx":107 + /* "cc3d.pyx":112 * out_dtype = np.dtype(out_dtype) * if out_dtype not in (np.uint16, np.uint32, np.uint64): * raise TypeError( # <<<<<<<<<<<<<< * """Only unsigned 16, 32, and 64 bit out data types are * supported through the python interface (C++ can handle any integer type).""" */ - __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_u_Only_unsigned_16_32_and_64_bit_o); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 107, __pyx_L1_error) + __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_u_Only_unsigned_16_32_and_64_bit_o); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__2); __Pyx_GIVEREF(__pyx_tuple__2); - /* "cc3d.pyx":118 + /* "cc3d.pyx":123 * * if data.size == 0: * return np.zeros(shape=(0,), dtype=np.uint32) # <<<<<<<<<<<<<< * * order = 'F' if data.flags['F_CONTIGUOUS'] else 'C' */ - __pyx_tuple__3 = PyTuple_Pack(1, __pyx_int_0); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 118, __pyx_L1_error) + __pyx_tuple__3 = PyTuple_Pack(1, __pyx_int_0); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__3); __Pyx_GIVEREF(__pyx_tuple__3); - /* "cc3d.pyx":261 + /* "cc3d.pyx":286 * return out_labels.reshape( (sx), order=order) * * def region_graph( # <<<<<<<<<<<<<< * cnp.ndarray[INTEGER, ndim=3, cast=True] labels, * int connectivity=26 */ - __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_No_matching_signature_found); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_No_matching_signature_found); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__8); __Pyx_GIVEREF(__pyx_tuple__8); - __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_Function_call_with_ambiguous_arg); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_Function_call_with_ambiguous_arg); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__9); __Pyx_GIVEREF(__pyx_tuple__9); @@ -27391,29 +27732,29 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple__34); __Pyx_GIVEREF(__pyx_tuple__34); - /* "cc3d.pyx":73 + /* "cc3d.pyx":78 * pass * * def connected_components( # <<<<<<<<<<<<<< * data, int64_t max_labels=-1, * int64_t connectivity=26, out_dtype=np.uint32 */ - __pyx_tuple__35 = PyTuple_Pack(20, __pyx_n_s_data, __pyx_n_s_max_labels, __pyx_n_s_connectivity, __pyx_n_s_out_dtype, __pyx_n_s_dims, __pyx_n_s_order, __pyx_n_s_shape, __pyx_n_s_sx, __pyx_n_s_sy, __pyx_n_s_sz, __pyx_n_s_arr_memview8u, __pyx_n_s_arr_memview16u, __pyx_n_s_arr_memview32u, __pyx_n_s_arr_memview64u, __pyx_n_s_voxels, __pyx_n_s_out_labels16, __pyx_n_s_out_labels32, __pyx_n_s_out_labels64, __pyx_n_s_out_labels, __pyx_n_s_dtype); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 73, __pyx_L1_error) + __pyx_tuple__35 = PyTuple_Pack(20, __pyx_n_s_data, __pyx_n_s_max_labels, __pyx_n_s_connectivity, __pyx_n_s_out_dtype, __pyx_n_s_dims, __pyx_n_s_order, __pyx_n_s_shape, __pyx_n_s_sx, __pyx_n_s_sy, __pyx_n_s_sz, __pyx_n_s_arr_memview8u, __pyx_n_s_arr_memview16u, __pyx_n_s_arr_memview32u, __pyx_n_s_arr_memview64u, __pyx_n_s_voxels, __pyx_n_s_out_labels16, __pyx_n_s_out_labels32, __pyx_n_s_out_labels64, __pyx_n_s_out_labels, __pyx_n_s_dtype); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 78, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__35); __Pyx_GIVEREF(__pyx_tuple__35); - __pyx_codeobj__36 = (PyObject*)__Pyx_PyCode_New(4, 0, 20, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cc3d_pyx, __pyx_n_s_connected_components, 73, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__36)) __PYX_ERR(0, 73, __pyx_L1_error) + __pyx_codeobj__36 = (PyObject*)__Pyx_PyCode_New(4, 0, 20, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cc3d_pyx, __pyx_n_s_connected_components, 78, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__36)) __PYX_ERR(0, 78, __pyx_L1_error) - /* "cc3d.pyx":261 + /* "cc3d.pyx":286 * return out_labels.reshape( (sx), order=order) * * def region_graph( # <<<<<<<<<<<<<< * cnp.ndarray[INTEGER, ndim=3, cast=True] labels, * int connectivity=26 */ - __pyx_tuple__37 = PyTuple_Pack(5, __pyx_n_s_labels, __pyx_n_s_connectivity, __pyx_n_s_res, __pyx_n_s_output, __pyx_n_s_i); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_tuple__37 = PyTuple_Pack(5, __pyx_n_s_labels, __pyx_n_s_connectivity, __pyx_n_s_res, __pyx_n_s_output, __pyx_n_s_i); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__37); __Pyx_GIVEREF(__pyx_tuple__37); - __pyx_codeobj__38 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__37, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cc3d_pyx, __pyx_n_s_region_graph, 261, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__38)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_codeobj__38 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__37, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cc3d_pyx, __pyx_n_s_region_graph, 286, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__38)) __PYX_ERR(0, 286, __pyx_L1_error) /* "View.MemoryView":286 * return self.name @@ -27912,173 +28253,173 @@ if (!__Pyx_RefNanny) { */ if (PyDict_SetItem(__pyx_d, __pyx_n_s_VERSION, __pyx_kp_u_1_8_0) < 0) __PYX_ERR(0, 43, __pyx_L1_error) - /* "cc3d.pyx":69 + /* "cc3d.pyx":74 * int64_t * * class DimensionError(Exception): # <<<<<<<<<<<<<< * """The array has the wrong number of dimensions.""" * pass */ - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 74, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); __Pyx_GIVEREF(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); - __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 69, __pyx_L1_error) + __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 74, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_t_1, __pyx_n_s_DimensionError, __pyx_n_s_DimensionError, (PyObject *) NULL, __pyx_n_s_cc3d, __pyx_kp_s_The_array_has_the_wrong_number_o); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 69, __pyx_L1_error) + __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_t_1, __pyx_n_s_DimensionError, __pyx_n_s_DimensionError, (PyObject *) NULL, __pyx_n_s_cc3d, __pyx_kp_s_The_array_has_the_wrong_number_o); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 74, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_DimensionError, __pyx_t_1, __pyx_t_3, NULL, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 69, __pyx_L1_error) + __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_DimensionError, __pyx_t_1, __pyx_t_3, NULL, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 74, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_DimensionError, __pyx_t_4) < 0) __PYX_ERR(0, 69, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_DimensionError, __pyx_t_4) < 0) __PYX_ERR(0, 74, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "cc3d.pyx":75 + /* "cc3d.pyx":80 * def connected_components( * data, int64_t max_labels=-1, * int64_t connectivity=26, out_dtype=np.uint32 # <<<<<<<<<<<<<< * ): * """ */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 75, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 80, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_uint32); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 75, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_uint32); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 80, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_k_ = __pyx_t_2; __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; - /* "cc3d.pyx":73 + /* "cc3d.pyx":78 * pass * * def connected_components( # <<<<<<<<<<<<<< * data, int64_t max_labels=-1, * int64_t connectivity=26, out_dtype=np.uint32 */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4cc3d_1connected_components, NULL, __pyx_n_s_cc3d); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 73, __pyx_L1_error) + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4cc3d_1connected_components, NULL, __pyx_n_s_cc3d); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 78, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_connected_components, __pyx_t_2) < 0) __PYX_ERR(0, 73, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_connected_components, __pyx_t_2) < 0) __PYX_ERR(0, 78, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "cc3d.pyx":263 + /* "cc3d.pyx":288 * def region_graph( * cnp.ndarray[INTEGER, ndim=3, cast=True] labels, * int connectivity=26 # <<<<<<<<<<<<<< * ): * """ */ - __pyx_t_2 = __Pyx_PyInt_From_long(26); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 263, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_long(26); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 288, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - /* "cc3d.pyx":261 + /* "cc3d.pyx":286 * return out_labels.reshape( (sx), order=order) * * def region_graph( # <<<<<<<<<<<<<< * cnp.ndarray[INTEGER, ndim=3, cast=True] labels, * int connectivity=26 */ - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __pyx_t_2 = 0; - /* "cc3d.pyx":263 + /* "cc3d.pyx":288 * def region_graph( * cnp.ndarray[INTEGER, ndim=3, cast=True] labels, * int connectivity=26 # <<<<<<<<<<<<<< * ): * """ */ - __pyx_t_2 = __Pyx_PyInt_From_long(26); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 263, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_long(26); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 288, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_k__4 = __pyx_t_2; __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; - /* "cc3d.pyx":261 + /* "cc3d.pyx":286 * return out_labels.reshape( (sx), order=order) * * def region_graph( # <<<<<<<<<<<<<< * cnp.ndarray[INTEGER, ndim=3, cast=True] labels, * int connectivity=26 */ - __pyx_t_2 = __Pyx_PyDict_NewPresized(8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyDict_NewPresized(8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __pyx_FusedFunction_NewEx(&__pyx_fuse_0__pyx_mdef_4cc3d_5region_graph, 0, __pyx_n_s_region_graph, NULL, __pyx_n_s_cc3d, __pyx_d, ((PyObject *)__pyx_codeobj__38)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_3 = __pyx_FusedFunction_NewEx(&__pyx_fuse_0__pyx_mdef_4cc3d_5region_graph, 0, __pyx_n_s_region_graph, NULL, __pyx_n_s_cc3d, __pyx_d, ((PyObject *)__pyx_codeobj__38)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (!__Pyx_CyFunction_InitDefaults(__pyx_t_3, sizeof(__pyx_defaults8), 0)) __PYX_ERR(0, 261, __pyx_L1_error) + if (!__Pyx_CyFunction_InitDefaults(__pyx_t_3, sizeof(__pyx_defaults8), 0)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_CyFunction_Defaults(__pyx_defaults8, __pyx_t_3)->__pyx_arg_connectivity = 26; __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_3, __pyx_t_1); __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_3, __pyx_pf_4cc3d_38__defaults__); - if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_uint8_t, __pyx_t_3) < 0) __PYX_ERR(0, 261, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_uint8_t, __pyx_t_3) < 0) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __pyx_FusedFunction_NewEx(&__pyx_fuse_1__pyx_mdef_4cc3d_7region_graph, 0, __pyx_n_s_region_graph, NULL, __pyx_n_s_cc3d, __pyx_d, ((PyObject *)__pyx_codeobj__38)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_3 = __pyx_FusedFunction_NewEx(&__pyx_fuse_1__pyx_mdef_4cc3d_7region_graph, 0, __pyx_n_s_region_graph, NULL, __pyx_n_s_cc3d, __pyx_d, ((PyObject *)__pyx_codeobj__38)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (!__Pyx_CyFunction_InitDefaults(__pyx_t_3, sizeof(__pyx_defaults9), 0)) __PYX_ERR(0, 261, __pyx_L1_error) + if (!__Pyx_CyFunction_InitDefaults(__pyx_t_3, sizeof(__pyx_defaults9), 0)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_CyFunction_Defaults(__pyx_defaults9, __pyx_t_3)->__pyx_arg_connectivity = 26; __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_3, __pyx_t_1); __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_3, __pyx_pf_4cc3d_40__defaults__); - if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_uint16_t, __pyx_t_3) < 0) __PYX_ERR(0, 261, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_uint16_t, __pyx_t_3) < 0) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __pyx_FusedFunction_NewEx(&__pyx_fuse_2__pyx_mdef_4cc3d_9region_graph, 0, __pyx_n_s_region_graph, NULL, __pyx_n_s_cc3d, __pyx_d, ((PyObject *)__pyx_codeobj__38)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_3 = __pyx_FusedFunction_NewEx(&__pyx_fuse_2__pyx_mdef_4cc3d_9region_graph, 0, __pyx_n_s_region_graph, NULL, __pyx_n_s_cc3d, __pyx_d, ((PyObject *)__pyx_codeobj__38)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (!__Pyx_CyFunction_InitDefaults(__pyx_t_3, sizeof(__pyx_defaults10), 0)) __PYX_ERR(0, 261, __pyx_L1_error) + if (!__Pyx_CyFunction_InitDefaults(__pyx_t_3, sizeof(__pyx_defaults10), 0)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_CyFunction_Defaults(__pyx_defaults10, __pyx_t_3)->__pyx_arg_connectivity = 26; __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_3, __pyx_t_1); __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_3, __pyx_pf_4cc3d_42__defaults__); - if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_uint32_t, __pyx_t_3) < 0) __PYX_ERR(0, 261, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_uint32_t, __pyx_t_3) < 0) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __pyx_FusedFunction_NewEx(&__pyx_fuse_3__pyx_mdef_4cc3d_11region_graph, 0, __pyx_n_s_region_graph, NULL, __pyx_n_s_cc3d, __pyx_d, ((PyObject *)__pyx_codeobj__38)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_3 = __pyx_FusedFunction_NewEx(&__pyx_fuse_3__pyx_mdef_4cc3d_11region_graph, 0, __pyx_n_s_region_graph, NULL, __pyx_n_s_cc3d, __pyx_d, ((PyObject *)__pyx_codeobj__38)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (!__Pyx_CyFunction_InitDefaults(__pyx_t_3, sizeof(__pyx_defaults11), 0)) __PYX_ERR(0, 261, __pyx_L1_error) + if (!__Pyx_CyFunction_InitDefaults(__pyx_t_3, sizeof(__pyx_defaults11), 0)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_CyFunction_Defaults(__pyx_defaults11, __pyx_t_3)->__pyx_arg_connectivity = 26; __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_3, __pyx_t_1); __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_3, __pyx_pf_4cc3d_44__defaults__); - if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_uint64_t, __pyx_t_3) < 0) __PYX_ERR(0, 261, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_uint64_t, __pyx_t_3) < 0) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __pyx_FusedFunction_NewEx(&__pyx_fuse_4__pyx_mdef_4cc3d_13region_graph, 0, __pyx_n_s_region_graph, NULL, __pyx_n_s_cc3d, __pyx_d, ((PyObject *)__pyx_codeobj__38)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_3 = __pyx_FusedFunction_NewEx(&__pyx_fuse_4__pyx_mdef_4cc3d_13region_graph, 0, __pyx_n_s_region_graph, NULL, __pyx_n_s_cc3d, __pyx_d, ((PyObject *)__pyx_codeobj__38)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (!__Pyx_CyFunction_InitDefaults(__pyx_t_3, sizeof(__pyx_defaults12), 0)) __PYX_ERR(0, 261, __pyx_L1_error) + if (!__Pyx_CyFunction_InitDefaults(__pyx_t_3, sizeof(__pyx_defaults12), 0)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_CyFunction_Defaults(__pyx_defaults12, __pyx_t_3)->__pyx_arg_connectivity = 26; __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_3, __pyx_t_1); __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_3, __pyx_pf_4cc3d_46__defaults__); - if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_int8_t, __pyx_t_3) < 0) __PYX_ERR(0, 261, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_int8_t, __pyx_t_3) < 0) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __pyx_FusedFunction_NewEx(&__pyx_fuse_5__pyx_mdef_4cc3d_15region_graph, 0, __pyx_n_s_region_graph, NULL, __pyx_n_s_cc3d, __pyx_d, ((PyObject *)__pyx_codeobj__38)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_3 = __pyx_FusedFunction_NewEx(&__pyx_fuse_5__pyx_mdef_4cc3d_15region_graph, 0, __pyx_n_s_region_graph, NULL, __pyx_n_s_cc3d, __pyx_d, ((PyObject *)__pyx_codeobj__38)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (!__Pyx_CyFunction_InitDefaults(__pyx_t_3, sizeof(__pyx_defaults13), 0)) __PYX_ERR(0, 261, __pyx_L1_error) + if (!__Pyx_CyFunction_InitDefaults(__pyx_t_3, sizeof(__pyx_defaults13), 0)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_CyFunction_Defaults(__pyx_defaults13, __pyx_t_3)->__pyx_arg_connectivity = 26; __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_3, __pyx_t_1); __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_3, __pyx_pf_4cc3d_48__defaults__); - if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_int16_t, __pyx_t_3) < 0) __PYX_ERR(0, 261, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_int16_t, __pyx_t_3) < 0) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __pyx_FusedFunction_NewEx(&__pyx_fuse_6__pyx_mdef_4cc3d_17region_graph, 0, __pyx_n_s_region_graph, NULL, __pyx_n_s_cc3d, __pyx_d, ((PyObject *)__pyx_codeobj__38)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_3 = __pyx_FusedFunction_NewEx(&__pyx_fuse_6__pyx_mdef_4cc3d_17region_graph, 0, __pyx_n_s_region_graph, NULL, __pyx_n_s_cc3d, __pyx_d, ((PyObject *)__pyx_codeobj__38)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (!__Pyx_CyFunction_InitDefaults(__pyx_t_3, sizeof(__pyx_defaults14), 0)) __PYX_ERR(0, 261, __pyx_L1_error) + if (!__Pyx_CyFunction_InitDefaults(__pyx_t_3, sizeof(__pyx_defaults14), 0)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_CyFunction_Defaults(__pyx_defaults14, __pyx_t_3)->__pyx_arg_connectivity = 26; __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_3, __pyx_t_1); __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_3, __pyx_pf_4cc3d_50__defaults__); - if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_int32_t, __pyx_t_3) < 0) __PYX_ERR(0, 261, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_int32_t, __pyx_t_3) < 0) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __pyx_FusedFunction_NewEx(&__pyx_fuse_7__pyx_mdef_4cc3d_19region_graph, 0, __pyx_n_s_region_graph, NULL, __pyx_n_s_cc3d, __pyx_d, ((PyObject *)__pyx_codeobj__38)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_3 = __pyx_FusedFunction_NewEx(&__pyx_fuse_7__pyx_mdef_4cc3d_19region_graph, 0, __pyx_n_s_region_graph, NULL, __pyx_n_s_cc3d, __pyx_d, ((PyObject *)__pyx_codeobj__38)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (!__Pyx_CyFunction_InitDefaults(__pyx_t_3, sizeof(__pyx_defaults15), 0)) __PYX_ERR(0, 261, __pyx_L1_error) + if (!__Pyx_CyFunction_InitDefaults(__pyx_t_3, sizeof(__pyx_defaults15), 0)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_CyFunction_Defaults(__pyx_defaults15, __pyx_t_3)->__pyx_arg_connectivity = 26; __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_3, __pyx_t_1); __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_3, __pyx_pf_4cc3d_52__defaults__); - if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_int64_t, __pyx_t_3) < 0) __PYX_ERR(0, 261, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_int64_t, __pyx_t_3) < 0) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __pyx_FusedFunction_NewEx(&__pyx_mdef_4cc3d_3region_graph, 0, __pyx_n_s_region_graph, NULL, __pyx_n_s_cc3d, __pyx_d, ((PyObject *)__pyx_codeobj__38)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_3 = __pyx_FusedFunction_NewEx(&__pyx_mdef_4cc3d_3region_graph, 0, __pyx_n_s_region_graph, NULL, __pyx_n_s_cc3d, __pyx_d, ((PyObject *)__pyx_codeobj__38)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_3, __pyx_t_1); ((__pyx_FusedFunctionObject *) __pyx_t_3)->__signatures__ = __pyx_t_2; __Pyx_GIVEREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_region_graph, __pyx_t_3) < 0) __PYX_ERR(0, 261, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_region_graph, __pyx_t_3) < 0) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; diff --git a/cc3d.hpp b/cc3d.hpp index 96ed827..618b4ef 100644 --- a/cc3d.hpp +++ b/cc3d.hpp @@ -756,11 +756,12 @@ OUT* connected_components2d_8( template OUT* connected_components2d_8_bbdt( T* in_labels, - const int64_t sx, const int64_t sy, - size_t max_labels, OUT *out_labels = NULL + const int64_t sx, const int64_t sy, const int64_t sz = 1, + size_t max_labels = 10000000000000000, OUT *out_labels = NULL ) { - const int64_t voxels = sx * sy; + const int64_t sxy = sx * sy; + const int64_t voxels = sx * sy * sz; max_labels = std::max(std::min(max_labels, static_cast(voxels)), static_cast(1L)); // can't allocate 0 arrays max_labels = std::min(max_labels, static_cast(std::numeric_limits::max())); @@ -772,10 +773,11 @@ OUT* connected_components2d_8_bbdt( } /* - Layout of mask. We start from e. - - a | b | c - d | e + Layout of mask. We start from y. + + c | d | e | f + b | y | z + a | x | w */ const int64_t A = -1 + sx; @@ -807,85 +809,87 @@ OUT* connected_components2d_8_bbdt( // Raster Scan 1: Set temporary labels and // record equivalences in a disjoint set. - for (int64_t y = 0; y < sy; y += 2) { - for (int64_t x = 0; x < sx; x += 2) { - loc = x + sx * y; - - lp = 0; - lq = 0; - lr = 0; - ls = 0; - lx = 0; + for (int64_t z = 0; z < sz; z++) { + for (int64_t y = 0; y < sy; y += 2) { + for (int64_t x = 0; x < sx; x += 2) { + loc = x + sx * y + sxy * z; + + lp = 0; + lq = 0; + lr = 0; + ls = 0; + lx = 0; + + if (in_labels[loc + Y]) { + if (x > 0 && y > 0 && in_labels[loc + C]) { + lp = out_labels[loc + C]; + } + if (y > 0 && in_labels[loc + D]) { + lq = out_labels[loc + D]; + } + else if (y > 0 && x < sx - 1 && in_labels[loc + E]) { + lq = out_labels[loc + E]; + } + if (x > 0 && in_labels[loc + B]) { + ls = out_labels[loc + B]; + } + else if (x > 0 && y < sx - 1 && in_labels[loc + A]) { + ls = out_labels[loc + A]; + } + if (x < sx - 2 && y > 0 && in_labels[loc + Z] && in_labels[loc + F]) { + lr = out_labels[loc + F]; + } - if (in_labels[loc + Y]) { - if (x > 0 && y > 0 && in_labels[loc + C]) { - lp = out_labels[loc + C]; - } - if (y > 0 && in_labels[loc + D]) { - lq = out_labels[loc + D]; } - else if (y > 0 && x < sx - 1 && in_labels[loc + E]) { - lq = out_labels[loc + E]; - } - if (x > 0 && in_labels[loc + B]) { - ls = out_labels[loc + B]; + else if (x < sx - 1 && in_labels[loc + Z]) { + if (y > 0 && in_labels[loc + D]) { + lq = out_labels[loc + D]; + } + else if (y > 0 && in_labels[loc + E]) { + lq = out_labels[loc + E]; + } + if (x < sx - 2 && y > 0 && in_labels[loc + F]) { + lr = in_labels[loc + F]; + } + if (x > 0 && y < sy - 1 && in_labels[loc + X]) { + ls = in_labels[loc + A] + ? out_labels[loc + A] + : out_labels[loc + B]; // out_labels will be 0 + } } - else if (x > 0 && y < sx - 1 && in_labels[loc + A]) { - ls = out_labels[loc + A]; + else if (x > 0 && y < sy - 1 && in_labels[loc + X]) { + ls = in_labels[loc + A] + ? out_labels[loc + A] + : out_labels[loc + B]; // out_labels will be 0 } - if (x < sx - 2 && y > 0 && in_labels[loc + Z] && in_labels[loc + F]) { - lr = out_labels[loc + F]; + else if (!in_labels[loc + W]) { + continue; } - } - else if (x < sx - 1 && in_labels[loc + Z]) { - if (y > 0 && in_labels[loc + D]) { - lq = out_labels[loc + D]; + if (lq) { + assignfn(loc, lq); } - else if (y > 0 && in_labels[loc + E]) { - lq = out_labels[loc + E]; + else if (lp) { + assignfn(loc, lp); + if (lr) { + equivalences.unify(lp, lr); + } } - if (x < sx - 2 && y > 0 && in_labels[loc + F]) { - lr = in_labels[loc + F]; + else if (ls) { + assignfn(loc, ls); + if (lr) { + equivalences.unify(lp, lr); + } } - if (x > 0 && y < sy - 1 && in_labels[loc + X]) { - ls = in_labels[loc + A] - ? out_labels[loc + A] - : out_labels[loc + B]; // out_labels will be 0 + else if (lr) { + assignfn(loc, lr); } - } - else if (x > 0 && y < sy - 1 && in_labels[loc + X]) { - ls = in_labels[loc + A] - ? out_labels[loc + A] - : out_labels[loc + B]; // out_labels will be 0 - } - else if (!in_labels[loc + W]) { - continue; - } - - if (lq) { - assignfn(loc, lq); - } - else if (lp) { - assignfn(loc, lp); - if (lr) { - equivalences.unify(lp, lr); - } - } - else if (ls) { - assignfn(loc, ls); - if (lr) { - equivalences.unify(lp, lr); + else { + next_label++; + assignfn(loc, next_label); + equivalences.add(next_label); } } - else if (lr) { - assignfn(loc, lr); - } - else { - next_label++; - assignfn(loc, next_label); - equivalences.add(next_label); - } } } diff --git a/cc3d.pyx b/cc3d.pyx index 32f971d..5154590 100644 --- a/cc3d.pyx +++ b/cc3d.pyx @@ -43,13 +43,18 @@ import numpy as np __VERSION__ = '1.8.0' cdef extern from "cc3d.hpp" namespace "cc3d": - cdef uint32_t* connected_components3d[T,U]( + cdef U* connected_components3d[T,U]( T* in_labels, int64_t sx, int64_t sy, int64_t sz, int64_t max_labels, int64_t connectivity, U* out_labels ) - + cdef U* connected_components2d_8_bbdt[T,U]( + T* in_labels, + int64_t sx, int64_t sy, int64_t sz, + int64_t max_labels, + U* out_labels + ) cdef vector[T] extract_region_graph[T]( T* labels, int64_t sx, int64_t sy, int64_t sz, @@ -222,7 +227,7 @@ def connected_components( sx, sy, sz, max_labels, connectivity, &out_labels64[0] ) - elif dtype in (np.uint8, np.int8, np.bool): + elif dtype in (np.uint8, np.int8) or (dtype == np.bool and connectivity != 8): arr_memview8u = data.view(np.uint8) if out_dtype == np.uint16: connected_components3d[uint8_t, uint16_t]( @@ -242,6 +247,26 @@ def connected_components( sx, sy, sz, max_labels, connectivity, &out_labels64[0] ) + elif dtype == np.bool and connectivity == 8: + arr_memview8u = data.view(np.uint8) + if out_dtype == np.uint16: + connected_components2d_8_bbdt[uint8_t, uint16_t]( + &arr_memview8u[0,0,0], + sx, sy, sz, max_labels, + &out_labels16[0] + ) + elif out_dtype == np.uint32: + connected_components2d_8_bbdt[uint8_t, uint32_t]( + &arr_memview8u[0,0,0], + sx, sy, sz, max_labels, + &out_labels32[0] + ) + elif out_dtype == np.uint64: + connected_components2d_8_bbdt[uint8_t, uint64_t]( + &arr_memview8u[0,0,0], + sx, sy, sz, max_labels, + &out_labels64[0] + ) else: raise TypeError("Type {} not currently supported.".format(dtype)) From 28c475db9f92c6196fc4bc65889e434faace3d84 Mon Sep 17 00:00:00 2001 From: William Silversmith Date: Sun, 6 Sep 2020 23:03:08 -0400 Subject: [PATCH 03/23] fix: bbdt appears to be working though it needs tuning --- cc3d.hpp | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/cc3d.hpp b/cc3d.hpp index 618b4ef..0941be3 100644 --- a/cc3d.hpp +++ b/cc3d.hpp @@ -800,11 +800,17 @@ OUT* connected_components2d_8_bbdt( OUT ls = 0; OUT lx = 0; - std::function assignfn = [X,Y,Z,W,out_labels,in_labels](size_t loc, OUT value) { - out_labels[loc + Y] = in_labels[loc + Y] * value; - out_labels[loc + Z] = in_labels[loc + Z] * value; - out_labels[loc + X] = in_labels[loc + X] * value; - out_labels[loc + W] = in_labels[loc + W] * value; + std::function assignfn = [X,Y,Z,W,sx,sy,out_labels,in_labels](int64_t x, int64_t y, int64_t loc, OUT value) { + out_labels[loc + Y] = (in_labels[loc + Y] > 0) * value; + if (x < sx - 1) { + out_labels[loc + Z] = (in_labels[loc + Z] > 0) * value; + } + if (y < sy - 1) { + out_labels[loc + X] = (in_labels[loc + X] > 0) * value; + } + if (x < sx - 1 && y < sy - 1) { + out_labels[loc + W] = (in_labels[loc + W] > 0) * value; + } }; // Raster Scan 1: Set temporary labels and @@ -821,15 +827,15 @@ OUT* connected_components2d_8_bbdt( lx = 0; if (in_labels[loc + Y]) { - if (x > 0 && y > 0 && in_labels[loc + C]) { - lp = out_labels[loc + C]; - } if (y > 0 && in_labels[loc + D]) { lq = out_labels[loc + D]; } else if (y > 0 && x < sx - 1 && in_labels[loc + E]) { lq = out_labels[loc + E]; } + if (x > 0 && y > 0 && in_labels[loc + C]) { + lp = out_labels[loc + C]; + } if (x > 0 && in_labels[loc + B]) { ls = out_labels[loc + B]; } @@ -839,7 +845,6 @@ OUT* connected_components2d_8_bbdt( if (x < sx - 2 && y > 0 && in_labels[loc + Z] && in_labels[loc + F]) { lr = out_labels[loc + F]; } - } else if (x < sx - 1 && in_labels[loc + Z]) { if (y > 0 && in_labels[loc + D]) { @@ -849,7 +854,7 @@ OUT* connected_components2d_8_bbdt( lq = out_labels[loc + E]; } if (x < sx - 2 && y > 0 && in_labels[loc + F]) { - lr = in_labels[loc + F]; + lr = out_labels[loc + F]; } if (x > 0 && y < sy - 1 && in_labels[loc + X]) { ls = in_labels[loc + A] @@ -858,35 +863,38 @@ OUT* connected_components2d_8_bbdt( } } else if (x > 0 && y < sy - 1 && in_labels[loc + X]) { - ls = in_labels[loc + A] - ? out_labels[loc + A] - : out_labels[loc + B]; // out_labels will be 0 + ls = in_labels[loc + A] + ? out_labels[loc + A] + : out_labels[loc + B]; // out_labels will be 0 } - else if (!in_labels[loc + W]) { + else if (x >= sx - 1 || y >= sy - 1 || !in_labels[loc + W]) { continue; } if (lq) { - assignfn(loc, lq); + assignfn(x, y, loc, lq); + if (lr) { + equivalences.unify(lq, lr); + } } else if (lp) { - assignfn(loc, lp); + assignfn(x, y, loc, lp); if (lr) { equivalences.unify(lp, lr); } } else if (ls) { - assignfn(loc, ls); + assignfn(x, y, loc, ls); if (lr) { equivalences.unify(lp, lr); } } else if (lr) { - assignfn(loc, lr); + assignfn(x, y, loc, lr); } else { next_label++; - assignfn(loc, next_label); + assignfn(x, y, loc, next_label); equivalences.add(next_label); } } From ee232f403fe20710bbe2b3237ae47378677849e1 Mon Sep 17 00:00:00 2001 From: William Silversmith Date: Mon, 7 Sep 2020 01:56:29 -0400 Subject: [PATCH 04/23] wip: trying a more traditional approach The last version was broken and slow --- cc3d.hpp | 180 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 119 insertions(+), 61 deletions(-) diff --git a/cc3d.hpp b/cc3d.hpp index 0941be3..2a99487 100644 --- a/cc3d.hpp +++ b/cc3d.hpp @@ -794,14 +794,8 @@ OUT* connected_components2d_8_bbdt( int64_t loc = 0; OUT next_label = 0; - OUT lp = 0; - OUT lq = 0; - OUT lr = 0; - OUT ls = 0; - OUT lx = 0; - - std::function assignfn = [X,Y,Z,W,sx,sy,out_labels,in_labels](int64_t x, int64_t y, int64_t loc, OUT value) { - out_labels[loc + Y] = (in_labels[loc + Y] > 0) * value; + std::function assignY = [X,Y,Z,W,sx,sy,out_labels,in_labels](int64_t x, int64_t y, int64_t loc, OUT value) { + out_labels[loc + Y] = value; if (x < sx - 1) { out_labels[loc + Z] = (in_labels[loc + Z] > 0) * value; } @@ -811,6 +805,21 @@ OUT* connected_components2d_8_bbdt( if (x < sx - 1 && y < sy - 1) { out_labels[loc + W] = (in_labels[loc + W] > 0) * value; } + }; + + std::function assignZ = [X,Z,W,sy,out_labels,in_labels](int64_t x, int64_t y, int64_t loc, OUT value) { + out_labels[loc + Z] = value; + if (y < sy - 1) { + out_labels[loc + X] = (in_labels[loc + X] > 0) * value; + out_labels[loc + W] = (in_labels[loc + W] > 0) * value; + } + }; + + std::function assignX = [X,W,sx,out_labels,in_labels](int64_t x, int64_t y, int64_t loc, OUT value) { + out_labels[loc + X] = value; + if (x < sx - 1) { + out_labels[loc + W] = (in_labels[loc + W] > 0) * value; + } }; // Raster Scan 1: Set temporary labels and @@ -820,82 +829,131 @@ OUT* connected_components2d_8_bbdt( for (int64_t x = 0; x < sx; x += 2) { loc = x + sx * y + sxy * z; - lp = 0; - lq = 0; - lr = 0; - ls = 0; - lx = 0; - if (in_labels[loc + Y]) { if (y > 0 && in_labels[loc + D]) { - lq = out_labels[loc + D]; + assignY(x, y, loc, out_labels[loc + D]); + if (x < sx - 2 && in_labels[loc + Z] && in_labels[loc + F]) { + equivalences.unify(out_labels[loc + Y], out_labels[loc + F]); + } } else if (y > 0 && x < sx - 1 && in_labels[loc + E]) { - lq = out_labels[loc + E]; + assignY(x, y, loc, out_labels[loc + E]); + if (x > 0 && y > 0 && in_labels[loc + C]) { + equivalences.unify(out_labels[loc + Y], out_labels[loc + C]); + if (y < sy - 1 && !in_labels[loc + B] && in_labels[loc + A]) { + equivalences.unify(out_labels[loc + Y], out_labels[loc + A]); + } + } + else if (x > 0 && in_labels[loc + B]) { + equivalences.unify(out_labels[loc + Y], out_labels[loc + B]); + } + else if (x > 0 && y < sy - 1 && in_labels[loc + A]) { + equivalences.unify(out_labels[loc + Y], out_labels[loc + A]); + } } - if (x > 0 && y > 0 && in_labels[loc + C]) { - lp = out_labels[loc + C]; + else if (x > 0 && y > 0 && in_labels[loc + C]) { + assignY(x, y, loc, out_labels[loc + C]); + if (y < sy - 1 && !in_labels[loc + B] && in_labels[loc + A]) { + equivalences.unify(out_labels[loc + Y], out_labels[loc + A]); + } + if (x < sx - 2 && in_labels[loc + Z] && in_labels[loc + F]) { + equivalences.unify(out_labels[loc + Y], out_labels[loc + F]); + } } - if (x > 0 && in_labels[loc + B]) { - ls = out_labels[loc + B]; + else if (x > 0 && in_labels[loc + B]) { + assignY(x, y, loc, out_labels[loc + B]); + if (x < sx - 2 && in_labels[loc + Z] && in_labels[loc + F]) { + equivalences.unify(out_labels[loc + Y], out_labels[loc + F]); + } } else if (x > 0 && y < sx - 1 && in_labels[loc + A]) { - ls = out_labels[loc + A]; + assignY(x, y, loc, out_labels[loc + A]); + if (x < sx - 2 && in_labels[loc + Z] && in_labels[loc + F]) { + equivalences.unify(out_labels[loc + Y], out_labels[loc + F]); + } } - if (x < sx - 2 && y > 0 && in_labels[loc + Z] && in_labels[loc + F]) { - lr = out_labels[loc + F]; + else if (x < sx - 2 && y > 0 && in_labels[loc + Z] && in_labels[loc + F]) { + assignY(x, y, loc, out_labels[loc + F]); + } + else { + next_label++; + assignY(x, y, loc, next_label); + equivalences.add(next_label); } } else if (x < sx - 1 && in_labels[loc + Z]) { if (y > 0 && in_labels[loc + D]) { - lq = out_labels[loc + D]; + assignZ(x, y, loc, out_labels[loc + D]); + if (x < sx - 2 && in_labels[loc + F]) { + equivalences.unify(out_labels[loc + Z], out_labels[loc + F]); + } + if (x > 0 && y < sy - 1 && in_labels[loc + X]) { + if (in_labels[loc + B]) { + equivalences.unify(out_labels[loc + Z], out_labels[loc + B]); + } + else if (in_labels[loc + A]) { + equivalences.unify(out_labels[loc + Z], out_labels[loc + A]); + } + } } else if (y > 0 && in_labels[loc + E]) { - lq = out_labels[loc + E]; - } - if (x < sx - 2 && y > 0 && in_labels[loc + F]) { - lr = out_labels[loc + F]; + assignZ(x, y, loc, out_labels[loc + E]); + if (x > 0 && y < sy - 1 && in_labels[loc + X]) { + if (in_labels[loc + B]) { + equivalences.unify(out_labels[loc + Z], out_labels[loc + B]); + } + else if (in_labels[loc + A]) { + equivalences.unify(out_labels[loc + Z], out_labels[loc + A]); + } + } } - if (x > 0 && y < sy - 1 && in_labels[loc + X]) { - ls = in_labels[loc + A] - ? out_labels[loc + A] - : out_labels[loc + B]; // out_labels will be 0 + else if (x < sx - 2 && y > 0 && in_labels[loc + F]) { + assignZ(x, y, loc, out_labels[loc + F]); + if (x > 0 && y < sy - 1 && in_labels[loc + X]) { + if (in_labels[loc + B]) { + equivalences.unify(out_labels[loc + Z], out_labels[loc + B]); + } + else if (in_labels[loc + A]) { + equivalences.unify(out_labels[loc + Z], out_labels[loc + A]); + } + } } - } - else if (x > 0 && y < sy - 1 && in_labels[loc + X]) { - ls = in_labels[loc + A] - ? out_labels[loc + A] - : out_labels[loc + B]; // out_labels will be 0 - } - else if (x >= sx - 1 || y >= sy - 1 || !in_labels[loc + W]) { - continue; - } - - if (lq) { - assignfn(x, y, loc, lq); - if (lr) { - equivalences.unify(lq, lr); + else if (x > 0 && y < sy - 1 && in_labels[loc + X]) { + if (in_labels[loc + B]) { + equivalences.unify(out_labels[loc + Z], out_labels[loc + B]); + } + else if (in_labels[loc + A]) { + equivalences.unify(out_labels[loc + Z], out_labels[loc + A]); + } + else { + next_label++; + assignZ(x, y, loc, next_label); + equivalences.add(next_label); + } } - } - else if (lp) { - assignfn(x, y, loc, lp); - if (lr) { - equivalences.unify(lp, lr); + else { + next_label++; + assignZ(x, y, loc, next_label); + equivalences.add(next_label); } } - else if (ls) { - assignfn(x, y, loc, ls); - if (lr) { - equivalences.unify(lp, lr); + else if (x > 0 && y < sy - 1 && in_labels[loc + X]) { + if (in_labels[loc + B]) { + assignX(x, y, loc, out_labels[loc + B]); } + else if (in_labels[loc + A]) { + assignX(x, y, loc, out_labels[loc + A]); + } + else { + next_label++; + assignX(x, y, loc, next_label); + equivalences.add(next_label); + } } - else if (lr) { - assignfn(x, y, loc, lr); - } - else { + else if (x < sx - 1 && y < sy - 1 && in_labels[loc + W]) { next_label++; - assignfn(x, y, loc, next_label); - equivalences.add(next_label); + out_labels[loc + W] = next_label; + equivalences.add(next_label); } } } From c61003f49debf0a404c3ba0fd85a12bd8728ef72 Mon Sep 17 00:00:00 2001 From: William Silversmith Date: Mon, 7 Sep 2020 02:04:25 -0400 Subject: [PATCH 05/23] perf: skip some checks given we know X is ok --- cc3d.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cc3d.hpp b/cc3d.hpp index 2a99487..65a24da 100644 --- a/cc3d.hpp +++ b/cc3d.hpp @@ -920,10 +920,12 @@ OUT* connected_components2d_8_bbdt( } else if (x > 0 && y < sy - 1 && in_labels[loc + X]) { if (in_labels[loc + B]) { - equivalences.unify(out_labels[loc + Z], out_labels[loc + B]); + out_labels[loc + Z] = out_labels[loc + B]; + assignX(x, y, loc, out_labels[loc + B]); } else if (in_labels[loc + A]) { - equivalences.unify(out_labels[loc + Z], out_labels[loc + A]); + out_labels[loc + Z] = out_labels[loc + A]; + assignX(x, y, loc, out_labels[loc + A]); } else { next_label++; From ce6914bc75bdef12ade9dd478daf56349ffd9016 Mon Sep 17 00:00:00 2001 From: William Silversmith Date: Mon, 7 Sep 2020 02:24:56 -0400 Subject: [PATCH 06/23] wip: may have fixed issue with pieces not being unified --- cc3d.hpp | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/cc3d.hpp b/cc3d.hpp index 65a24da..3abe3ad 100644 --- a/cc3d.hpp +++ b/cc3d.hpp @@ -774,6 +774,8 @@ OUT* connected_components2d_8_bbdt( /* Layout of mask. We start from y. + We are exploiting the 2x2 connectedness + of XYZW. This only works for binary images. c | d | e | f b | y | z @@ -838,6 +840,9 @@ OUT* connected_components2d_8_bbdt( } else if (y > 0 && x < sx - 1 && in_labels[loc + E]) { assignY(x, y, loc, out_labels[loc + E]); + if (x < sx - 2 && in_labels[loc + Z] && in_labels[loc + F]) { + equivalences.unify(out_labels[loc + Y], out_labels[loc + F]); + } if (x > 0 && y > 0 && in_labels[loc + C]) { equivalences.unify(out_labels[loc + Y], out_labels[loc + C]); if (y < sy - 1 && !in_labels[loc + B] && in_labels[loc + A]) { @@ -898,12 +903,15 @@ OUT* connected_components2d_8_bbdt( } else if (y > 0 && in_labels[loc + E]) { assignZ(x, y, loc, out_labels[loc + E]); + if (x < sx - 2 && in_labels[loc + F]) { + equivalences.unify(out_labels[loc + Z], out_labels[loc + F]); + } if (x > 0 && y < sy - 1 && in_labels[loc + X]) { if (in_labels[loc + B]) { - equivalences.unify(out_labels[loc + Z], out_labels[loc + B]); + equivalences.unify(out_labels[loc + X], out_labels[loc + B]); } else if (in_labels[loc + A]) { - equivalences.unify(out_labels[loc + Z], out_labels[loc + A]); + equivalences.unify(out_labels[loc + X], out_labels[loc + A]); } } } @@ -911,10 +919,10 @@ OUT* connected_components2d_8_bbdt( assignZ(x, y, loc, out_labels[loc + F]); if (x > 0 && y < sy - 1 && in_labels[loc + X]) { if (in_labels[loc + B]) { - equivalences.unify(out_labels[loc + Z], out_labels[loc + B]); + equivalences.unify(out_labels[loc + X], out_labels[loc + B]); } else if (in_labels[loc + A]) { - equivalences.unify(out_labels[loc + Z], out_labels[loc + A]); + equivalences.unify(out_labels[loc + X], out_labels[loc + A]); } } } @@ -929,13 +937,17 @@ OUT* connected_components2d_8_bbdt( } else { next_label++; - assignZ(x, y, loc, next_label); + out_labels[loc + Z] = next_label; + assignX(x, y, loc, next_label); equivalences.add(next_label); } } - else { + else { // ZW next_label++; - assignZ(x, y, loc, next_label); + out_labels[loc + Z] = next_label; + if (y < sy - 1 && in_labels[loc + W]) { + out_labels[loc + W] = next_label; + } equivalences.add(next_label); } } From c5af4ff829549ad2281270a8e3d62134d1ca1ecc Mon Sep 17 00:00:00 2001 From: William Silversmith Date: Wed, 30 Sep 2020 13:20:33 -0400 Subject: [PATCH 07/23] perf: replace function calls with macros --- cc3d.hpp | 276 +++++++++++++++++++++++++++---------------------------- 1 file changed, 138 insertions(+), 138 deletions(-) diff --git a/cc3d.hpp b/cc3d.hpp index 3abe3ad..7e3b624 100644 --- a/cc3d.hpp +++ b/cc3d.hpp @@ -756,12 +756,11 @@ OUT* connected_components2d_8( template OUT* connected_components2d_8_bbdt( T* in_labels, - const int64_t sx, const int64_t sy, const int64_t sz = 1, + const int64_t sx, const int64_t sy, size_t max_labels = 10000000000000000, OUT *out_labels = NULL ) { - const int64_t sxy = sx * sy; - const int64_t voxels = sx * sy * sz; + const int64_t voxels = sx * sy; max_labels = std::max(std::min(max_labels, static_cast(voxels)), static_cast(1L)); // can't allocate 0 arrays max_labels = std::min(max_labels, static_cast(std::numeric_limits::max())); @@ -796,183 +795,184 @@ OUT* connected_components2d_8_bbdt( int64_t loc = 0; OUT next_label = 0; - std::function assignY = [X,Y,Z,W,sx,sy,out_labels,in_labels](int64_t x, int64_t y, int64_t loc, OUT value) { - out_labels[loc + Y] = value; - if (x < sx - 1) { - out_labels[loc + Z] = (in_labels[loc + Z] > 0) * value; - } - if (y < sy - 1) { - out_labels[loc + X] = (in_labels[loc + X] > 0) * value; - } - if (x < sx - 1 && y < sy - 1) { - out_labels[loc + W] = (in_labels[loc + W] > 0) * value; - } - }; +#define ASSIGN_Y(value) \ + out_labels[loc + Y] = (value); \ + if (x < sx - 1 && in_labels[loc + Z]) { \ + out_labels[loc + Z] = (value); \ + } \ + if (y < sy - 1 && in_labels[loc + X]) { \ + out_labels[loc + X] = (value); \ + } \ + if (x < sx - 1 && y < sy - 1 && in_labels[loc + W]) { \ + out_labels[loc + W] = (value); \ + } - std::function assignZ = [X,Z,W,sy,out_labels,in_labels](int64_t x, int64_t y, int64_t loc, OUT value) { - out_labels[loc + Z] = value; - if (y < sy - 1) { - out_labels[loc + X] = (in_labels[loc + X] > 0) * value; - out_labels[loc + W] = (in_labels[loc + W] > 0) * value; +#define ASSIGN_Z(value) \ + out_labels[loc + Z] = (value); \ + if (y < sy - 1 && in_labels[loc + X]) { \ + out_labels[loc + X] = (value); \ + } \ + if (y < sy - 1 && in_labels[loc +W]) { \ + out_labels[loc + W] = (value); \ } - }; - std::function assignX = [X,W,sx,out_labels,in_labels](int64_t x, int64_t y, int64_t loc, OUT value) { - out_labels[loc + X] = value; - if (x < sx - 1) { - out_labels[loc + W] = (in_labels[loc + W] > 0) * value; - } - }; +#define ASSIGN_X(value) \ + out_labels[loc + X] = (value); \ + if (x < sx - 1 && in_labels[loc + W]) { \ + out_labels[loc + W] = (value); \ + } // Raster Scan 1: Set temporary labels and // record equivalences in a disjoint set. - for (int64_t z = 0; z < sz; z++) { - for (int64_t y = 0; y < sy; y += 2) { - for (int64_t x = 0; x < sx; x += 2) { - loc = x + sx * y + sxy * z; - - if (in_labels[loc + Y]) { - if (y > 0 && in_labels[loc + D]) { - assignY(x, y, loc, out_labels[loc + D]); - if (x < sx - 2 && in_labels[loc + Z] && in_labels[loc + F]) { - equivalences.unify(out_labels[loc + Y], out_labels[loc + F]); - } + for (int64_t y = 0; y < sy; y += 2) { + for (int64_t x = 0; x < sx; x += 2) { + loc = x + sx * y; + + if (in_labels[loc + Y]) { + if (y > 0 && in_labels[loc + D]) { + ASSIGN_Y(out_labels[loc + D]); + if (x < sx - 2 && in_labels[loc + Z] && in_labels[loc + F]) { + equivalences.unify(out_labels[loc + Y], out_labels[loc + F]); } - else if (y > 0 && x < sx - 1 && in_labels[loc + E]) { - assignY(x, y, loc, out_labels[loc + E]); - if (x < sx - 2 && in_labels[loc + Z] && in_labels[loc + F]) { - equivalences.unify(out_labels[loc + Y], out_labels[loc + F]); - } - if (x > 0 && y > 0 && in_labels[loc + C]) { - equivalences.unify(out_labels[loc + Y], out_labels[loc + C]); - if (y < sy - 1 && !in_labels[loc + B] && in_labels[loc + A]) { - equivalences.unify(out_labels[loc + Y], out_labels[loc + A]); - } - } - else if (x > 0 && in_labels[loc + B]) { - equivalences.unify(out_labels[loc + Y], out_labels[loc + B]); - } - else if (x > 0 && y < sy - 1 && in_labels[loc + A]) { - equivalences.unify(out_labels[loc + Y], out_labels[loc + A]); - } + } + else if (y > 0 && x < sx - 1 && in_labels[loc + E]) { + ASSIGN_Y(out_labels[loc + E]); + if (x < sx - 2 && in_labels[loc + Z] && in_labels[loc + F]) { + equivalences.unify(out_labels[loc + Y], out_labels[loc + F]); } - else if (x > 0 && y > 0 && in_labels[loc + C]) { - assignY(x, y, loc, out_labels[loc + C]); + if (x > 0 && y > 0 && in_labels[loc + C]) { + equivalences.unify(out_labels[loc + Y], out_labels[loc + C]); if (y < sy - 1 && !in_labels[loc + B] && in_labels[loc + A]) { equivalences.unify(out_labels[loc + Y], out_labels[loc + A]); } - if (x < sx - 2 && in_labels[loc + Z] && in_labels[loc + F]) { - equivalences.unify(out_labels[loc + Y], out_labels[loc + F]); - } } else if (x > 0 && in_labels[loc + B]) { - assignY(x, y, loc, out_labels[loc + B]); - if (x < sx - 2 && in_labels[loc + Z] && in_labels[loc + F]) { - equivalences.unify(out_labels[loc + Y], out_labels[loc + F]); - } - } - else if (x > 0 && y < sx - 1 && in_labels[loc + A]) { - assignY(x, y, loc, out_labels[loc + A]); - if (x < sx - 2 && in_labels[loc + Z] && in_labels[loc + F]) { - equivalences.unify(out_labels[loc + Y], out_labels[loc + F]); - } + equivalences.unify(out_labels[loc + Y], out_labels[loc + B]); } - else if (x < sx - 2 && y > 0 && in_labels[loc + Z] && in_labels[loc + F]) { - assignY(x, y, loc, out_labels[loc + F]); + else if (x > 0 && y < sy - 1 && in_labels[loc + A]) { + equivalences.unify(out_labels[loc + Y], out_labels[loc + A]); } - else { - next_label++; - assignY(x, y, loc, next_label); - equivalences.add(next_label); + } + else if (x > 0 && y > 0 && in_labels[loc + C]) { + ASSIGN_Y(out_labels[loc + C]); + if (y < sy - 1 && !in_labels[loc + B] && in_labels[loc + A]) { + equivalences.unify(out_labels[loc + Y], out_labels[loc + A]); } + if (x < sx - 2 && in_labels[loc + Z] && in_labels[loc + F]) { + equivalences.unify(out_labels[loc + Y], out_labels[loc + F]); + } } - else if (x < sx - 1 && in_labels[loc + Z]) { - if (y > 0 && in_labels[loc + D]) { - assignZ(x, y, loc, out_labels[loc + D]); - if (x < sx - 2 && in_labels[loc + F]) { - equivalences.unify(out_labels[loc + Z], out_labels[loc + F]); - } - if (x > 0 && y < sy - 1 && in_labels[loc + X]) { - if (in_labels[loc + B]) { - equivalences.unify(out_labels[loc + Z], out_labels[loc + B]); - } - else if (in_labels[loc + A]) { - equivalences.unify(out_labels[loc + Z], out_labels[loc + A]); - } - } + else if (x > 0 && in_labels[loc + B]) { + ASSIGN_Y(out_labels[loc + B]); + if (x < sx - 2 && in_labels[loc + Z] && in_labels[loc + F]) { + equivalences.unify(out_labels[loc + Y], out_labels[loc + F]); + } + } + else if (x > 0 && y < sx - 1 && in_labels[loc + A]) { + ASSIGN_Y(out_labels[loc + A]); + if (x < sx - 2 && in_labels[loc + Z] && in_labels[loc + F]) { + equivalences.unify(out_labels[loc + Y], out_labels[loc + F]); + } + } + else if (x < sx - 2 && y > 0 && in_labels[loc + Z] && in_labels[loc + F]) { + ASSIGN_Y(out_labels[loc + F]); + } + else { + next_label++; + ASSIGN_Y(next_label); + equivalences.add(next_label); + } + } + else if (x < sx - 1 && in_labels[loc + Z]) { + if (y > 0 && in_labels[loc + D]) { + ASSIGN_Z(out_labels[loc + D]); + if (x < sx - 2 && in_labels[loc + F]) { + equivalences.unify(out_labels[loc + Z], out_labels[loc + F]); } - else if (y > 0 && in_labels[loc + E]) { - assignZ(x, y, loc, out_labels[loc + E]); - if (x < sx - 2 && in_labels[loc + F]) { - equivalences.unify(out_labels[loc + Z], out_labels[loc + F]); + if (x > 0 && y < sy - 1 && in_labels[loc + X]) { + if (in_labels[loc + B]) { + equivalences.unify(out_labels[loc + Z], out_labels[loc + B]); + } + else if (in_labels[loc + A]) { + equivalences.unify(out_labels[loc + Z], out_labels[loc + A]); } - if (x > 0 && y < sy - 1 && in_labels[loc + X]) { - if (in_labels[loc + B]) { - equivalences.unify(out_labels[loc + X], out_labels[loc + B]); - } - else if (in_labels[loc + A]) { - equivalences.unify(out_labels[loc + X], out_labels[loc + A]); - } - } } - else if (x < sx - 2 && y > 0 && in_labels[loc + F]) { - assignZ(x, y, loc, out_labels[loc + F]); - if (x > 0 && y < sy - 1 && in_labels[loc + X]) { - if (in_labels[loc + B]) { - equivalences.unify(out_labels[loc + X], out_labels[loc + B]); - } - else if (in_labels[loc + A]) { - equivalences.unify(out_labels[loc + X], out_labels[loc + A]); - } - } + } + else if (y > 0 && in_labels[loc + E]) { + ASSIGN_Z(out_labels[loc + E]); + if (x < sx - 2 && in_labels[loc + F]) { + equivalences.unify(out_labels[loc + Z], out_labels[loc + F]); } - else if (x > 0 && y < sy - 1 && in_labels[loc + X]) { + if (x > 0 && y < sy - 1 && in_labels[loc + X]) { if (in_labels[loc + B]) { - out_labels[loc + Z] = out_labels[loc + B]; - assignX(x, y, loc, out_labels[loc + B]); + equivalences.unify(out_labels[loc + X], out_labels[loc + B]); } else if (in_labels[loc + A]) { - out_labels[loc + Z] = out_labels[loc + A]; - assignX(x, y, loc, out_labels[loc + A]); + equivalences.unify(out_labels[loc + X], out_labels[loc + A]); } - else { - next_label++; - out_labels[loc + Z] = next_label; - assignX(x, y, loc, next_label); - equivalences.add(next_label); + } + } + else if (x < sx - 2 && y > 0 && in_labels[loc + F]) { + ASSIGN_Z(out_labels[loc + F]); + if (x > 0 && y < sy - 1 && in_labels[loc + X]) { + if (in_labels[loc + B]) { + equivalences.unify(out_labels[loc + X], out_labels[loc + B]); } - } - else { // ZW - next_label++; - out_labels[loc + Z] = next_label; - if (y < sy - 1 && in_labels[loc + W]) { - out_labels[loc + W] = next_label; + else if (in_labels[loc + A]) { + equivalences.unify(out_labels[loc + X], out_labels[loc + A]); } - equivalences.add(next_label); - } + } } else if (x > 0 && y < sy - 1 && in_labels[loc + X]) { if (in_labels[loc + B]) { - assignX(x, y, loc, out_labels[loc + B]); + out_labels[loc + Z] = out_labels[loc + B]; + ASSIGN_X(out_labels[loc + B]); } else if (in_labels[loc + A]) { - assignX(x, y, loc, out_labels[loc + A]); - } + out_labels[loc + Z] = out_labels[loc + A]; + ASSIGN_X(out_labels[loc + A]); + } else { next_label++; - assignX(x, y, loc, next_label); + out_labels[loc + Z] = next_label; + ASSIGN_X(next_label); equivalences.add(next_label); - } + } } - else if (x < sx - 1 && y < sy - 1 && in_labels[loc + W]) { + else { // ZW next_label++; - out_labels[loc + W] = next_label; - equivalences.add(next_label); + out_labels[loc + Z] = next_label; + if (y < sy - 1 && in_labels[loc + W]) { + out_labels[loc + W] = next_label; + } + equivalences.add(next_label); } } + else if (x > 0 && y < sy - 1 && in_labels[loc + X]) { + if (in_labels[loc + B]) { + ASSIGN_X(out_labels[loc + B]); + } + else if (in_labels[loc + A]) { + ASSIGN_X(out_labels[loc + A]); + } + else { + next_label++; + ASSIGN_X(next_label); + equivalences.add(next_label); + } + } + else if (x < sx - 1 && y < sy - 1 && in_labels[loc + W]) { + next_label++; + out_labels[loc + W] = next_label; + equivalences.add(next_label); + } } } +#undef ASSIGN_X +#undef ASSIGN_Y +#undef ASSIGN_Z + return relabel(out_labels, voxels, next_label, equivalences); } From 021dda26fb2be8133abce65545dcb3aae7464ed3 Mon Sep 17 00:00:00 2001 From: William Silversmith Date: Wed, 30 Sep 2020 13:21:07 -0400 Subject: [PATCH 08/23] test: save test configuration --- test.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/test.cpp b/test.cpp index a1f41fe..b46c7c9 100644 --- a/test.cpp +++ b/test.cpp @@ -32,13 +32,17 @@ void print(int *input, int sx, int sy, int sz) { int main () { - int *big = new int[512*512*512](); - for (int i = 0; i < 512*512*512; i++) { - big[i] = 1; - } + int sx = 2048; + int sy = 2048; - cc3d::connected_components3d(big, 512,512,512); + int *big = new int[sx*sy](); + for (int i = 0; i < sx*sy; i++) { + big[i] = rand() % 1000; + } + auto *out = cc3d::connected_components2d_4_bbdt_2(big, sx,sy, sx*sy); + delete[] out; + delete[] big; // int twod[25] = { // 1,1,0,1,1, From db36a72b54690bfb7fb6acd12a7193f445607d5c Mon Sep 17 00:00:00 2001 From: William Silversmith Date: Fri, 2 Oct 2020 19:58:59 -0400 Subject: [PATCH 09/23] fix: incorrect references --- cc3d.cpp | 24 ++++++++++++------------ cc3d.pyx | 8 ++++---- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cc3d.cpp b/cc3d.cpp index 6d51245..ada3577 100644 --- a/cc3d.cpp +++ b/cc3d.cpp @@ -5966,7 +5966,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p * if out_dtype == np.uint16: * connected_components2d_8_bbdt[uint8_t, uint16_t]( * &arr_memview8u[0,0,0], # <<<<<<<<<<<<<< - * sx, sy, sz, max_labels, + * sx, sy, max_labels, * &out_labels16[0] */ __pyx_t_70 = 0; @@ -5992,7 +5992,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p /* "cc3d.pyx":256 * &arr_memview8u[0,0,0], - * sx, sy, sz, max_labels, + * sx, sy, max_labels, * &out_labels16[0] # <<<<<<<<<<<<<< * ) * elif out_dtype == np.uint32: @@ -6013,9 +6013,9 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p * if out_dtype == np.uint16: * connected_components2d_8_bbdt[uint8_t, uint16_t]( # <<<<<<<<<<<<<< * &arr_memview8u[0,0,0], - * sx, sy, sz, max_labels, + * sx, sy, max_labels, */ - (void)(cc3d::connected_components2d_8_bbdt((&(*((uint8_t *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_arr_memview8u.data + __pyx_t_70 * __pyx_v_arr_memview8u.strides[0]) ) + __pyx_t_71 * __pyx_v_arr_memview8u.strides[1]) ) + __pyx_t_72 * __pyx_v_arr_memview8u.strides[2]) )))), __pyx_v_sx, __pyx_v_sy, __pyx_v_sz, __pyx_v_max_labels, ((uint16_t *)(&(*__Pyx_BufPtrStrided1d(uint16_t *, __pyx_pybuffernd_out_labels16.rcbuffer->pybuffer.buf, __pyx_t_73, __pyx_pybuffernd_out_labels16.diminfo[0].strides)))))); + (void)(cc3d::connected_components2d_8_bbdt((&(*((uint8_t *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_arr_memview8u.data + __pyx_t_70 * __pyx_v_arr_memview8u.strides[0]) ) + __pyx_t_71 * __pyx_v_arr_memview8u.strides[1]) ) + __pyx_t_72 * __pyx_v_arr_memview8u.strides[2]) )))), __pyx_v_sx, __pyx_v_sy, __pyx_v_max_labels, ((uint16_t *)(&(*__Pyx_BufPtrStrided1d(uint16_t *, __pyx_pybuffernd_out_labels16.rcbuffer->pybuffer.buf, __pyx_t_73, __pyx_pybuffernd_out_labels16.diminfo[0].strides)))))); /* "cc3d.pyx":252 * elif dtype == np.bool and connectivity == 8: @@ -6049,7 +6049,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p * elif out_dtype == np.uint32: * connected_components2d_8_bbdt[uint8_t, uint32_t]( * &arr_memview8u[0,0,0], # <<<<<<<<<<<<<< - * sx, sy, sz, max_labels, + * sx, sy, max_labels, * &out_labels32[0] */ __pyx_t_74 = 0; @@ -6075,7 +6075,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p /* "cc3d.pyx":262 * &arr_memview8u[0,0,0], - * sx, sy, sz, max_labels, + * sx, sy, max_labels, * &out_labels32[0] # <<<<<<<<<<<<<< * ) * elif out_dtype == np.uint64: @@ -6096,9 +6096,9 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p * elif out_dtype == np.uint32: * connected_components2d_8_bbdt[uint8_t, uint32_t]( # <<<<<<<<<<<<<< * &arr_memview8u[0,0,0], - * sx, sy, sz, max_labels, + * sx, sy, max_labels, */ - (void)(cc3d::connected_components2d_8_bbdt((&(*((uint8_t *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_arr_memview8u.data + __pyx_t_74 * __pyx_v_arr_memview8u.strides[0]) ) + __pyx_t_75 * __pyx_v_arr_memview8u.strides[1]) ) + __pyx_t_76 * __pyx_v_arr_memview8u.strides[2]) )))), __pyx_v_sx, __pyx_v_sy, __pyx_v_sz, __pyx_v_max_labels, ((uint32_t *)(&(*__Pyx_BufPtrStrided1d(uint32_t *, __pyx_pybuffernd_out_labels32.rcbuffer->pybuffer.buf, __pyx_t_77, __pyx_pybuffernd_out_labels32.diminfo[0].strides)))))); + (void)(cc3d::connected_components2d_8_bbdt((&(*((uint8_t *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_arr_memview8u.data + __pyx_t_74 * __pyx_v_arr_memview8u.strides[0]) ) + __pyx_t_75 * __pyx_v_arr_memview8u.strides[1]) ) + __pyx_t_76 * __pyx_v_arr_memview8u.strides[2]) )))), __pyx_v_sx, __pyx_v_sy, __pyx_v_max_labels, ((uint32_t *)(&(*__Pyx_BufPtrStrided1d(uint32_t *, __pyx_pybuffernd_out_labels32.rcbuffer->pybuffer.buf, __pyx_t_77, __pyx_pybuffernd_out_labels32.diminfo[0].strides)))))); /* "cc3d.pyx":258 * &out_labels16[0] @@ -6132,7 +6132,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p * elif out_dtype == np.uint64: * connected_components2d_8_bbdt[uint8_t, uint64_t]( * &arr_memview8u[0,0,0], # <<<<<<<<<<<<<< - * sx, sy, sz, max_labels, + * sx, sy, max_labels, * &out_labels64[0] */ __pyx_t_78 = 0; @@ -6158,7 +6158,7 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p /* "cc3d.pyx":268 * &arr_memview8u[0,0,0], - * sx, sy, sz, max_labels, + * sx, sy, max_labels, * &out_labels64[0] # <<<<<<<<<<<<<< * ) * else: @@ -6179,9 +6179,9 @@ static PyObject *__pyx_pf_4cc3d_connected_components(CYTHON_UNUSED PyObject *__p * elif out_dtype == np.uint64: * connected_components2d_8_bbdt[uint8_t, uint64_t]( # <<<<<<<<<<<<<< * &arr_memview8u[0,0,0], - * sx, sy, sz, max_labels, + * sx, sy, max_labels, */ - (void)(cc3d::connected_components2d_8_bbdt((&(*((uint8_t *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_arr_memview8u.data + __pyx_t_78 * __pyx_v_arr_memview8u.strides[0]) ) + __pyx_t_79 * __pyx_v_arr_memview8u.strides[1]) ) + __pyx_t_80 * __pyx_v_arr_memview8u.strides[2]) )))), __pyx_v_sx, __pyx_v_sy, __pyx_v_sz, __pyx_v_max_labels, ((uint64_t *)(&(*__Pyx_BufPtrStrided1d(uint64_t *, __pyx_pybuffernd_out_labels64.rcbuffer->pybuffer.buf, __pyx_t_81, __pyx_pybuffernd_out_labels64.diminfo[0].strides)))))); + (void)(cc3d::connected_components2d_8_bbdt((&(*((uint8_t *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_arr_memview8u.data + __pyx_t_78 * __pyx_v_arr_memview8u.strides[0]) ) + __pyx_t_79 * __pyx_v_arr_memview8u.strides[1]) ) + __pyx_t_80 * __pyx_v_arr_memview8u.strides[2]) )))), __pyx_v_sx, __pyx_v_sy, __pyx_v_max_labels, ((uint64_t *)(&(*__Pyx_BufPtrStrided1d(uint64_t *, __pyx_pybuffernd_out_labels64.rcbuffer->pybuffer.buf, __pyx_t_81, __pyx_pybuffernd_out_labels64.diminfo[0].strides)))))); /* "cc3d.pyx":264 * &out_labels32[0] diff --git a/cc3d.pyx b/cc3d.pyx index 5154590..c1c305c 100644 --- a/cc3d.pyx +++ b/cc3d.pyx @@ -51,7 +51,7 @@ cdef extern from "cc3d.hpp" namespace "cc3d": ) cdef U* connected_components2d_8_bbdt[T,U]( T* in_labels, - int64_t sx, int64_t sy, int64_t sz, + int64_t sx, int64_t sy, int64_t max_labels, U* out_labels ) @@ -252,19 +252,19 @@ def connected_components( if out_dtype == np.uint16: connected_components2d_8_bbdt[uint8_t, uint16_t]( &arr_memview8u[0,0,0], - sx, sy, sz, max_labels, + sx, sy, max_labels, &out_labels16[0] ) elif out_dtype == np.uint32: connected_components2d_8_bbdt[uint8_t, uint32_t]( &arr_memview8u[0,0,0], - sx, sy, sz, max_labels, + sx, sy, max_labels, &out_labels32[0] ) elif out_dtype == np.uint64: connected_components2d_8_bbdt[uint8_t, uint64_t]( &arr_memview8u[0,0,0], - sx, sy, sz, max_labels, + sx, sy, max_labels, &out_labels64[0] ) else: From 5852d790aee73f6ed199fcc3514eb64b35ba94f0 Mon Sep 17 00:00:00 2001 From: William Silversmith Date: Fri, 2 Oct 2020 20:12:33 -0400 Subject: [PATCH 10/23] perf: skip unification if unnecessary --- cc3d.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cc3d.hpp b/cc3d.hpp index 44ddaf0..972208f 100644 --- a/cc3d.hpp +++ b/cc3d.hpp @@ -1079,7 +1079,7 @@ OUT* connected_components2d_8_bbdt( if (in_labels[loc + Y]) { if (y > 0 && in_labels[loc + D]) { ASSIGN_Y(out_labels[loc + D]); - if (x < sx - 2 && in_labels[loc + Z] && in_labels[loc + F]) { + if (x < sx - 2 && in_labels[loc + Z] && !in_labels[loc + E] && in_labels[loc + F]) { equivalences.unify(out_labels[loc + Y], out_labels[loc + F]); } } From aa0e7dd482b6107a00f96a8dbd62fc97e0505ac2 Mon Sep 17 00:00:00 2001 From: William Silversmith Date: Fri, 2 Oct 2020 20:39:01 -0400 Subject: [PATCH 11/23] fix+perf: errors in decision tree and unnecessary unifies --- Makefile | 2 +- cc3d.hpp | 76 +++++++++++++++++++++++++++----------------------------- test.cpp | 6 ++--- 3 files changed, 40 insertions(+), 44 deletions(-) diff --git a/Makefile b/Makefile index 2820927..577b3d1 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,6 @@ shared: g++ -fPIC -shared -std=c++11 -O3 cc3d.hpp -ffast-math -o cc3d.so test: FORCE - g++ -pg -std=c++11 -g -O3 test.cpp -ffast-math -o test + g++ -std=c++11 -g -O3 test.cpp -ffast-math -o test FORCE: \ No newline at end of file diff --git a/cc3d.hpp b/cc3d.hpp index 972208f..6c26ee7 100644 --- a/cc3d.hpp +++ b/cc3d.hpp @@ -1085,40 +1085,37 @@ OUT* connected_components2d_8_bbdt( } else if (y > 0 && x < sx - 1 && in_labels[loc + E]) { ASSIGN_Y(out_labels[loc + E]); - if (x < sx - 2 && in_labels[loc + Z] && in_labels[loc + F]) { - equivalences.unify(out_labels[loc + Y], out_labels[loc + F]); + if (x > 0 && in_labels[loc + B]) { + equivalences.unify(out_labels[loc + Y], out_labels[loc + B]); } - if (x > 0 && y > 0 && in_labels[loc + C]) { + else if (x > 0 && y > 0 && in_labels[loc + C]) { equivalences.unify(out_labels[loc + Y], out_labels[loc + C]); if (y < sy - 1 && !in_labels[loc + B] && in_labels[loc + A]) { equivalences.unify(out_labels[loc + Y], out_labels[loc + A]); } } - else if (x > 0 && in_labels[loc + B]) { - equivalences.unify(out_labels[loc + Y], out_labels[loc + B]); - } else if (x > 0 && y < sy - 1 && in_labels[loc + A]) { equivalences.unify(out_labels[loc + Y], out_labels[loc + A]); } } + else if (x > 0 && in_labels[loc + B]) { + ASSIGN_Y(out_labels[loc + B]); + if (x < sx - 2 && y > 0 && in_labels[loc + Z] && in_labels[loc + F]) { + equivalences.unify(out_labels[loc + Y], out_labels[loc + F]); + } + } else if (x > 0 && y > 0 && in_labels[loc + C]) { ASSIGN_Y(out_labels[loc + C]); - if (y < sy - 1 && !in_labels[loc + B] && in_labels[loc + A]) { + if (y < sy - 1 && in_labels[loc + A]) { equivalences.unify(out_labels[loc + Y], out_labels[loc + A]); } if (x < sx - 2 && in_labels[loc + Z] && in_labels[loc + F]) { equivalences.unify(out_labels[loc + Y], out_labels[loc + F]); } } - else if (x > 0 && in_labels[loc + B]) { - ASSIGN_Y(out_labels[loc + B]); - if (x < sx - 2 && in_labels[loc + Z] && in_labels[loc + F]) { - equivalences.unify(out_labels[loc + Y], out_labels[loc + F]); - } - } else if (x > 0 && y < sx - 1 && in_labels[loc + A]) { ASSIGN_Y(out_labels[loc + A]); - if (x < sx - 2 && in_labels[loc + Z] && in_labels[loc + F]) { + if (x < sx - 2 && y > 0 && in_labels[loc + Z] && in_labels[loc + F]) { equivalences.unify(out_labels[loc + Y], out_labels[loc + F]); } } @@ -1132,33 +1129,35 @@ OUT* connected_components2d_8_bbdt( } } else if (x < sx - 1 && in_labels[loc + Z]) { - if (y > 0 && in_labels[loc + D]) { - ASSIGN_Z(out_labels[loc + D]); - if (x < sx - 2 && in_labels[loc + F]) { - equivalences.unify(out_labels[loc + Z], out_labels[loc + F]); - } + if (y > 0 && in_labels[loc + E]) { + ASSIGN_Z(out_labels[loc + E]); if (x > 0 && y < sy - 1 && in_labels[loc + X]) { if (in_labels[loc + B]) { - equivalences.unify(out_labels[loc + Z], out_labels[loc + B]); + equivalences.unify(out_labels[loc + X], out_labels[loc + B]); } else if (in_labels[loc + A]) { - equivalences.unify(out_labels[loc + Z], out_labels[loc + A]); + equivalences.unify(out_labels[loc + X], out_labels[loc + A]); } - } + } } - else if (y > 0 && in_labels[loc + E]) { - ASSIGN_Z(out_labels[loc + E]); + else if (y > 0 && in_labels[loc + D]) { + ASSIGN_Z(out_labels[loc + D]); if (x < sx - 2 && in_labels[loc + F]) { equivalences.unify(out_labels[loc + Z], out_labels[loc + F]); } if (x > 0 && y < sy - 1 && in_labels[loc + X]) { - if (in_labels[loc + B]) { - equivalences.unify(out_labels[loc + X], out_labels[loc + B]); + if (in_labels[loc + C]) { + if (!in_labels[loc + B] && in_labels[loc + A]) { + equivalences.unify(out_labels[loc + Z], out_labels[loc + A]); + } + } + else if (in_labels[loc + B]) { + equivalences.unify(out_labels[loc + Z], out_labels[loc + B]); } else if (in_labels[loc + A]) { - equivalences.unify(out_labels[loc + X], out_labels[loc + A]); + equivalences.unify(out_labels[loc + Z], out_labels[loc + A]); } - } + } } else if (x < sx - 2 && y > 0 && in_labels[loc + F]) { ASSIGN_Z(out_labels[loc + F]); @@ -1171,19 +1170,16 @@ OUT* connected_components2d_8_bbdt( } } } - else if (x > 0 && y < sy - 1 && in_labels[loc + X]) { - if (in_labels[loc + B]) { - out_labels[loc + Z] = out_labels[loc + B]; - ASSIGN_X(out_labels[loc + B]); + else if (y < sy - 1 && in_labels[loc + X]) { + if (x > 0 && in_labels[loc + B]) { + ASSIGN_Z(out_labels[loc + B]); } - else if (in_labels[loc + A]) { - out_labels[loc + Z] = out_labels[loc + A]; - ASSIGN_X(out_labels[loc + A]); + else if (x > 0 && in_labels[loc + A]) { + ASSIGN_Z(out_labels[loc + A]); } else { next_label++; - out_labels[loc + Z] = next_label; - ASSIGN_X(next_label); + ASSIGN_Z(next_label); equivalences.add(next_label); } } @@ -1196,11 +1192,11 @@ OUT* connected_components2d_8_bbdt( equivalences.add(next_label); } } - else if (x > 0 && y < sy - 1 && in_labels[loc + X]) { - if (in_labels[loc + B]) { + else if (y < sy - 1 && in_labels[loc + X]) { + if (x > 0 && in_labels[loc + B]) { ASSIGN_X(out_labels[loc + B]); } - else if (in_labels[loc + A]) { + else if (x > 0 && in_labels[loc + A]) { ASSIGN_X(out_labels[loc + A]); } else { diff --git a/test.cpp b/test.cpp index b46c7c9..773517d 100644 --- a/test.cpp +++ b/test.cpp @@ -32,15 +32,15 @@ void print(int *input, int sx, int sy, int sz) { int main () { - int sx = 2048; - int sy = 2048; + int sx = 5000; + int sy = 5000; int *big = new int[sx*sy](); for (int i = 0; i < sx*sy; i++) { big[i] = rand() % 1000; } - auto *out = cc3d::connected_components2d_4_bbdt_2(big, sx,sy, sx*sy); + auto *out = cc3d::connected_components2d_8_bbdt(big, sx,sy, sx*sy); delete[] out; delete[] big; From 27e847eaa4771c95acd746921ed2498d02900bdf Mon Sep 17 00:00:00 2001 From: William Silversmith Date: Fri, 2 Oct 2020 20:56:39 -0400 Subject: [PATCH 12/23] perf: skip unnecessary check of B --- cc3d.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cc3d.hpp b/cc3d.hpp index 6c26ee7..a872979 100644 --- a/cc3d.hpp +++ b/cc3d.hpp @@ -1090,7 +1090,7 @@ OUT* connected_components2d_8_bbdt( } else if (x > 0 && y > 0 && in_labels[loc + C]) { equivalences.unify(out_labels[loc + Y], out_labels[loc + C]); - if (y < sy - 1 && !in_labels[loc + B] && in_labels[loc + A]) { + if (y < sy - 1 && in_labels[loc + A]) { equivalences.unify(out_labels[loc + Y], out_labels[loc + A]); } } From 8edf3016d931ef4716dab387f59460485a17af87 Mon Sep 17 00:00:00 2001 From: William Silversmith Date: Fri, 2 Oct 2020 21:50:40 -0400 Subject: [PATCH 13/23] refactor: whitespace change --- cc3d.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cc3d.hpp b/cc3d.hpp index a872979..4d5b9f4 100644 --- a/cc3d.hpp +++ b/cc3d.hpp @@ -1060,7 +1060,7 @@ OUT* connected_components2d_8_bbdt( if (y < sy - 1 && in_labels[loc + X]) { \ out_labels[loc + X] = (value); \ } \ - if (y < sy - 1 && in_labels[loc +W]) { \ + if (y < sy - 1 && in_labels[loc + W]) { \ out_labels[loc + W] = (value); \ } From e2ce90aa5d9ad80f086d8b6249da52b50147166e Mon Sep 17 00:00:00 2001 From: William Silversmith Date: Thu, 24 Dec 2020 23:58:24 -0500 Subject: [PATCH 14/23] wip: not working but closer in concept to the was bbdt should work Only write one label for every 4 in the first pass. --- cc3d.hpp | 96 +++++++++++++++++++++++++++----------------------------- 1 file changed, 47 insertions(+), 49 deletions(-) diff --git a/cc3d.hpp b/cc3d.hpp index 4d5b9f4..9161bf6 100644 --- a/cc3d.hpp +++ b/cc3d.hpp @@ -1041,50 +1041,23 @@ OUT* connected_components2d_8_bbdt( const int64_t W = +1 + sx; int64_t loc = 0; + int64_t oloc = 0; OUT next_label = 0; -#define ASSIGN_Y(value) \ - out_labels[loc + Y] = (value); \ - if (x < sx - 1 && in_labels[loc + Z]) { \ - out_labels[loc + Z] = (value); \ - } \ - if (y < sy - 1 && in_labels[loc + X]) { \ - out_labels[loc + X] = (value); \ - } \ - if (x < sx - 1 && y < sy - 1 && in_labels[loc + W]) { \ - out_labels[loc + W] = (value); \ - } - -#define ASSIGN_Z(value) \ - out_labels[loc + Z] = (value); \ - if (y < sy - 1 && in_labels[loc + X]) { \ - out_labels[loc + X] = (value); \ - } \ - if (y < sy - 1 && in_labels[loc + W]) { \ - out_labels[loc + W] = (value); \ - } - -#define ASSIGN_X(value) \ - out_labels[loc + X] = (value); \ - if (x < sx - 1 && in_labels[loc + W]) { \ - out_labels[loc + W] = (value); \ - } - // Raster Scan 1: Set temporary labels and // record equivalences in a disjoint set. for (int64_t y = 0; y < sy; y += 2) { - for (int64_t x = 0; x < sx; x += 2) { - loc = x + sx * y; + for (int64_t x = 0; x < sx; x += 2, loc += 2, oloc++) { if (in_labels[loc + Y]) { if (y > 0 && in_labels[loc + D]) { - ASSIGN_Y(out_labels[loc + D]); + out_labels[oloc] = out_labels[loc + D]; if (x < sx - 2 && in_labels[loc + Z] && !in_labels[loc + E] && in_labels[loc + F]) { equivalences.unify(out_labels[loc + Y], out_labels[loc + F]); } } else if (y > 0 && x < sx - 1 && in_labels[loc + E]) { - ASSIGN_Y(out_labels[loc + E]); + out_labels[oloc] = out_labels[loc + E]; if (x > 0 && in_labels[loc + B]) { equivalences.unify(out_labels[loc + Y], out_labels[loc + B]); } @@ -1099,13 +1072,13 @@ OUT* connected_components2d_8_bbdt( } } else if (x > 0 && in_labels[loc + B]) { - ASSIGN_Y(out_labels[loc + B]); + out_labels[oloc] = out_labels[loc + B]; if (x < sx - 2 && y > 0 && in_labels[loc + Z] && in_labels[loc + F]) { equivalences.unify(out_labels[loc + Y], out_labels[loc + F]); } } else if (x > 0 && y > 0 && in_labels[loc + C]) { - ASSIGN_Y(out_labels[loc + C]); + out_labels[oloc] = out_labels[loc + C]; if (y < sy - 1 && in_labels[loc + A]) { equivalences.unify(out_labels[loc + Y], out_labels[loc + A]); } @@ -1114,23 +1087,23 @@ OUT* connected_components2d_8_bbdt( } } else if (x > 0 && y < sx - 1 && in_labels[loc + A]) { - ASSIGN_Y(out_labels[loc + A]); + out_labels[oloc] = out_labels[loc + A]; if (x < sx - 2 && y > 0 && in_labels[loc + Z] && in_labels[loc + F]) { equivalences.unify(out_labels[loc + Y], out_labels[loc + F]); } } else if (x < sx - 2 && y > 0 && in_labels[loc + Z] && in_labels[loc + F]) { - ASSIGN_Y(out_labels[loc + F]); + out_labels[oloc] = out_labels[loc + F]; } else { next_label++; - ASSIGN_Y(next_label); + out_labels[oloc] = next_label; equivalences.add(next_label); } } else if (x < sx - 1 && in_labels[loc + Z]) { if (y > 0 && in_labels[loc + E]) { - ASSIGN_Z(out_labels[loc + E]); + out_labels[oloc] = out_labels[loc + E]; if (x > 0 && y < sy - 1 && in_labels[loc + X]) { if (in_labels[loc + B]) { equivalences.unify(out_labels[loc + X], out_labels[loc + B]); @@ -1141,7 +1114,7 @@ OUT* connected_components2d_8_bbdt( } } else if (y > 0 && in_labels[loc + D]) { - ASSIGN_Z(out_labels[loc + D]); + out_labels[oloc] = out_labels[loc + D]; if (x < sx - 2 && in_labels[loc + F]) { equivalences.unify(out_labels[loc + Z], out_labels[loc + F]); } @@ -1160,7 +1133,7 @@ OUT* connected_components2d_8_bbdt( } } else if (x < sx - 2 && y > 0 && in_labels[loc + F]) { - ASSIGN_Z(out_labels[loc + F]); + out_labels[oloc] = out_labels[loc + F]; if (x > 0 && y < sy - 1 && in_labels[loc + X]) { if (in_labels[loc + B]) { equivalences.unify(out_labels[loc + X], out_labels[loc + B]); @@ -1172,14 +1145,14 @@ OUT* connected_components2d_8_bbdt( } else if (y < sy - 1 && in_labels[loc + X]) { if (x > 0 && in_labels[loc + B]) { - ASSIGN_Z(out_labels[loc + B]); + out_labels[oloc] = out_labels[loc + B]; } else if (x > 0 && in_labels[loc + A]) { - ASSIGN_Z(out_labels[loc + A]); + out_labels[oloc] = out_labels[loc + A]; } else { next_label++; - ASSIGN_Z(next_label); + out_labels[oloc] = next_label; equivalences.add(next_label); } } @@ -1194,14 +1167,14 @@ OUT* connected_components2d_8_bbdt( } else if (y < sy - 1 && in_labels[loc + X]) { if (x > 0 && in_labels[loc + B]) { - ASSIGN_X(out_labels[loc + B]); + out_labels[oloc] = out_labels[loc + B]; } else if (x > 0 && in_labels[loc + A]) { - ASSIGN_X(out_labels[loc + A]); + out_labels[oloc] = out_labels[loc + A]; } else { next_label++; - ASSIGN_X(next_label); + out_labels[oloc] = next_label; equivalences.add(next_label); } } @@ -1213,11 +1186,36 @@ OUT* connected_components2d_8_bbdt( } } -#undef ASSIGN_X -#undef ASSIGN_Y -#undef ASSIGN_Z + int64_t num_labels = next_label; - return relabel(out_labels, voxels, next_label, equivalences); + OUT label; + OUT* renumber = new OUT[num_labels + 1](); + next_label = 1; + + for (int64_t i = 1; i <= num_labels; i++) { + label = equivalences.root(i); + if (renumber[label] == 0) { + renumber[label] = next_label; + renumber[i] = next_label; + next_label++; + } + else { + renumber[i] = renumber[label]; + } + } + + // Raster Scan 2: Write final labels based on equivalences + for (int64_t y = sy - 1; y >= 0; y--) { + for (int64_t x = sx - 1; x >= 0; x--) { + loc = x + sx * y; + oloc = (x >> 1) + sx * (y >> 1); + out_labels[loc] = renumber[out_labels[oloc]]; + } + } + + delete[] renumber; + + return out_labels; } template From 8f7915ebb35854450bf86ee95f86f1e5e0aa4f9b Mon Sep 17 00:00:00 2001 From: William Silversmith Date: Fri, 25 Dec 2020 18:42:55 -0500 Subject: [PATCH 15/23] fix: several errors in bbdt implementation --- cc3d.hpp | 84 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 44 insertions(+), 40 deletions(-) diff --git a/cc3d.hpp b/cc3d.hpp index 9161bf6..e6e4748 100644 --- a/cc3d.hpp +++ b/cc3d.hpp @@ -1040,60 +1040,66 @@ OUT* connected_components2d_8_bbdt( const int64_t Z = +1; const int64_t W = +1 + sx; + const int64_t oA = -1 + ((sx+1) / 2); + const int64_t oB = -1; + const int64_t oC = -1 - ((sx+1) / 2); + const int64_t oD = -((sx+1) / 2); + const int64_t oE = +0 - ((sx+1) / 2); + const int64_t oF = +1 - ((sx+1) / 2); + int64_t loc = 0; int64_t oloc = 0; OUT next_label = 0; // Raster Scan 1: Set temporary labels and // record equivalences in a disjoint set. - for (int64_t y = 0; y < sy; y += 2) { + for (int64_t y = 0; y < sy; y += 2, loc += sx) { for (int64_t x = 0; x < sx; x += 2, loc += 2, oloc++) { - if (in_labels[loc + Y]) { if (y > 0 && in_labels[loc + D]) { - out_labels[oloc] = out_labels[loc + D]; + out_labels[oloc] = out_labels[oloc + oD]; if (x < sx - 2 && in_labels[loc + Z] && !in_labels[loc + E] && in_labels[loc + F]) { - equivalences.unify(out_labels[loc + Y], out_labels[loc + F]); + equivalences.unify(out_labels[oloc], out_labels[oloc + oF]); } } else if (y > 0 && x < sx - 1 && in_labels[loc + E]) { - out_labels[oloc] = out_labels[loc + E]; + out_labels[oloc] = out_labels[oloc + oE]; if (x > 0 && in_labels[loc + B]) { - equivalences.unify(out_labels[loc + Y], out_labels[loc + B]); + equivalences.unify(out_labels[oloc], out_labels[oloc + oB]); } else if (x > 0 && y > 0 && in_labels[loc + C]) { - equivalences.unify(out_labels[loc + Y], out_labels[loc + C]); + equivalences.unify(out_labels[oloc], out_labels[oloc + oC]); if (y < sy - 1 && in_labels[loc + A]) { - equivalences.unify(out_labels[loc + Y], out_labels[loc + A]); + equivalences.unify(out_labels[oloc], out_labels[oloc + oA]); } } else if (x > 0 && y < sy - 1 && in_labels[loc + A]) { - equivalences.unify(out_labels[loc + Y], out_labels[loc + A]); + equivalences.unify(out_labels[oloc], out_labels[oloc + oA]); } } else if (x > 0 && in_labels[loc + B]) { - out_labels[oloc] = out_labels[loc + B]; + out_labels[oloc] = out_labels[oloc + oB]; if (x < sx - 2 && y > 0 && in_labels[loc + Z] && in_labels[loc + F]) { - equivalences.unify(out_labels[loc + Y], out_labels[loc + F]); + equivalences.unify(out_labels[oloc], out_labels[oloc + oF]); } } else if (x > 0 && y > 0 && in_labels[loc + C]) { - out_labels[oloc] = out_labels[loc + C]; + out_labels[oloc] = out_labels[oloc + oC]; if (y < sy - 1 && in_labels[loc + A]) { - equivalences.unify(out_labels[loc + Y], out_labels[loc + A]); + equivalences.unify(out_labels[oloc], out_labels[oloc + oA]); } if (x < sx - 2 && in_labels[loc + Z] && in_labels[loc + F]) { - equivalences.unify(out_labels[loc + Y], out_labels[loc + F]); + equivalences.unify(out_labels[oloc], out_labels[oloc + oF]); } } else if (x > 0 && y < sx - 1 && in_labels[loc + A]) { - out_labels[oloc] = out_labels[loc + A]; + out_labels[oloc] = out_labels[oloc + oA]; if (x < sx - 2 && y > 0 && in_labels[loc + Z] && in_labels[loc + F]) { - equivalences.unify(out_labels[loc + Y], out_labels[loc + F]); + equivalences.unify(out_labels[oloc], out_labels[oloc + oF]); } } else if (x < sx - 2 && y > 0 && in_labels[loc + Z] && in_labels[loc + F]) { - out_labels[oloc] = out_labels[loc + F]; + out_labels[oloc] = out_labels[oloc + oF]; } else { next_label++; @@ -1103,52 +1109,52 @@ OUT* connected_components2d_8_bbdt( } else if (x < sx - 1 && in_labels[loc + Z]) { if (y > 0 && in_labels[loc + E]) { - out_labels[oloc] = out_labels[loc + E]; + out_labels[oloc] = out_labels[oloc + oE]; if (x > 0 && y < sy - 1 && in_labels[loc + X]) { if (in_labels[loc + B]) { - equivalences.unify(out_labels[loc + X], out_labels[loc + B]); + equivalences.unify(out_labels[oloc], out_labels[oloc + oB]); } else if (in_labels[loc + A]) { - equivalences.unify(out_labels[loc + X], out_labels[loc + A]); + equivalences.unify(out_labels[oloc], out_labels[oloc + oA]); } } } else if (y > 0 && in_labels[loc + D]) { - out_labels[oloc] = out_labels[loc + D]; + out_labels[oloc] = out_labels[oloc + oD]; if (x < sx - 2 && in_labels[loc + F]) { - equivalences.unify(out_labels[loc + Z], out_labels[loc + F]); + equivalences.unify(out_labels[oloc], out_labels[oloc + oF]); } if (x > 0 && y < sy - 1 && in_labels[loc + X]) { if (in_labels[loc + C]) { if (!in_labels[loc + B] && in_labels[loc + A]) { - equivalences.unify(out_labels[loc + Z], out_labels[loc + A]); + equivalences.unify(out_labels[oloc], out_labels[oloc + oA]); } } else if (in_labels[loc + B]) { - equivalences.unify(out_labels[loc + Z], out_labels[loc + B]); + equivalences.unify(out_labels[oloc], out_labels[oloc + oB]); } else if (in_labels[loc + A]) { - equivalences.unify(out_labels[loc + Z], out_labels[loc + A]); + equivalences.unify(out_labels[oloc], out_labels[oloc + oA]); } } } else if (x < sx - 2 && y > 0 && in_labels[loc + F]) { - out_labels[oloc] = out_labels[loc + F]; + out_labels[oloc] = out_labels[oloc + oF]; if (x > 0 && y < sy - 1 && in_labels[loc + X]) { if (in_labels[loc + B]) { - equivalences.unify(out_labels[loc + X], out_labels[loc + B]); + equivalences.unify(out_labels[oloc], out_labels[oloc + oB]); } else if (in_labels[loc + A]) { - equivalences.unify(out_labels[loc + X], out_labels[loc + A]); + equivalences.unify(out_labels[oloc], out_labels[oloc + oA]); } } } else if (y < sy - 1 && in_labels[loc + X]) { if (x > 0 && in_labels[loc + B]) { - out_labels[oloc] = out_labels[loc + B]; + out_labels[oloc] = out_labels[oloc + oB]; } else if (x > 0 && in_labels[loc + A]) { - out_labels[oloc] = out_labels[loc + A]; + out_labels[oloc] = out_labels[oloc + oA]; } else { next_label++; @@ -1158,19 +1164,16 @@ OUT* connected_components2d_8_bbdt( } else { // ZW next_label++; - out_labels[loc + Z] = next_label; - if (y < sy - 1 && in_labels[loc + W]) { - out_labels[loc + W] = next_label; - } + out_labels[oloc] = next_label; equivalences.add(next_label); } } else if (y < sy - 1 && in_labels[loc + X]) { if (x > 0 && in_labels[loc + B]) { - out_labels[oloc] = out_labels[loc + B]; + out_labels[oloc] = out_labels[oloc + oB]; } else if (x > 0 && in_labels[loc + A]) { - out_labels[oloc] = out_labels[loc + A]; + out_labels[oloc] = out_labels[oloc + oA]; } else { next_label++; @@ -1180,7 +1183,7 @@ OUT* connected_components2d_8_bbdt( } else if (x < sx - 1 && y < sy - 1 && in_labels[loc + W]) { next_label++; - out_labels[loc + W] = next_label; + out_labels[oloc] = next_label; equivalences.add(next_label); } } @@ -1207,9 +1210,10 @@ OUT* connected_components2d_8_bbdt( // Raster Scan 2: Write final labels based on equivalences for (int64_t y = sy - 1; y >= 0; y--) { for (int64_t x = sx - 1; x >= 0; x--) { - loc = x + sx * y; - oloc = (x >> 1) + sx * (y >> 1); - out_labels[loc] = renumber[out_labels[oloc]]; + loc = x + sx * y; + oloc = (x / 2) + (sx / 2) * (y / 2); + // printf("<%d,%d> loc: %d oloc: %d label: %d\n", x, y, loc, oloc, out_labels[oloc]); + out_labels[loc] = (in_labels[loc] != 0) * renumber[out_labels[oloc]]; } } From 089e851edc33653f21713dce13f537f52812bcfe Mon Sep 17 00:00:00 2001 From: William Silversmith Date: Fri, 25 Dec 2020 18:55:33 -0500 Subject: [PATCH 16/23] fix: oA computed wrong --- cc3d.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cc3d.hpp b/cc3d.hpp index e6e4748..d5ceaf3 100644 --- a/cc3d.hpp +++ b/cc3d.hpp @@ -1040,11 +1040,12 @@ OUT* connected_components2d_8_bbdt( const int64_t Z = +1; const int64_t W = +1 + sx; - const int64_t oA = -1 + ((sx+1) / 2); + // output offsets + const int64_t oA = -1; const int64_t oB = -1; const int64_t oC = -1 - ((sx+1) / 2); const int64_t oD = -((sx+1) / 2); - const int64_t oE = +0 - ((sx+1) / 2); + const int64_t oE = -((sx+1) / 2); const int64_t oF = +1 - ((sx+1) / 2); int64_t loc = 0; From 604602f0c0a9f32896ab9ce15578175669b872c9 Mon Sep 17 00:00:00 2001 From: William Silversmith Date: Fri, 25 Dec 2020 21:15:23 -0500 Subject: [PATCH 17/23] perf: faster relabel loop --- cc3d.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cc3d.hpp b/cc3d.hpp index d5ceaf3..3396f23 100644 --- a/cc3d.hpp +++ b/cc3d.hpp @@ -1213,8 +1213,7 @@ OUT* connected_components2d_8_bbdt( for (int64_t x = sx - 1; x >= 0; x--) { loc = x + sx * y; oloc = (x / 2) + (sx / 2) * (y / 2); - // printf("<%d,%d> loc: %d oloc: %d label: %d\n", x, y, loc, oloc, out_labels[oloc]); - out_labels[loc] = (in_labels[loc] != 0) * renumber[out_labels[oloc]]; + out_labels[loc] = ~(static_cast(in_labels[loc] > 0) - 1) & renumber[out_labels[oloc]]; } } From 1e73adb00fe1700305672d5dc3bf6c66bcc8f125 Mon Sep 17 00:00:00 2001 From: William Silversmith Date: Fri, 25 Dec 2020 21:30:37 -0500 Subject: [PATCH 18/23] fix: make comparison more robust --- cc3d.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cc3d.hpp b/cc3d.hpp index 3396f23..6e6b2e5 100644 --- a/cc3d.hpp +++ b/cc3d.hpp @@ -1209,9 +1209,9 @@ OUT* connected_components2d_8_bbdt( } // Raster Scan 2: Write final labels based on equivalences + loc = voxels - 1; for (int64_t y = sy - 1; y >= 0; y--) { - for (int64_t x = sx - 1; x >= 0; x--) { - loc = x + sx * y; + for (int64_t x = sx - 1; x >= 0; x--, loc--) { oloc = (x / 2) + (sx / 2) * (y / 2); out_labels[loc] = ~(static_cast(in_labels[loc] > 0) - 1) & renumber[out_labels[oloc]]; } From fcf6602c86cc1fa71fa51e8844001e8819566fbf Mon Sep 17 00:00:00 2001 From: William Silversmith Date: Fri, 25 Dec 2020 21:32:33 -0500 Subject: [PATCH 19/23] fix: make the comparison more robust in relabel --- cc3d.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cc3d.hpp b/cc3d.hpp index 6e6b2e5..c84bea6 100644 --- a/cc3d.hpp +++ b/cc3d.hpp @@ -1213,7 +1213,7 @@ OUT* connected_components2d_8_bbdt( for (int64_t y = sy - 1; y >= 0; y--) { for (int64_t x = sx - 1; x >= 0; x--, loc--) { oloc = (x / 2) + (sx / 2) * (y / 2); - out_labels[loc] = ~(static_cast(in_labels[loc] > 0) - 1) & renumber[out_labels[oloc]]; + out_labels[loc] = ~(static_cast(in_labels[loc] != 0) - 1) & renumber[out_labels[oloc]]; } } From 80b9a9e9692754df52a3f4cebbd0c775d7287bd3 Mon Sep 17 00:00:00 2001 From: William Silversmith Date: Fri, 25 Dec 2020 22:13:19 -0500 Subject: [PATCH 20/23] fix: loc was not computed correctly for odd sizes --- cc3d.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cc3d.hpp b/cc3d.hpp index c84bea6..5892406 100644 --- a/cc3d.hpp +++ b/cc3d.hpp @@ -1054,8 +1054,9 @@ OUT* connected_components2d_8_bbdt( // Raster Scan 1: Set temporary labels and // record equivalences in a disjoint set. - for (int64_t y = 0; y < sy; y += 2, loc += sx) { - for (int64_t x = 0; x < sx; x += 2, loc += 2, oloc++) { + for (int64_t y = 0; y < sy; y += 2) { + for (int64_t x = 0; x < sx; x += 2, oloc++) { + loc = x + sx * y; if (in_labels[loc + Y]) { if (y > 0 && in_labels[loc + D]) { out_labels[oloc] = out_labels[oloc + oD]; From 47ac1ca4cd9aa2d6d74141735fe8ee6702e200ab Mon Sep 17 00:00:00 2001 From: William Silversmith Date: Fri, 25 Dec 2020 22:15:44 -0500 Subject: [PATCH 21/23] fix: missing join of A --- cc3d.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cc3d.hpp b/cc3d.hpp index 5892406..a4619d5 100644 --- a/cc3d.hpp +++ b/cc3d.hpp @@ -1063,6 +1063,9 @@ OUT* connected_components2d_8_bbdt( if (x < sx - 2 && in_labels[loc + Z] && !in_labels[loc + E] && in_labels[loc + F]) { equivalences.unify(out_labels[oloc], out_labels[oloc + oF]); } + if (x > 0 && y < sy - 1 && !in_labels[loc + B] && in_labels[loc + A]) { + equivalences.unify(out_labels[oloc], out_labels[oloc + oA]); + } } else if (y > 0 && x < sx - 1 && in_labels[loc + E]) { out_labels[oloc] = out_labels[oloc + oE]; From 0df79d70ca639659985ad5e5325d463d75a9c9fa Mon Sep 17 00:00:00 2001 From: William Silversmith Date: Sat, 26 Dec 2020 11:56:40 -0500 Subject: [PATCH 22/23] perf: faster relabel loop --- cc3d.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cc3d.hpp b/cc3d.hpp index a4619d5..277bfc1 100644 --- a/cc3d.hpp +++ b/cc3d.hpp @@ -1216,8 +1216,8 @@ OUT* connected_components2d_8_bbdt( loc = voxels - 1; for (int64_t y = sy - 1; y >= 0; y--) { for (int64_t x = sx - 1; x >= 0; x--, loc--) { - oloc = (x / 2) + (sx / 2) * (y / 2); - out_labels[loc] = ~(static_cast(in_labels[loc] != 0) - 1) & renumber[out_labels[oloc]]; + oloc = (x >> 1) + (sx >> 1) * (y >> 1); + out_labels[loc] = (static_cast(in_labels[loc] == 0) - 1) & renumber[out_labels[oloc]]; } } From fb35532a756d2b4d51f32b9b6946f1b50dd91a35 Mon Sep 17 00:00:00 2001 From: William Silversmith Date: Fri, 19 Jul 2024 17:59:54 -0400 Subject: [PATCH 23/23] fix: np.bool doesn't work anymore --- automated_test.py | 8 ++++---- cc3d.pyx | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/automated_test.py b/automated_test.py index bccc62d..7566243 100644 --- a/automated_test.py +++ b/automated_test.py @@ -416,7 +416,7 @@ def test_compare_scipy_26(out_dtype): import scipy.ndimage.measurements sx, sy, sz = 128, 128, 128 - labels = np.random.randint(0,2, (sx,sy,sz), dtype=np.bool) + labels = np.random.randint(0,2, (sx,sy,sz), dtype=bool) structure = [ [[1,1,1], [1,1,1], [1,1,1]], @@ -436,7 +436,7 @@ def test_compare_scipy_18(): import scipy.ndimage.measurements sx, sy, sz = 256, 256, 256 - labels = np.random.randint(0,2, (sx,sy,sz), dtype=np.bool) + labels = np.random.randint(0,2, (sx,sy,sz), dtype=bool) structure = [ [[0,1,0], [1,1,1], [0,1,0]], @@ -457,7 +457,7 @@ def test_compare_scipy_6(): import scipy.ndimage.measurements sx, sy, sz = 256, 256, 256 - labels = np.random.randint(0,2, (sx,sy,sz), dtype=np.bool) + labels = np.random.randint(0,2, (sx,sy,sz), dtype=bool) cc3d_labels = cc3d.connected_components(labels, connectivity=6) scipy_labels, wow = scipy.ndimage.measurements.label(labels) @@ -574,7 +574,7 @@ def test_region_graph_6(): ]) def test_stress_upper_bound_for_binary(): - labels = np.zeros((256,256,256), dtype=np.bool) + labels = np.zeros((256,256,256), dtype=bool) for z in range(256): for y in range(256): off = (y + (z % 2)) % 2 diff --git a/cc3d.pyx b/cc3d.pyx index 510268a..30f886a 100644 --- a/cc3d.pyx +++ b/cc3d.pyx @@ -172,7 +172,7 @@ def connected_components( # For 3D six-connected data the same ratio holds # for a 2x2x2 block, where 1/2 the slots are filled # in the worst case. - if data.dtype == np.bool: + if data.dtype == bool: max_labels = min(max_labels, ((data.size + 1) // 2) + 1) dtype = data.dtype @@ -237,7 +237,7 @@ def connected_components( sx, sy, sz, max_labels, connectivity, &out_labels64[0] ) - elif dtype in (np.uint8, np.int8) or (dtype == np.bool and connectivity != 8): + elif dtype in (np.uint8, np.int8) or (dtype == bool and connectivity != 8): arr_memview8u = data.view(np.uint8) if out_dtype == np.uint16: connected_components3d[uint8_t, uint16_t]( @@ -257,7 +257,7 @@ def connected_components( sx, sy, sz, max_labels, connectivity, &out_labels64[0] ) - elif dtype == np.bool and connectivity == 8: + elif dtype == bool and connectivity == 8: arr_memview8u = data.view(np.uint8) if out_dtype == np.uint16: connected_components2d_8_bbdt[uint8_t, uint16_t](