imshow()函数不工作

2024-09-25 00:36:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在用python编写一个程序,包有numpy、scipy和matplotlib.pyplot。这是我的代码:

import matplotlib.pyplot as plt
from scipy import misc
im=misc.imread("photosAfterAverage/exampleAfterAverage1.jpg")
plt.imshow(im, cmap=plt.cm.gray)

由于某种原因,图像没有显示出来(如果我得到了图像,检查一下,在那部分一切都很好-我可以打印数组)。


Tags: 代码from图像import程序numpymatplotlibas
2条回答

“交互模式也可以通过matplotlib.pyplot.ion()打开,通过matplotlib.pyplot.ioff()cf. matplotlib user guide关闭。

您需要调用plt.show()来显示图像。或者使用ipython --pylab作为可识别matplotlib的交互式shell。

相关问题 更多 >