我有一个值范围从0-255
的 numpy
数组。 我想将其转换为3通道RGB图像。 我使用PIL Image.convert()
函数,但它将其转换为灰度图像。
我正在使用Python的PIL
库将numpy
数组转换为图像,代码如下:
imge_out = Image.fromarray(img_as_np.astype('uint8'))
img_as_img = imge_out.convert("RGB")
输出将图像转换为3个通道,但以黑白(灰度)图像显示。如果我使用以下代码:
img_as_img = imge_out.convert("R")
它显示。
error conversion from L to R not supported
我该如何正确地将numpy数组转换成RGB图片?