Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. def create_anim(img_arr):
  2. img = []
  3. for i in range(img_arr.shape[2]):
  4. im = plt.imshow(img_arr[:,:,i], animated=True, cmap='gray')
  5. img.append([im])
  6. return img
  7.  
  8.  
  9. img = create_anim(img_arr) # img_arr is 3d array containing all the frames
  10. fig = plt.figure()
  11. ani = animation.ArtistAnimation(fig, img, interval=50, blit=False,
  12. repeat_delay=None, repeat=False)
  13.  
  14. ani.save("movie.gif", fps=80, writer='imagemagick')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement