コード例 #1
0
 def test_vertical_ellipse(self):
     x, y, a, b, r = 10, 20, 15, 10, math.pi / 2
     c = math.sqrt(a ** 2 - b ** 2)
     xf0, yf0 = ret._get_closest_focus(10, 30, x, y, a, b, r)
     assert (xf0, yf0) == (x, y + c)
     xf1, yf1 = ret._get_closest_focus(10, 10, x, y, a, b, r)
     assert (xf1, yf1) == (x, y - c)
コード例 #2
0
 def test_horizontal_ellipse(self):
     x, y, a, b, r = 10, 20, 20, 10, 0
     c = math.sqrt(a ** 2 - b ** 2)
     xf0, yf0 = ret._get_closest_focus(20, 20, x, y, a, b, r)
     assert (xf0, yf0) == (x + c, y)
     xf1, yf1 = ret._get_closest_focus(5, 20, x, y, a, b, r)
     assert (xf1, yf1) == (x - c, y)
コード例 #3
0
 def test_xy_use_focus_true(self):
     x0, y0, x1, y1 = 10, -5, -20, 30
     a, b, r = 10, 8, 0
     data0 = ret.make_ellipse_data_points(x0, y0, a, b, r, nt=99, use_focus=True)
     xc0, yc0 = data0.mean(axis=0)
     f0 = ret._get_closest_focus(x0, y0, xc0, yc0, a, b, r)
     assert approx(f0) == (x0, y0)
     data1 = ret.make_ellipse_data_points(x1, y1, a, b, r, nt=99, use_focus=True)
     xc1, yc1 = data1.mean(axis=0)
     f1 = ret._get_closest_focus(x1, y1, xc1, yc1, a, b, r)
     assert approx(f1) == (x1, y1)
コード例 #4
0
 def test_no_values_out_of_bounds(self):
     xf, yf, rf_lim = 100, 100, 20
     semi_len_min, semi_len_max = 50, 100
     semi_len_ratio_lim = 1.15
     peak_array = np.random.randint(0, 200, size=(10, 11, 200, 2))
     ellipse_array, inlier_array = ret.get_ellipse_model_ransac(
         peak_array,
         xf=xf,
         yf=yf,
         rf_lim=rf_lim,
         semi_len_min=semi_len_min,
         semi_len_max=semi_len_max,
         semi_len_ratio_lim=semi_len_ratio_lim,
         min_samples=15,
         max_trails=5,
     )
     for iy, ix in np.ndindex(peak_array.shape[:2]):
         if ellipse_array[iy, ix] is not None:
             xc, yc, semi0, semi1, r = ellipse_array[iy, ix]
             x, y = ret._get_closest_focus(xf, yf, xc, yc, semi0, semi1, r)
             rf = math.hypot(x - xf, y - yf)
             semi_ratio = max(semi0, semi1) / min(semi0, semi1)
             assert rf < rf_lim
             assert semi_ratio < semi_len_ratio_lim
             assert semi0 > semi_len_min
             assert semi1 > semi_len_min
             assert semi0 < semi_len_max
             assert semi1 < semi_len_max
コード例 #5
0
 def test_circle(self):
     xc, yc = 10, 20
     x, y, a, b, r = 10, 20, 10, 10, 0
     xf, yf = ret._get_closest_focus(xc, yc, x, y, a, b, r)
     assert (xf, yf) == (10, 20)