-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvisualization.py
More file actions
36 lines (30 loc) · 853 Bytes
/
Copy pathvisualization.py
File metadata and controls
36 lines (30 loc) · 853 Bytes
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
import matplotlib.animation as animation
import os
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
import dateutil
IMAGE_PATH= './radarimages'
SEQUENCES= os.listdir(IMAGE_PATH)
print(SEQUENCES)
def frame():
global SEQUENCES, IMAGE_PATH
ind=-1
while True:
ind+=1
if ind>=len(SEQUENCES):
break
name= SEQUENCES[ind]
tif= np.array(Image.open(os.path.join(IMAGE_PATH,name)))
tif[tif<5]=0
time= dateutil.parser.parse(name.split('.')[0].split('_')[-1])
yield tif, time
def update(args):
img= args[0]
time= args[1]
ax.imshow(img)
ax.set_title(time.strftime('%Y-%m-%d %H:%M:%S'))
if __name__=='__main__':
fig, ax= plt.subplots(1,1,figsize=(10,8))
ani = animation.FuncAnimation(fig,update,frame, interval=0)
ani.save('demo.gif', writer='imagemagick', fps=1,bitrate=50)