Exemplo n.º 1
0
def test_relative_and_absolute_thresholds_in_peak_local_max():
    image = np.zeros((5, 5))
    image[1, 1] = 10
    image[3, 3] = 20
    peaks_rel = _peak_local_max(image, min_distance=1, threshold_rel=0.5)
    np.testing.assert_equal(len(peaks_rel[peaks_rel == 1]), 1)
    peaks_abs = _peak_local_max(image, min_distance=1, threshold_abs=10)
    np.testing.assert_equal(len(peaks_abs[peaks_abs == 1]), 1)
Exemplo n.º 2
0
def test_trivial_cases_in_peak_local_max():
    trivial = np.zeros((25, 25))
    peaks = _peak_local_max(trivial, min_distance=1)
    assert (peaks.astype(np.bool) == trivial).all()
Exemplo n.º 3
0
def test_constant_image_in_peak_local_max():
    image = 128 * np.ones((20, 20))
    peaks = _peak_local_max(image, min_distance=1)
    np.testing.assert_equal(len(peaks[peaks == 1]), 0)
Exemplo n.º 4
0
def test_flat_peak_local_max():
    image = np.zeros((5, 5))
    image[1:3, 1:3] = 10
    peaks = _peak_local_max(image, min_distance=1)
    np.testing.assert_equal(len(peaks[peaks == 1]), 4)
Exemplo n.º 5
0
def test_empty_peak_local_max():
    image = np.zeros((10, 20))
    result = _peak_local_max(image, min_distance=1, threshold_rel=0)
    assert np.all(~result)