def test_outer_pix(fake_butterfly): middle = tracing.split_picture(fake_butterfly) binary_left = fake_butterfly[:, :middle] binary_right = fake_butterfly[:, middle:] outer_pix_l = tracing.detect_outer_pix(binary_left, 'l') outer_pix_r = tracing.detect_outer_pix(binary_right, 'r') outer_pix_r = outer_pix_r + np.array([0, middle]) assert_array_equal(outer_pix_l, np.array([250, 250])) assert_array_equal(outer_pix_r, np.array([250, 1749]))
def test_remove_antenna(fake_butterfly): middle = tracing.split_picture(fake_butterfly) binary_left = fake_butterfly[:, :middle] binary_right = fake_butterfly[:, middle:] # Adding antennae binary_left[260, 500:800] = 1 binary_right[260, 201:501] = 1 without_antenna_l = tracing.remove_antenna(binary_left) without_antenna_r = tracing.remove_antenna(binary_right) assert np.sum(without_antenna_l[260, 500:800]) == 0 assert np.sum(without_antenna_r[260, 201:501]) == 0
def test_inner_pix(fake_butterfly): middle = tracing.split_picture(fake_butterfly) binary_left = fake_butterfly[:, :middle] binary_right = fake_butterfly[:, middle:] # Relative outer pixels outer_pix_l = np.array([250, 250]) outer_pix_r = np.array([250, 750]) inner_pix_l = tracing.detect_inner_pix(binary_left, outer_pix_l, 'l') inner_pix_l = inner_pix_l + np.array([0, outer_pix_l[1]]) inner_pix_r = tracing.detect_inner_pix(binary_right, outer_pix_r, 'r') inner_pix_r = inner_pix_r + np.array([0, middle]) assert_array_equal(inner_pix_l, np.array([499, 799])) assert_array_equal(inner_pix_r, np.array([499, 1200]))
def test_detect_points_interest(fake_butterfly): middle = tracing.split_picture(fake_butterfly) fake_butterfly[:, middle] = 0 labels, _ = ndi.label(fake_butterfly, structure=ndi.generate_binary_structure(2, 2)) regions = regionprops(labels) boundary_l = tracing.boundary_tracing(regions[0]) boundary_r = tracing.boundary_tracing(regions[1]) test_poi_l = np.array([[25, 25], [49, 80]]) test_poi_r = np.array([[25, 174], [49, 119]]) poi_l = tracing.detect_points_interest(boundary_l, 'l', 200) poi_r = tracing.detect_points_interest(boundary_r, 'r', 200) assert np.all(poi_r[0] == test_poi_r[0]) assert np.all(poi_l[0] == test_poi_l[0]) assert np.all(poi_r[1] == test_poi_r[1]) assert np.all(poi_l[1] == test_poi_l[1])
def test_split(fake_butterfly): middle = tracing.split_picture(fake_butterfly) assert middle == 999
def test_split(fake_butterfly): assert tracing.split_picture(fake_butterfly) in [99, 100]