【发布时间】:2011-04-18 22:25:43
【问题描述】:
我正在尝试使用 matplotlib.pyplot.imshow() 显示灰度图像。我的问题是灰度图像显示为颜色图。我需要灰度,因为我想在图像上绘制颜色。
我读入图像并使用 PIL 的 Image.open().convert("L") 转换为灰度
image = Image.open(file).convert("L")
然后我将图像转换为矩阵,以便我可以轻松地使用
进行一些图像处理matrix = scipy.misc.fromimage(image, 0)
但是,当我这样做时
figure()
matplotlib.pyplot.imshow(matrix)
show()
它使用颜色图显示图像(即它不是灰度图)。
我在这里做错了什么?
【问题讨论】:
标签: python matplotlib grayscale