Ejemplo n.º 1
0
    def test_double_conversions(self):
        output = efr.fit_improved_B2AC(self.points.copy())
        general_1 = c2gconv.conic_to_general_1(output.copy())
        general_2 = c2gconv.conic_to_general_2(output.copy())
        general_3 = c2gconv.conic_to_general_reference(output.copy())
        e_1 = B2ACEllipse(*general_1)
        e_2 = B2ACEllipse(*general_2)
        e_3 = B2ACEllipse(*general_3)

        # Test correct center point.
        assert np.linalg.norm(self.e.center_point - e_1.center_point) < 1
        # assert np.linalg.norm(self.e.center_point - e_2.center_point) < 1
        assert np.linalg.norm(self.e.center_point - e_3.center_point) < 1

        # Test correct radii.
        assert np.linalg.norm(max(self.e.radii) - max(e_1.radii)) < 0.25
        assert np.linalg.norm(min(self.e.radii) - min(e_1.radii)) < 0.25
        # assert np.linalg.norm(max(self.e.radii) - max(e_2.radii)) < 0.25
        # assert np.linalg.norm(min(self.e.radii) - min(e_2.radii)) < 0.25
        assert np.linalg.norm(max(self.e.radii) - max(e_3.radii)) < 0.25
        assert np.linalg.norm(min(self.e.radii) - min(e_3.radii)) < 0.25

        # Test overlap
        assert overlap(self.e, e_1) > 0.98
        assert overlap(e_1, self.e) > 0.98
        # assert overlap(self.e, e_2) > 0.98
        # assert overlap(e_2, self.e) > 0.98
        assert overlap(self.e, e_3) > 0.98
        assert overlap(e_3, self.e) > 0.98
Ejemplo n.º 2
0
 def test_py_and_ext_similarity(self):
     output = fitext.fit_ellipse_int(self.points.copy())
     e_ext = B2ACEllipse(*output)
     points, x_mean, y_mean = remove_mean_values(self.points.copy())
     output = fit_improved_B2AC_int(points)
     ellipse_data = c2gconv.conic_to_general_int(output, return_float=True, verbose=True)
     e_py = B2ACEllipse(*ellipse_data)
     e_py.center_point += (x_mean, y_mean)
     assert overlap(e_ext, e_py) > 0.99
     assert overlap(e_py, e_ext) > 0.99
Ejemplo n.º 3
0
 def test_fit_ext_float_version(self):
     output = fitext.fit_ellipse_float(self.points.copy())
     e_fitted = B2ACEllipse(*output)
     assert np.linalg.norm(self.e.center_point - e_fitted.center_point) < 1
     assert np.linalg.norm(max(self.e.radii) - max(e_fitted.radii)) < 0.25
     assert np.linalg.norm(min(self.e.radii) - min(e_fitted.radii)) < 0.25
     assert overlap(self.e, e_fitted) > 0.98
     assert overlap(e_fitted, self.e) > 0.98
Ejemplo n.º 4
0
 def test_fit_double_version(self):
     output = fit_improved_B2AC_double(self.points.copy())
     output = c2gconv.conic_to_general_1(output)
     e_fitted = B2ACEllipse(*output)
     assert np.linalg.norm(self.e.center_point - e_fitted.center_point) < 1
     assert np.linalg.norm(max(self.e.radii) - max(e_fitted.radii)) < 0.25
     assert np.linalg.norm(min(self.e.radii) - min(e_fitted.radii)) < 0.25
     assert overlap(self.e, e_fitted) > 0.98
     assert overlap(e_fitted, self.e) > 0.98
Ejemplo n.º 5
0
 def test_fit_int_version_1(self):
     output = fit_improved_B2AC_int(self.points.copy())
     ellipse_data = c2gconv.conic_to_general_int(output, return_float=True, verbose=True)
     e_fitted = B2ACEllipse(*ellipse_data)
     assert np.linalg.norm(self.e.center_point - e_fitted.center_point) < 1
     assert np.linalg.norm(max(self.e.radii) - max(e_fitted.radii)) < 1
     assert np.linalg.norm(min(self.e.radii) - min(e_fitted.radii)) < 1
     assert overlap(self.e, e_fitted) > 0.95
     assert overlap(e_fitted, self.e) > 0.95
Ejemplo n.º 6
0
 def test_fit_ref(self):
     points = self.points.copy()
     output = efr.fit_improved_B2AC(points)
     general_form = c2gconv.conic_to_general_1(output)
     e_fitted = B2ACEllipse(*general_form)
     assert np.linalg.norm(self.e.center_point - e_fitted.center_point) < 1
     assert np.linalg.norm(max(self.e.radii) - max(e_fitted.radii)) < 0.25
     assert np.linalg.norm(min(self.e.radii) - min(e_fitted.radii)) < 0.25
     assert overlap(self.e, e_fitted) > 0.98
     assert overlap(e_fitted, self.e) > 0.98
Ejemplo n.º 7
0
 def test_fit_int_version_2(self):
     points, x_mean, y_mean = remove_mean_values(self.points.copy())
     output = fit_improved_B2AC_int(points)
     ellipse_data = c2gconv.conic_to_general_int(output, return_float=True, verbose=True)
     e_fitted = B2ACEllipse(*ellipse_data)
     e_fitted.center_point += (x_mean, y_mean)
     print(e_fitted)
     assert np.linalg.norm(self.e.center_point - e_fitted.center_point) < 1.0
     assert np.linalg.norm(max(self.e.radii) - max(e_fitted.radii)) < 0.1
     assert np.linalg.norm(min(self.e.radii) - min(e_fitted.radii)) < 0.1
     assert overlap(self.e, e_fitted) > 0.98
     assert overlap(e_fitted, self.e) > 0.98
Ejemplo n.º 8
0
 def setup(self):
     self.e = B2ACEllipse(center=(50.0, 75.0),
                          radii=(50.0, 20.0),
                          rotation_angle=0.707)
     self.points = np.array(self.e.polygonize(), 'int32')