diff --git a/DEPENDS.txt b/DEPENDS.txt index 7793abdb..b2858256 100644 --- a/DEPENDS.txt +++ b/DEPENDS.txt @@ -2,7 +2,7 @@ Build Requirements ------------------ * `Python >= 2.5 `__ * `Numpy >= 1.6 `__ -* `Cython >= 0.16 `__ +* `Cython >= 0.15 `__ `Matplotlib >= 1.0 `__ is needed to generate the examples in the documentation. diff --git a/skimage/morphology/_greyreconstruct.pyx b/skimage/morphology/_greyreconstruct.pyx index 5d2cb0c5..e8a84f3b 100644 --- a/skimage/morphology/_greyreconstruct.pyx +++ b/skimage/morphology/_greyreconstruct.pyx @@ -8,12 +8,21 @@ All rights reserved. Original author: Lee Kamentsky """ +cimport numpy as cnp cimport cython @cython.boundscheck(False) -def reconstruction_loop(unsigned int[:] ranks, int[:] prev, int[:] next, - int[:] strides, int current_idx, int image_stride): +def reconstruction_loop(cnp.ndarray[dtype=cnp.uint32_t, ndim=1, + negative_indices=False, mode='c'] aranks, + cnp.ndarray[dtype=cnp.int32_t, ndim=1, + negative_indices=False, mode='c'] aprev, + cnp.ndarray[dtype=cnp.int32_t, ndim=1, + negative_indices=False, mode='c'] anext, + cnp.ndarray[dtype=cnp.int32_t, ndim=1, + negative_indices=False, mode='c'] astrides, + int current_idx, + int image_stride): """The inner loop for reconstruction. This algorithm uses the rank-order of pixels. If low intensity pixels have @@ -28,20 +37,24 @@ def reconstruction_loop(unsigned int[:] ranks, int[:] prev, int[:] next, Parameters ---------- - ranks : array + aranks : array The rank order of the flattened seed and mask images. - prev, next: arrays + aprev, anext: arrays Indices of previous and next pixels in rank sorted order. - strides : array + astrides : array Strides to neighbors of the current pixel. current_idx : int Index of highest-ranked pixel used as starting point in loop. image_stride : int - Stride between seed image and mask image in `ranks`. + Stride between seed image and mask image in `aranks`. """ cdef unsigned int neighbor_rank, current_rank, mask_rank - cdef int i, current_link, neighbor_idx, nprev, nnext - cdef int nstrides = strides.shape[0] + cdef int i, neighbor_idx, current_link, nprev, nnext + cdef int nstrides = astrides.shape[0] + cdef cnp.uint32_t *ranks = (aranks.data) + cdef cnp.int32_t *prev = (aprev.data) + cdef cnp.int32_t *next = (anext.data) + cdef cnp.int32_t *strides = (astrides.data) while current_idx != -1: if current_idx < image_stride: