mirror of
https://github.com/wassname/scikit-image.git
synced 2026-08-11 11:25:30 +08:00
change doc for indices and remove the unnecessarily tolist() operation
This commit is contained in:
@@ -33,8 +33,8 @@ def peak_local_max(image, min_distance=10, threshold_abs=0, threshold_rel=0.1,
|
||||
If True, `min_distance` excludes peaks from the border of the image as
|
||||
well as from each other.
|
||||
indices : bool
|
||||
If True, the output will be a matrix representing peak coordinates.
|
||||
If False, the output will be a boolean matrix shaped as `image.shape`
|
||||
If True, the output will be an array representing peak coordinates.
|
||||
If False, the output will be a boolean array shaped as `image.shape`
|
||||
with peaks present at True elements.
|
||||
num_peaks : int
|
||||
Maximum number of peaks. When the number of peaks exceeds `num_peaks`,
|
||||
@@ -150,6 +150,6 @@ def peak_local_max(image, min_distance=10, threshold_abs=0, threshold_rel=0.1,
|
||||
if indices is True:
|
||||
return coordinates
|
||||
else:
|
||||
nd_indices = tuple(coordinates.T.tolist())
|
||||
nd_indices = tuple(coordinates.T)
|
||||
out[nd_indices] = True
|
||||
return out
|
||||
|
||||
@@ -116,12 +116,13 @@ 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
|
||||
|
||||
Reference in New Issue
Block a user