From 1b66ab479a843fb1bcfbd996b1b16f205571fd19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Fri, 18 Oct 2013 21:00:40 +0200 Subject: [PATCH] Speed up memory views in watershed function --- skimage/morphology/_watershed.pyx | 6 +++--- skimage/morphology/watershed.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/skimage/morphology/_watershed.pyx b/skimage/morphology/_watershed.pyx index beaf874b..a0857707 100644 --- a/skimage/morphology/_watershed.pyx +++ b/skimage/morphology/_watershed.pyx @@ -23,12 +23,12 @@ include "heap_watershed.pxi" @cython.boundscheck(False) -def watershed(DTYPE_INT32_t[:] image, +def watershed(DTYPE_INT32_t[::1] image, DTYPE_INT32_t[:, ::1] pq, Py_ssize_t age, DTYPE_INT32_t[:, ::1] structure, - DTYPE_BOOL_t[:] mask, - DTYPE_INT32_t[:] output): + DTYPE_BOOL_t[::1] mask, + DTYPE_INT32_t[::1] output): """Do heavy lifting of watershed algorithm Parameters diff --git a/skimage/morphology/watershed.py b/skimage/morphology/watershed.py index c9fb1789..2bdb57b2 100644 --- a/skimage/morphology/watershed.py +++ b/skimage/morphology/watershed.py @@ -202,7 +202,7 @@ def watershed(image, markers, connectivity=None, offset=None, mask=None): stride = np.dot(image_stride, np.array(offs)) offs.insert(0, stride) c.append(offs) - c = np.array(c, np.int32) + c = np.array(c, dtype=np.int32) pq, age = __heapify_markers(c_markers, c_image) pq = np.ascontiguousarray(pq, dtype=np.int32)