Bug fixes: concatenation order and shape assignments

This commit is contained in:
Juan Nunez-Iglesias
2013-07-02 13:22:13 +02:00
parent 6dc8e6300b
commit 8e4ab32ed9
2 changed files with 4 additions and 3 deletions
+2 -1
View File
@@ -22,7 +22,8 @@ def _slic_cython(cnp.ndarray[dtype=cnp.float_t, ndim=4] image_zyx,
# initialize on grid:
cdef Py_ssize_t depth, height, width
depth, height, width = image_zyx.shape[0], image_zyx[1], image_zyx[2]
shape = image_zyx.shape
depth, height, width = shape[0], shape[1], 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]
+2 -2
View File
@@ -101,9 +101,9 @@ def slic(image, n_segments=100, ratio=10., max_iter=10, sigma=1,
# we do the scaling of ratio in the same way as in the SLIC paper
# so the values have the same meaning
ratio = (ratio / float(max((step_z, step_y, step_x)))) ** 2
image_zyx = np.concatenate([grid_y[..., np.newaxis],
image_zyx = np.concatenate([grid_z[..., np.newaxis],
grid_y[..., np.newaxis],
grid_x[..., np.newaxis],
grid_z[..., np.newaxis],
image / ratio], axis=-1).copy("C")
nearest_mean = np.zeros((depth, height, width), dtype=np.intp)
distance = np.empty((depth, height, width), dtype=np.float)