From cd197527fb39796520dd22e1f8df97b17a4810b3 Mon Sep 17 00:00:00 2001 From: Juan Nunez-Iglesias Date: Tue, 2 Jul 2013 13:16:17 +0200 Subject: [PATCH] Speed up initialising 'distance' in SLIC --- skimage/segmentation/_slic.pyx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/skimage/segmentation/_slic.pyx b/skimage/segmentation/_slic.pyx index 337be882..654c5cff 100644 --- a/skimage/segmentation/_slic.pyx +++ b/skimage/segmentation/_slic.pyx @@ -51,7 +51,6 @@ def _slic_cython(double[:, :, :, ::1] image_zyx, image_zyx.shape[2]) # approximate grid size for desired n_segments cdef Py_ssize_t step_z, step_y, step_x - grid_z, grid_y, grid_x = np.mgrid[:depth, :height, :width] slices = regular_grid((depth, height, width), n_segments) step_z, step_y, step_x = [int(s.step) for s in slices] @@ -65,10 +64,7 @@ def _slic_cython(double[:, :, :, ::1] image_zyx, #cdef double[::1] image_zyx_ravel_j for i in range(max_iter): changes = 0 - for z in range(depth): - for y in range(height): - for x in range(width): - distance[z, y, x] = np.inf + distance[:, :, :] = np.inf # assign pixels to means for k in range(n_means): # compute windows: