如何将形状为(band,row,column)的数组重新整形为(row,column,band)? [英] How do I re-shape an array with shape(band,row,column) to (row,column,band)?

查看:58
本文介绍了如何将形状为(band,row,column)的数组重新整形为(row,column,band)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个形状为(370,275,210)的NumPy数组,我想将其重塑为(275,210,370).我将如何在Python中实现这一目标? 370是带的数量,275是行的数量,而210是图像中包含的列的数量.

I have a NumPy array with shape(370,275,210) and I want to re-shape it to (275,210,370). How would I achieve this in Python? 370 is the number of bands,275 is the number of rows, and 210 is the number of columns contained in the image.

推荐答案

您可以使用 np.moveaxis()

>>> a = np.zeros((370, 275, 210))
>>> a.shape
(370, 275, 210)
>>> a = np.moveaxis(a, 0, 2)
>>> a.shape
(275, 210, 370)

这篇关于如何将形状为(band,row,column)的数组重新整形为(row,column,band)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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