Python:将 3D 图像系列重塑为像素系列 [英] Python: Reshape 3D image series to pixel series

查看:26
本文介绍了Python:将 3D 图像系列重塑为像素系列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个形状为 (imageCount, width, height) 的 3D numpy 图像数组.

i have a 3D numpy array of images with the shape (imageCount, width, height).

我的目标是将其转换为形状为 (pixelPosition, imageCount) 的 2D 像素系列数组.

My goal is to transform this into a 2D pixel series array with the shape (pixelPosition, imageCount).

现在这是我的解决方案:

Right now this is my solution:

timeSeries= []

for h in range(height):
    for w in range(width):
        timeSeries.append(images[:,h,w])

是否有使用 numpy.reshape() 或类似方法的更简单的方法?

is there a simpler way with numpy.reshape() or something like this?

推荐答案

转置和重塑 -

images.transpose(1,2,0).reshape(height*width,-1)

这篇关于Python:将 3D 图像系列重塑为像素系列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆