Permalink
Browse files

Change reconstruction to support Cython 0.15.

This removes use of Cython's typed memoryviews.

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

Conflicts:

	skimage/morphology/_greyreconstruct.pyx
  • Loading branch information...
1 parent ce423e1 commit e350db23a2c91c008f2193193fd43d5a4a2cfc75 @tonysyu tonysyu committed Aug 25, 2012
Showing with 22 additions and 9 deletions.
  1. +1 −1 DEPENDS.txt
  2. +21 −8 skimage/morphology/_greyreconstruct.pyx
View
@@ -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.
@@ -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:

0 comments on commit e350db2

Please sign in to comment.