-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexemplary_image_generation.py
51 lines (40 loc) · 1.7 KB
/
exemplary_image_generation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import numpy as np
import matplotlib.pyplot as plt
from contour_eot.utility.visuals import plot_elliptic_state, prepare_styling
from contour_eot.utility.contour_sampling import get_deterministic_ellipse_contour_measurements
from contour_eot.utility.utils import scatter_matrix, matrix_to_params
def visualize_different_sampling_methods(target_file):
def save(f):
plt.axis('equal')
plt.axis('off')
plt.tight_layout()
if f is None:
plt.show()
else:
plt.savefig(f, bbox_inches='tight')
plt.close()
print(f"Saved to file f{f}")
kwargs = dict(
marker='o',
c='black'
)
n_pts = 50
plt.rcParams["figure.figsize"] = 8, 3
l1, l2 = 10, 2
s1 = np.array([0, 0, 0, l1, l2])
plot_elliptic_state(s1, fill=True, c='grey', alpha=.3)
z1 = get_deterministic_ellipse_contour_measurements(state=s1, number_of_points=n_pts, equidistant_on_contour=False)
plt.scatter(*z1.T, **kwargs)
plot_elliptic_state(np.asarray([*np.mean(z1, axis=0), *matrix_to_params(scatter_matrix(z1))]), c='C0')
save(target_file + "_angles")
# EQUIDISTANT
s2 = np.array([0, 0, 0, l1, l2])
plot_elliptic_state(s2, fill=True, c='grey', alpha=.3)
z2 = get_deterministic_ellipse_contour_measurements(state=s2, number_of_points=n_pts, equidistant_on_contour=True)
plt.scatter(*z2.T, **kwargs)
plot_elliptic_state(np.asarray([*np.mean(z2, axis=0), *matrix_to_params(scatter_matrix(z2))]), c='C0')
save(target_file + "_equidistant")
if __name__ == '__main__':
prepare_styling()
target_dir = "../../output/"
visualize_different_sampling_methods(target_file=f"{target_dir}sampling_examples")