【发布时间】:2015-02-20 10:21:12
【问题描述】:
我有一个形状为(3, 256, 256) 的 numpy 数组,它是分辨率为 256x256 的 3 通道 (RGB) 图像。我正在尝试通过执行以下操作将 Image 从PIL 保存到磁盘:
from PIL import Image
import numpy as np
#... get array s.t. arr.shape = (3,256, 256)
img = Image.fromarray(arr, 'RGB')
img.save('out.png')
但是,这是将尺寸为 256x3 的图像保存到磁盘
【问题讨论】:
-
您是否尝试过使用
np.swapaxes重塑为(256,256,3)数组?
标签: python numpy python-imaging-library