def test_sgm_middle_value_invalid(self): """ " Test SGM middle value invalid """ p1 = 8 p2 = 32 cv_in = np.array( [ [[1, 15, 20], [14, 16, 6], [8, 19, 8]], [[13, 11, 3], [np.nan, np.nan, np.nan], [16, 4, 12]], [[18, 2, 17], [23, 7, 1], [5, 20, 14]], ] ) p1_in = p1 * np.ones((3, 3, 8)) p2_in = p2 * np.ones((3, 3, 8)) directions = [[0, 1], [1, 0], [1, 1], [1, -1], [0, -1], [-1, 0], [-1, -1], [-1, 1]] segmentation = np.ones((3, 3)) cv_out = sgm.run_sgm_parall(cv_in, p1_in, p2_in, directions, segmentation, cost_paths=False, overcounting=False) # invalid value : nan self.assertTrue(np.isnan(cv_out["cv"][1, 1, 1]))
def test_sgm_middle_value_lr_0_1(self): """ " Test SGM middle value directions 0 1 """ p1 = 8 p2 = 32 cv_in = common.cv_in p1_in = p1 * np.ones((3, 3, 8)) p2_in = p2 * np.ones((3, 3, 8)) directions = [[0, 1]] segmentation = np.ones((3, 3)) cv_out = sgm.run_sgm_parall(cv_in, p1_in, p2_in, directions, segmentation, cost_paths=False, overcounting=False) # invalid value : nan self.assertEqual(cv_out["cv"][1, 1, 1], 20)
def test_sgm_middle_value_invalid_overcounting(self): """ " Test SGM middle value invalid overcounting """ p1 = 8 p2 = 32 cv_in = common.cv_in_nans p1_in = p1 * np.ones((3, 3, 8)) p2_in = p2 * np.ones((3, 3, 8)) directions = [[0, 1], [1, 0], [1, 1], [1, -1], [0, -1], [-1, 0], [-1, -1], [-1, 1]] segmentation = np.ones((3, 3)) cv_out = sgm.run_sgm_parall(cv_in, p1_in, p2_in, directions, segmentation, cost_paths=False, overcounting=True) # invalid value : nan self.assertTrue(np.isnan(cv_out["cv"][1, 1, 1]))
def test_sgm_middle_value_min_cost(self): """ " Test SGM middle value minimum cost """ p1 = 8 p2 = 32 cv_in = common.cv_in p1_in = p1 * np.ones((3, 3, 8)) p2_in = p2 * np.ones((3, 3, 8)) directions = [[0, 1], [1, 0], [1, 1], [1, -1], [0, -1], [-1, 0], [-1, -1], [-1, 1]] segmentation = np.ones((3, 3)) cv_out = sgm.run_sgm_parall(cv_in, p1_in, p2_in, directions, segmentation, cost_paths=True, overcounting=False) # invalid value : nan self.assertEqual(cv_out["cv"][1, 1, 1], 142) self.assertEqual(cv_out["cv_min"][1, 1, 1], 2)