ENH minor speedups.

This commit is contained in:
Andreas Mueller
2012-08-10 10:03:20 +01:00
parent ea02bc6170
commit f88a29b091
+2 -1
View File
@@ -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]