使用imshow()时图像未显示在Google Colab中 [英] Image is not displaying in Google Colab while using imshow()

查看:910
本文介绍了使用imshow()时图像未显示在Google Colab中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个需要OpenCV中的功能来绘制图像的项目中. 我正在尝试使用Google Colab中的以下代码显示图像.但是输出中没有任何内容.有人可以帮我吗?

%pylab notebook
import cv2

testim = imread('butterfly.jpg')
figure()
imshow(testim)
plt.show()

屏幕截图:

链接到我的Colab笔记本

解决方案

找到了一种解决方法.我们可以在代码中使用%matplotlib inline来使用.在In [28]中用作示例-链接

I am working on a project which requires functions from OpenCV to plot images. I am trying to display image using the below code in Google Colab. But nothing shows up in the output. Can anybody help me with this?

%pylab notebook
import cv2

testim = imread('butterfly.jpg')
figure()
imshow(testim)
plt.show()

Screenshot:

Link to my Colab Notebook

解决方案

Found one workaround. We can use %matplotlib inline in the code to use . Used as example here in In[28] - link

这篇关于使用imshow()时图像未显示在Google Colab中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆