Change threshold test from >= to >.

This commit is contained in:
Tony S Yu
2012-04-15 23:48:27 -04:00
parent 187bc6d5b8
commit 2585a323ac
2 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -51,7 +51,7 @@ def peak_local_max(image, min_distance=10, threshold='deprecated',
threshold_rel = threshold
# find top corner candidates above a threshold
corner_threshold = max(np.max(image.ravel()) * threshold_rel, threshold_abs)
image_t = (image >= corner_threshold) * 1
image_t = (image > corner_threshold) * 1
# get coordinates of peaks
coordinates = np.transpose(image_t.nonzero())
+3 -3
View File
@@ -22,7 +22,7 @@ def test_noisy_peaks():
def test_relative_threshold():
image = np.zeros((5, 5), dtype=np.uint8)
image[1, 1] = 10
image[3, 3] = 21
image[3, 3] = 20
peaks = peak.peak_local_max(image, min_distance=1, threshold_rel=0.5)
assert len(peaks) == 1
assert_close(peaks, [(3, 3)])
@@ -31,8 +31,8 @@ def test_relative_threshold():
def test_absolute_threshold():
image = np.zeros((5, 5), dtype=np.uint8)
image[1, 1] = 10
image[3, 3] = 21
peaks = peak.peak_local_max(image, min_distance=1, threshold_abs=11)
image[3, 3] = 20
peaks = peak.peak_local_max(image, min_distance=1, threshold_abs=10)
assert len(peaks) == 1
assert_close(peaks, [(3, 3)])