Change reconstruction to support Cython 0.15.

This removes use of Cython's typed memoryviews.

This reverts commit b5d9106966: "ENH: Use Cython data types instead of Numpy dtypes."

Conflicts:

	skimage/morphology/_greyreconstruct.pyx
This commit is contained in:
Tony S Yu
2012-08-25 14:04:48 -04:00
parent ce423e169e
commit e350db23a2
2 changed files with 22 additions and 9 deletions
+1 -1
View File
@@ -2,7 +2,7 @@ Build Requirements
------------------
* `Python >= 2.5 <http://python.org>`__
* `Numpy >= 1.6 <http://numpy.scipy.org/>`__
* `Cython >= 0.16 <http://www.cython.org/>`__
* `Cython >= 0.15 <http://www.cython.org/>`__
`Matplotlib >= 1.0 <http://matplotlib.sf.net>`__ is needed to generate the
examples in the documentation.
+21 -8
View File
@@ -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 = <cnp.uint32_t *>(aranks.data)
cdef cnp.int32_t *prev = <cnp.int32_t *>(aprev.data)
cdef cnp.int32_t *next = <cnp.int32_t *>(anext.data)
cdef cnp.int32_t *strides = <cnp.int32_t *>(astrides.data)
while current_idx != -1:
if current_idx < image_stride: