我有一个形状为(3, 256, 256)
的numpy数组,它是一个分辨率为256x256的三通道(RGB)图像。 我正在尝试通过以下方式使用PIL
中的Image
将其保存到磁盘:
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)
吗? - cel