python - 在python中显示numpy的帧堆栈
问题描述
我有一个形状为 (1,64,96,4) 的 numpy 堆栈,其中 (64,96) 是对应于从屏幕(帧)捕获的图像的像素,4 是堆叠的帧数。所以基本上堆栈有4个二维数组(64,96)。该堆栈用作 Deep q 网络的输入。
我想用 matplotlib 显示不同的帧,但我没有设法访问正确的元素。
这是创建帧堆栈的代码:
frame = self.preprocess_frame(frame) # (64,96)
state = np.stack([frame] * 4, axis=-1)
state = state.reshape(1, state.shape[0], state.shape[1], state.shape[2]) # 1*64*96*4, the extra dimension is only used for Keras library
return state
问题是如何从堆栈中访问不同的帧,以便将它们送入matplotlib.imshow
我试过这个只得到一帧,但没有成功:
plt.imshow(state[1], state[2])
plt.show()
先感谢您 !!!
解决方案
推荐阅读
- python - 没有名为“ray.rllib.agents.ppo.ppo_policy”的模块
- javascript - 使用simple-git,只能得到一个提交工作
- python - 无法安装ggplot
- xlsb - 用于保存 Personal.xlsb 副本的宏
- html - 跨度标签在文本图像或文本组合中不起作用
- flutter - Flutter 从 Firebase 实时数据库中检索数据
- mysql - mysql:如何一次在两个表中放置两个唯一的列
- django - Django request.POST.items() 未按预期运行
- docker - docker pull 镜像策略/设置
- sql - 为什么并行运行一个简单的查询会使其更快?