在运行了以下程序后不显示图像:
train_set_x_orig, train_set_y, test_set_x_orig, test_set_y, classes = load_dataset()
index = 25
plt.imshow(train_set_x_orig[index])
解决办法:
在后面加上plt.show()就会显示图像了 ,plt.imshow()函数对图像进行处理,并显示其格式。plt.show()则是显示plt.imshow()处理后的函数。
train_set_x_orig, train_set_y, test_set_x_orig, test_set_y, classes = load_dataset()
index = 25
plt.imshow(train_set_x_orig[index])
plt.show()
代码运行结果:
解决图像不显示:plt.imshow()与plt.show()的使用
本文介绍了在Python中使用matplotlib库时遇到图像不显示的问题,通过在`plt.imshow()`后添加`plt.show()`解决方法,并强调了这两个函数在图像处理中的作用。
491

被折叠的 条评论
为什么被折叠?



