From f88a29b091c6af19e7d3df3bc8f91c49216106e5 Mon Sep 17 00:00:00 2001 From: Andreas Mueller Date: Fri, 10 Aug 2012 10:03:20 +0100 Subject: [PATCH] ENH minor speedups. --- skimage/segmentation/_slic.pyx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/skimage/segmentation/_slic.pyx b/skimage/segmentation/_slic.pyx index 98a6f6bc..684740d6 100644 --- a/skimage/segmentation/_slic.pyx +++ b/skimage/segmentation/_slic.pyx @@ -51,9 +51,10 @@ def slic(image, n_segments=100, ratio=10., max_iter=10, sigma=1, image = rgb2lab(image) # initialize on grid: + cdef int height, width height, width = image.shape[:2] # approximate grid size for desired n_segments - step = np.ceil(np.sqrt(height * width / n_segments)) + cdef int step = np.ceil(np.sqrt(height * width / n_segments)) grid_y, grid_x = np.mgrid[:height, :width] means_y = grid_y[::step, ::step] means_x = grid_x[::step, ::step]