mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-11 22:51:34 +08:00
ENH minor speedups.
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user