Esempio n. 1
0
    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(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)
Esempio n. 2
0
    def test_sgm_middle_value_reset_middle(self):
        """ "
        Test SGM middle value all directions with a reset in middle
        """
        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))
        segmentation[1, 1] = 2

        cv_out = sgm.run_sgm(cv_in,
                             p1_in,
                             p2_in,
                             directions,
                             segmentation,
                             cost_paths=False,
                             overcounting=False)

        # invalid value : nan
        self.assertEqual(cv_out["cv"][1, 1, 1], 96)
Esempio n. 3
0
    def test_sgm_middle_value_invalid(self):
        """ "
        Test SGM middle value invalid
        """
        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(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]))
Esempio n. 4
0
    def test_sgm_middle_value_lr_minus1_minus1(self):
        """ "
        Test SGM middle value directions -1 -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 = [[-1, -1]]

        segmentation = np.ones((3, 3))

        cv_out = sgm.run_sgm(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)