将3D阵列切成多个2D阵列 [英] Slice a 3D array in to multiple 2D arrays
本文介绍了将3D阵列切成多个2D阵列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个形状为(64,64,3)的numpy数组.我们如何获得每个维数为(64,64)的三个数组.
I have a numpy array of shape(64,64,3). How can we get three arrays of dimension (64,64) each.
推荐答案
您可以使用moveaxis
将要拆分的轴一直移动到最左侧,然后使用序列拆包:
You can use moveaxis
to move the to split axis all the way to the left and then use sequence unpacking:
x,y,z = np.moveaxis(arr, -1, 0)
这篇关于将3D阵列切成多个2D阵列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文