【发布时间】:2021-11-29 01:15:37
【问题描述】:
为什么这段代码会绘制不同的图像?
from PIL import Image
import numpy as np
x = (np.random.random((32,32))*255).astype(np.int16)
img1 = Image.fromarray(x, mode='L')
img2 = Image.fromarray(x)
plt.imshow(img1, cmap='gray')
plt.imshow(img2, cmap='gray')
看图片:
【问题讨论】:
-
查看 PIL 图像模式 here。
-
L = 8位像素,黑白..所有值都是0-255..为什么图像不一样?
标签: python image numpy python-imaging-library