Merge pull request #467 from malcolmreynolds/fix-num-peaks-typo

FIX: number of peaks returned from feature.corner_peaks
This commit is contained in:
Johannes Schönberger
2013-03-18 08:55:17 -07:00
2 changed files with 14 additions and 1 deletions
+1 -1
View File
@@ -489,7 +489,7 @@ def corner_peaks(image, min_distance=10, threshold_abs=0, threshold_rel=0.1,
threshold_abs=threshold_abs,
threshold_rel=threshold_rel,
exclude_border=exclude_border,
indices=False, num_peaks=np.inf,
indices=False, num_peaks=num_peaks,
footprint=footprint, labels=labels)
if min_distance > 0:
coords = np.transpose(peaks.nonzero())
+13
View File
@@ -100,6 +100,19 @@ def test_subpix():
assert_array_equal(subpix[0], (24.5, 24.5))
def test_num_peaks():
"""For a bunch of different values of num_peaks, check that
peak_local_max returns exactly the right amount of peaks. Test
is run on Lena in order to produce a sufficient number of corners"""
lena_corners = corner_harris(data.lena())
for i in range(20):
n = np.random.random_integers(20)
results = peak_local_max(lena_corners, num_peaks=n)
assert (results.shape[0] == n)
def test_corner_peaks():
response = np.zeros((5, 5))
response[2:4, 2:4] = 1