mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-20 12:40:31 +08:00
Fix: return empty list for flat image.
This commit is contained in:
@@ -32,6 +32,8 @@ def peak_local_max(image, min_distance=10, threshold='deprecated',
|
||||
coordinates : (N, 2) array
|
||||
(row, column) coordinates of peaks.
|
||||
"""
|
||||
if np.all(image == image.flat[0]):
|
||||
return []
|
||||
image = image.copy()
|
||||
# Non maximum filter
|
||||
size = 2 * min_distance + 1
|
||||
|
||||
@@ -36,6 +36,13 @@ def test_absolute_threshold():
|
||||
assert len(peaks) == 1
|
||||
assert_close(peaks, [(3, 3)])
|
||||
|
||||
|
||||
def test_constant_image():
|
||||
image = 128 * np.ones((20, 20), dtype=np.uint8)
|
||||
peaks = peak.peak_local_max(image, min_distance=1)
|
||||
assert len(peaks) == 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from numpy import testing
|
||||
testing.run_module_suite()
|
||||
|
||||
Reference in New Issue
Block a user