From 3e28168914628dbf5a01b6ade9fd1a29a7613382 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Fri, 18 Oct 2013 20:56:18 +0200 Subject: [PATCH] Speed up memory views in skeletonize function --- skimage/morphology/_skeletonize.py | 8 ++++---- skimage/morphology/_skeletonize_cy.pyx | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/skimage/morphology/_skeletonize.py b/skimage/morphology/_skeletonize.py index 8872aada..11181a7b 100644 --- a/skimage/morphology/_skeletonize.py +++ b/skimage/morphology/_skeletonize.py @@ -282,8 +282,8 @@ def medial_axis(image, mask=None, return_distance=False): i, j = np.mgrid[0:image.shape[0], 0:image.shape[1]] result = masked_image.copy() distance = distance[result] - i = np.ascontiguousarray(i[result], np.intp) - j = np.ascontiguousarray(j[result], np.intp) + i = np.ascontiguousarray(i[result], dtype=np.intp) + j = np.ascontiguousarray(j[result], dtype=np.intp) result = np.ascontiguousarray(result, np.uint8) # Determine the order in which pixels are processed. @@ -296,9 +296,9 @@ def medial_axis(image, mask=None, return_distance=False): order = np.lexsort((tiebreaker, corner_score[masked_image], distance)) - order = np.ascontiguousarray(order, np.int32) + order = np.ascontiguousarray(order, dtype=np.int32) - table = np.ascontiguousarray(table, np.uint8) + table = np.ascontiguousarray(table, dtype=np.uint8) # Remove pixels not belonging to the medial axis _skeletonize_loop(result, i, j, order, table) diff --git a/skimage/morphology/_skeletonize_cy.pyx b/skimage/morphology/_skeletonize_cy.pyx index 10e70d98..c4471a11 100644 --- a/skimage/morphology/_skeletonize_cy.pyx +++ b/skimage/morphology/_skeletonize_cy.pyx @@ -20,8 +20,8 @@ cimport numpy as cnp def _skeletonize_loop(cnp.uint8_t[:, ::1] result, - Py_ssize_t[:] i, Py_ssize_t[:] j, - cnp.int32_t[:] order, cnp.uint8_t[:] table): + Py_ssize_t[::1] i, Py_ssize_t[::1] j, + cnp.int32_t[::1] order, cnp.uint8_t[::1] table): """ Inner loop of skeletonize function