2024-05-15 21:18:45 发布
网友
我有一个折叠的图像列表,是从视频剪辑中提取的帧。我想知道我怎样才能像剪辑一样顺序播放图像序列。(嗯,FPS不重要。) 在Python上检查PIL模块和skimage模块,除非我将JPG序列转换为GIF格式,否则我无法在Python上执行此操作。在
PIL
skimage
JPG
GIF
一种方法是使用matplotlib库的动画功能。以下是从online documentation复制/粘贴的示例:
#!/usr/bin/env python """ An animated image """ import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation def f(x, y): return np.sin(x) + np.cos(y) x = np.linspace(0, 2 * np.pi, 120) y = np.linspace(0, 2 * np.pi, 100).reshape(-1, 1) fig = plt.figure() im = plt.imshow(f(x, y)) def updatefig(*args): global x,y x += np.pi / 15. y += np.pi / 20. im.set_array(f(x,y)) return im, ani = animation.FuncAnimation(fig, updatefig, interval=50, blit=True) plt.show()
以下几点需要注意:
im.set_array
updatefig
一种方法是使用matplotlib库的动画功能。以下是从online documentation复制/粘贴的示例:
以下几点需要注意:
im.set_array
(在updatefig
函数中)加载下一个图像相关问题 更多 >
编程相关推荐