mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-04 04:10:34 +08:00
Fix bug in exclude_border option
This commit is contained in:
@@ -137,7 +137,7 @@ def peak_local_max(image, min_distance=1, threshold_abs=None,
|
||||
image_max = ndi.maximum_filter(image, size=size, mode='constant')
|
||||
mask = image == image_max
|
||||
|
||||
if exclude_border:
|
||||
if exclude_border and (footprint is not None or min_distance > 0):
|
||||
# zero out the image borders
|
||||
for i in range(mask.ndim):
|
||||
mask = mask.swapaxes(0, i)
|
||||
|
||||
@@ -310,6 +310,19 @@ def test_4D():
|
||||
[[5, 5, 5, 5], [15, 15, 15, 15]])
|
||||
|
||||
|
||||
def test_threshold_rel_default():
|
||||
image = np.ones((5, 5))
|
||||
|
||||
image[2, 2] = 1
|
||||
assert len(peak.peak_local_max(image)) == 0
|
||||
|
||||
image[2, 2] = 2
|
||||
assert_equal(peak.peak_local_max(image), [[2, 2]])
|
||||
|
||||
image[2, 2] = 0
|
||||
assert len(peak.peak_local_max(image, min_distance=0)) == image.size - 1
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from numpy import testing
|
||||
testing.run_module_suite()
|
||||
|
||||
Reference in New Issue
Block a user