博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
python图形库(1)
阅读量:4577 次
发布时间:2019-06-08

本文共 2672 字,大约阅读时间需要 8 分钟。

python有很好图形库cv2(包含很多图形处理的算法),pylab(绘图工具模块)

这两个“模块”是肯定要配置的。

 

安装这两个模块可用了我不少时间。

pylab它不是一个包,而是 numpy, scipy 和 matplotlab 的合体,要安装这3个部分。

numpy:
matplotlab
scipy
 
然后检测一下:
1 import pylab as pl2 listOfInt = []3 for c in range(10):4     listOfInt.append(c*2)5 6 print listOfInt7 8 pl.plot(listOfInt)9 pl.show()

出现效果:就成功了pylab模块的安装.

 

然后就是cv2了,找了好多资料,python库那里面下载东西,目录结构刚开始没搞清楚,不知道粘贴哪个。

这篇文章有很详细的讲解。说的比较多。只要看一部分就ok了

opencv2.4.12 下载地址。

点击下载的opencv-2.4.12.exe,一路next下去,例如本人安装到E盘根目录下。安装完成后,将E:\opencv2_4_12\build\python\2.7\x64下的cv2.pyd拷贝到你的Lib文件夹下就可以了。

然后测试一下

1 import cv2 2 import numpy as np 3  4 img = cv2.imread("1.jpg") 5 emptyImage = np.zeros(img.shape, np.uint8) 6  7 emptyImage2 = img.copy() 8  9 emptyImage3=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)10 11 cv2.imshow("EmptyImage3", emptyImage3)12 cv2.waitKey (0)13 cv2.destroyAllWindows()

显示效果即可:

 

 注意:scipy

里面是没有64位操作系统的exe文件的,解决方案有很多,但是有效的不多,改注册表麻烦。

写一个register.py的脚本,我试了一下是没有用的。可以去尝试一下。

1 # 2 # script to register Python 2.0 or later for use with win32all 3 # and other extensions that require Python registry settings 4 # 5 # written by Joakim Loew for Secret Labs AB / PythonWare 6 # 7 # source: 8 # http://www.pythonware.com/products/works/articles/regpy20.htm 9 #10 # modified by Valentine Gogichashvili as described in http://www.mail-archive.com/distutils-sig@python.org/msg10512.html11  12 import sys13  14 from _winreg import *15  16 # tweak as necessary17 version = sys.version[:3]18 installpath = sys.prefix19  20 regpath = "SOFTWARE\\Python\\Pythoncore\\%s\\" % (version)21 installkey = "InstallPath"22 pythonkey = "PythonPath"23 pythonpath = "%s;%s\\Lib\\;%s\\DLLs\\" % (24     installpath, installpath, installpath25 )26  27 def RegisterPy():28     try:29         reg = OpenKey(HKEY_CURRENT_USER, regpath)30     except EnvironmentError as e:31         try:32             reg = CreateKey(HKEY_CURRENT_USER, regpath)33             SetValue(reg, installkey, REG_SZ, installpath)34             SetValue(reg, pythonkey, REG_SZ, pythonpath)35             CloseKey(reg)36         except:37             print "*** Unable to register!"38             return39         print "--- Python", version, "is now registered!"40         return41     if (QueryValue(reg, installkey) == installpath and42         QueryValue(reg, pythonkey) == pythonpath):43         CloseKey(reg)44         print "=== Python", version, "is already registered!"45         return46     CloseKey(reg)47     print "*** Unable to register!"48     print "*** You probably have another Python installation!"49  50 if __name__ == "__main__":51     RegisterPy()
View Code

 

 

大致意思说的是scipy需要numpy不是上面的那种,而是numpy+mkl

转载于:https://www.cnblogs.com/TreeDream/p/6493272.html

你可能感兴趣的文章
python入门(3)python的解释器
查看>>
maven入门(1-3)构建简单的maven项目
查看>>
git 清除本地无效的分支
查看>>
poj1001--Exponentiation
查看>>
Python基础(迭代)
查看>>
webpack -p无效解决方式
查看>>
使用 PHP 获得网页内容 GET方式
查看>>
TJU Problem 2857 Digit Sorting
查看>>
C# 修饰符
查看>>
Centos以rpm方式进行安装MySql
查看>>
supervisor
查看>>
洛谷P1081 开车旅行70分
查看>>
Linux中用户及用户组
查看>>
python常用sql语句
查看>>
退休惠普九大感言——根源(虽然不是孙振耀写的,但正如孙振耀本人所说:写这篇文章的人对大家的影响、启发,内容比谁来写更有意义)...
查看>>
IE 下a标签在 position:absolute 后无法点击的问题
查看>>
jquery 正则表达式
查看>>
mysql查询更新时的锁表机制分析(只介绍了MYISAM)
查看>>
JDBC如何调用存储过程
查看>>
扫盲记-第五篇--图像全景分割
查看>>