-
Notifications
You must be signed in to change notification settings - Fork 0
/
image.py
48 lines (39 loc) · 1.18 KB
/
image.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
import numpy as np
import matplotlib.pyplot as plt
import imageio
# 3d files
filenames = []
for i in range(0,90,10):
outputdir = "output/"
imagedir = "images/"
file = "heat_output_3d_"+str(i)
mat_1d = np.fromfile(outputdir+file+".bin", np.float_, -1, "")
dim_size = int(np.cbrt(mat_1d.size))
print (dim_size)
mat_3d = np.reshape(mat_1d, (dim_size, dim_size, dim_size))
slice_2d = mat_3d[1]#mat_3d[int(dim_size/2)]
plt.matshow(slice_2d)
plt.savefig(imagedir+file+".png")
filenames.append(imagedir+file+".png")
images = []
for filename in filenames:
images.append(imageio.imread(filename))
imageio.mimsave('heat.gif', images)
#2d files
filenames = []
for i in range(0,90, 10):
outputdir = "output/"
imagedir = "images/"
file = "heat_output_2d_"+str(i)
mat_1d = np.fromfile(outputdir+file+".bin", np.float_, -1, "")
dim_size = int(np.sqrt(mat_1d.size))
#print (dim_size)
mat_2d = np.reshape(mat_1d, (dim_size, dim_size))
#slice_2d = mat_3d[int(dim_size/2)]
plt.matshow(mat_2d)
plt.savefig(imagedir+file+".png")
filenames.append(imagedir+file+".png")
# images = []
# for filename in filenames:
# images.append(imageio.imread(filename))
# imageio.mimsave('heat.gif', images)