我有一个表示360x640像素图像的RGB值的列表,该图像列表的格式为img_list[y_pix][x_pix][R,G,B]。因此,对于一个2x2像素,在左上角和右下角有白色像素,在反面有黑色像素,我的列表将是[[[255,255,255],[0,0,0]][[0,0,0],[255,255,255]]]。
我尝试将其作为数组传递给PIL
image_array = np.asarray(frame_array)
img = PIL.Image.fromarray(image_array)发布于 2019-08-30 23:06:36
您需要指定RGB数据类型,以便np.uint8理解每个值在RGB表示中都是一个字节。
import PIL
import numpy as np
l = [[[255, 255, 255], [0, 0, 0]], [[0, 0, 0], [255, 255, 255]]]
image_array = np.array(l, dtype=np.uint8)
img = PIL.Image.fromarray(image_array)
img.show()输出(放大):

https://stackoverflow.com/questions/57729087
复制相似问题