-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
47 lines (40 loc) · 1.06 KB
/
main.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
import sys,os
from PIL import Image
from scipy.spatial import Delaunay
from balloon import get_contours
### CONSTANTES ###
niterations = 1000
npoints = 50
initial_guess_radius = 20
dh = 1
##################
def main(fichier_in):
os.chdir(fichier_in)
hauteur = 0
points = []
for img in os.listdir():
try:
contour = get_contours(
Image.open(img),
niterations,
npoints,
initial_guess_radius,
)
points += [(x,y,hauteur) for (x,y) in contour]
except:
pass
hauteur += dh
tri = Delaunay(points)
os.chdir("..")
save(tri, points)
def save(tri, points):
with open("out.tri","w") as out:
for tetra in tri.simplicies:
for triangle in tetra:
for pt in triangle:
out.write(str(points[pt]) + " ")
out.write("\n")
if __name__ == "__main__":
args = sys.argv
assert len(args) > 1, "Pas assez d'arguments, il doit y avoir 1 argument"
main(args[1])