Ipython笔记本(jupyter),opencv(cv2)和密谋? [英] Ipython notebook (jupyter),opencv (cv2) and plotting?

查看:434
本文介绍了Ipython笔记本(jupyter),opencv(cv2)和密谋?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用opencv2和ipython笔记本进行绘图?

我对python图像分析相当新。我决定使用笔记本工作流程来制作漂亮的记录,因为我处理它并且使用matplotlib / pylab绘制的东西很好。

I am fairly new to python image analysis. I decided to go with the notebook work flow to make nice record as I process and it has been working out quite well using matplotlib/pylab to plot things.

最初的障碍我曾经是如何在笔记本中绘制内容的。简单,只需使用魔法:

An initial hurdle I had was how to plot things within the notebook. Easy, just use magic:

%matplotlib inline

后来,我想用交互式绘图进行操作,但在专用窗口中绘图总是会冻结。好吧,我再次了解到你需要使用魔法。而不是仅导入模块:

Later, I wanted to perform manipulations with interactive plots but plotting in a dedicated window would always freeze. Fine, I learnt again that you need to use magic. Instead of just importing the modules:

%pylab

现在我已经开始使用opencv了。我现在回到同样的问题,我要么根据手头的任务绘制内联或使用专用的交互式窗口。是否有类似的魔法使用?还有另一种让事情发挥作用的方法吗?或者我是否陷入困境并且需要回到IDLE运行程序?

Now I have moved onto working with opencv. I am now back to the same problem, where I either want to plot inline or use dedicated, interactive windows depending on the task at hand. Is there similar magic to use? Is there another way to get things working? Or am I stuck and need to just go back to running a program from IDLE?

作为旁注:我知道opencv已正确安装。首先,因为我没有安装或导入cv2模块的错误。其次,因为我可以用cv2读取图像,然后用其他东西绘制它们。

As a side note: I know that opencv has installed correctly. Firstly, because I got no errors either installing or importing the cv2 module. Secondly, because I can read in images with cv2 and then plot them with something else.

推荐答案

这是我的空模板:

import cv2
import matplotlib.pyplot as plt
import numpy as np
import sys
%matplotlib inline

im = cv2.imread('IMG_FILENAME',0)
h,w = im.shape[:2]
print(im.shape)
plt.imshow(im,cmap='gray')
plt.show()

这篇关于Ipython笔记本(jupyter),opencv(cv2)和密谋?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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