将 ndarray 对象转换为图像

convert ndarray object to Image

我有一张灰度图 type uint16, size = (256,256) ndarray object

我想使用 PIL 将其调整为 (75,75),但它要求输入为图像类型。

如何将 image of ndarray object 转换为 Image 类型以使用 image.resize((75,75), Image.ANTIALIAS)

注意: 我知道我可以 read 使用 Image.open 保存图像,但是我的 image is obtained after some image processing steps and is not read from disk

更新: 我正在尝试提供我拥有的图像:

import scipy.misc
scipy.misc.imsave('image.png', box_img)

# read this similar format image of type ndarray    
image = scipy.ndimage.imread('image.png')
# convert it to Image type

阅读时附上的image是我需要的类似类型。 我需要将此 image 转换为 Image 类型

谢谢,

果皮

from PIL import Image
import numpy as np

# An array of ones for example
img_array = np.ones((256,256), dtype='uint16')
img = Image.fromarray(img_array)
img = img.resize((75,75))