diff --git a/skimage/feature/peak.py b/skimage/feature/peak.py index 9c7a934f..fb6e3465 100644 --- a/skimage/feature/peak.py +++ b/skimage/feature/peak.py @@ -150,5 +150,6 @@ def peak_local_max(image, min_distance=10, threshold_abs=0, threshold_rel=0.1, if indices is True: return coordinates else: - out[coordinates[:, 0], coordinates[:, 1]] = True + nd_indices = tuple(coordinates.T.tolist()) + out[nd_indices] = True return out diff --git a/skimage/feature/tests/test_peak.py b/skimage/feature/tests/test_peak.py index 3ef1f12d..46854c41 100644 --- a/skimage/feature/tests/test_peak.py +++ b/skimage/feature/tests/test_peak.py @@ -116,6 +116,12 @@ def test_indices_with_labels(): indices=True, exclude_border=False) assert (result == np.transpose(expected.nonzero())).all() +def test_ndarray_indices_false(): + nd_image = np.zeros((5,5,5)) + nd_image[2,2,2] = 1 + peaks = peak.peak_local_max(nd_image, min_distance=1, indices=False) + assert (peaks == nd_image.astype(np.bool)).all() + if __name__ == '__main__': from numpy import testing