def save_frames(images, filename):
num_sequences, n_steps, w, h = images.shape
fig = plt.figure()
im = plt.imshow(combine_multiple_img(images[:, 0]), cmap=plt.cm.get_cmap('Greys'), interpolation='none')
plt.axis('image')
def updatefig(*args):
im.set_array(combine_multiple_img(images[:, args[0]]))
return im,
ani = animation.FuncAnimation(fig, updatefig, interval=500, frames=n_steps)
# Either avconv or ffmpeg need to be installed in the system to produce the videos!
try:
writer = animation.writers['avconv']
except KeyError:
writer = animation.writers['ffmpeg']
writer = writer(fps=3)
ani.save(filename, writer=writer)
plt.close(fig)
评论列表
文章目录