python - 将 Numpy 矩阵显示为视频

标签 python numpy

我有一个 numpy 矩阵,其中每一行都是一张图片。我可以使用 matplotlib.pyplot reshape 行并显示图像。问题是:我不想单独显示图像,我想像视频一样依次显示它们。

这在 python 中怎么可能?

最佳答案

好吧,我不知道这是否是最好的方法,但我已经使用 matplotlib.pyplot 来解决我的问题。将其导入为“plt”并执行以下操作:

matrix=numpy.genfromtxt(path,delimiter=',') # Read the numpy matrix with images in the rows
c=matrix[0]
c=c.reshape(120, 165) # this is the size of my pictures
im=plt.imshow(c)
for row in matrix:
    row=row.reshape(120, 165) # this is the size of my pictures
    im.set_data(row)
    plt.pause(0.02)
plt.show()

关于python - 将 Numpy 矩阵显示为视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17541449/

相关文章:

python - SQLAlchemy 中的外键约束

python - numpy.random.multinomial 错误输出?

python - 使用 matplotlib 创建条形图,其中 x 轴为日期,宽度为时间增量

python - 如何修改numpy数组的排序结果

python - 如果两个值相同,则在 Python 中从嵌套字典中删除重复条目

Python:为什么我不能在类里面使用 `super`?

python - 创建临时 keras session ?

python - 使用 Python setuptools 将 Cython 编译的 pyd 文件放入其原始文件夹中?

python - Python Quiver 图疑难解答

python - 删除每个值都被屏蔽的列