gpt4 book ai didi

python - 重新排序 numpy 数组索引

转载 作者:太空宇宙 更新时间:2023-11-03 17:21:37 25 4
gpt4 key购买 nike

我有一个二维数组,我想从中创建图像。我想通过将同一数组堆叠 3 次,将尺寸为 140x120 的 image 数组转换为 140x120x3 的数组(以获得与 skimage 一起使用的灰度图像)。

我尝试了以下方法:

image = np.uint8([image, image, image])

这会产生 3x120x140 的图像。如何重新排序数组以获得 120x140x3?

最佳答案

np.dstack([image, image, image]) ( docs ) 将返回所需形状的数组,但这是否具有适合您的应用程序的正确语义取决于您的图像生成库。

关于python - 重新排序 numpy 数组索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33087678/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com