📜  从数组到图像显示 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:49.674000             🧑  作者: Mango

代码示例1
from PIL import Image
import numpy as np

w, h = 512, 512
data = np.zeros((h, w, 3), dtype=np.uint8)
data[0:256, 0:256] = [255, 0, 0] # red patch in upper left
img = Image.fromarray(data, 'RGB')
img.save('my.png')
img.show()