Beispiel #1
0
 def test_threshold(self):
     image = cp.zeros((15, 15))
     x0, y0, i0 = (12, 8, 10)
     x1, y1, i1 = (2, 2, 8)
     x2, y2, i2 = (5, 13, 10)
     image[y0, x0] = i0
     image[y1, x1] = i1
     image[y2, x2] = i2
     out = peak._prominent_peaks(image, threshold=None)
     assert len(out[0]) == 3
     for i, x, y in zip(out[0], out[1], out[2]):
         self.assertTrue(i in (i0, i1, i2))
         self.assertTrue(x in (x0, x1, x2))
     out = peak._prominent_peaks(image, threshold=9)
     assert len(out[0]) == 2
     for i, x, y in zip(out[0], out[1], out[2]):
         self.assertTrue(i in (i0, i2))
         self.assertTrue(x in (x0, x2))
         self.assertTrue(y in (y0, y2))
Beispiel #2
0
 def test_peaks_in_contact(self):
     image = cp.zeros((15, 15))
     x0, y0, i0 = (8, 8, 1)
     x1, y1, i1 = (7, 7, 1)  # prominent peak
     x2, y2, i2 = (6, 6, 1)
     image[y0, x0] = i0
     image[y1, x1] = i1
     image[y2, x2] = i2
     out = peak._prominent_peaks(image, min_xdistance=3, min_ydistance=3)
     assert_array_equal(out[0], cp.asarray((i1,)))
     assert_array_equal(out[1], cp.asarray((x1,)))
     assert_array_equal(out[2], cp.asarray((y1,)))