mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-15 11:25:53 +08:00
Merge pull request #270 from tonysyu/cython-0.15-compat
BUG: Make reconstruction compatible with Cython 0.15.
This commit is contained in:
+1
-1
@@ -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:
|
||||
|
||||
@@ -11,7 +11,7 @@ Original author: Lee Kamentsky
|
||||
"""
|
||||
import numpy as np
|
||||
|
||||
from skimage.filter.rank_order import rank_order
|
||||
from skimage.filter._rank_order import rank_order
|
||||
|
||||
|
||||
def reconstruction(seed, mask, method='dilation', selem=None, offset=None):
|
||||
|
||||
Reference in New Issue
Block a user