读取图像首先要导入OpenCV包

import cv2

OpenCV目前支持读取bmp、jpg、png、tiff等常用格式。

//读取图片

img2 = cv2.imread('out-0022.jpg')

//显示图片

//创建窗口,窗口显示图片

cv2.namedWindow("Image")

cv2.imshow("Image", img2)

//保持图像显示

cv2.waitKey (0)

//复制图片

//要import numpy as np

img3= img2.copy()

//保存图像

cv2.imwrite("./result.jpg", img3)

//分离通道

b, g, r = cv2.split(img)

cv2.imshow("Blue", r)

cv2.imshow("Red", g)

cv2.imshow("Green", b)

b = cv2.split(img)[0]

g = cv2.split(img)[1]

r = cv2.split(img)[2]

b = np.zeros((img.shape[0],img.shape[1]), dtype=img.dtype)

g = np.zeros((img.shape[0],img.shape[1]), dtype=img.dtype)

r = np.zeros((img.shape[0],img.shape[1]), dtype=img.dtype)

b[:,:] = img[:,:,0]

g[:,:] = img[:,:,1]

r[:,:] = img[:,:,2]

//合并通道

merged = cv2.merge([b,g,r])

mergedByNp = np.dstack([b,g,r])

参考的文章及感觉不错的文章

http://blog.csdn.net/sunny2038/article/details/9080047

http://python.jobbole.com/85178/

计算机视觉编程http://yongyuan.name/pcvwithpython/chapter10.html

绘图操作 http://blog.csdn.net/thefutureisour/article/details/7523925

OpenCV for Python常用命令的更多相关文章

  1. python常用命令和基础运算符

    基础运算符 http://www.cnblogs.com/alex3714/articles/5465198.html 身份运算符:is is not成员运算符:in not in ##in 判断元素 ...

  2. Python 常用命令

    对Python进行软件的安装.卸载和查看,是我们在日常工作中经常要做的事情,有的时候会突然忘记常用的命令,所以在此记录下来: pip 安装软件包 pip install xxx 卸载软件包 pip u ...

  3. Linux(Ubuntu) 和 Python 常用命令

    Linux: pwd: check current directory touch f1 f2 f3: create three empty files tree dir/: show the lev ...

  4. python常用命令(持续) | Commonly used Python command list (con't)

    ---------------------------------------------------------------------------------------------------- ...

  5. python常用命令—‘\r’

    # \r 默认表示将输出的内容返回到第一个指针,这样的话,后面的内容会覆盖前面的内容 如常用的显示程序完成进度!!

  6. python常用命令—windows终端查看安装包信息

    1, pip list 会将 Python 的所有安装包全部显示出来, 左边是包名, 右边是包的版本号. 2, pip show 包的名字 会将这个包的名字,版本号,包的功能说明,按装这个包的路径显示 ...

  7. deepfake安装python常用命令

    pip install -r requirements.txt -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/ python -m p ...

  8. python 常用命令sys.exit()

    Python的程序有两中退出方式:os._exit(), sys.exit() os._exit()会直接将python程序终止,之后的所有代码都不会继续执行. sys.exit()会引发一个异常:S ...

  9. deeplearning.ai 作业中的Python常用命令

    1. print大法 test = Hello World print ("test:" + test) 2. math和numpy的区别:math只对单个元素,numpy会bro ...

随机推荐

  1. PHP中MySQL、MySQLi和PDO的用法和区别【原创】

    对于一个初学PHP的自己,对数据库的连接有着很大的疑惑,从Java转到PHP.数据库连接变了,以前只知道JDBC连接数据库,或者直接用框架调用,对于的PHP的数据库连接方式,及其应用.不是很了解,于是 ...

  2. wxWidgets的配置

    参考 :http://www.codeproject.com/Articles/11515/Introduction-to-wxWidgets 我是将D:\wxWidgets-3.0.1,中 编译过  ...

  3. gradle Could not create service of type CrossBuildFileHashCache using BuildSessionScopeServices.crea

    gradle Could not create service of type CrossBuildFileHashCache using BuildSessionScopeServices.crea ...

  4. SpringMVC札集(05)——SpringMVC参数回显

    自定义View系列教程00–推翻自己和过往,重学自定义View 自定义View系列教程01–常用工具介绍 自定义View系列教程02–onMeasure源码详尽分析 自定义View系列教程03–onL ...

  5. Ubuntu下改变文件权限

    Ubuntu下改变权限 有问题,待解决!! 参考:修改linux文件权限命令:chmod 起因:init 0 指令能在普通用户下调用,很方! 指令 chmod 格式: chmod 000 xxx.x ...

  6. win8 ie10 debug flex

    win8 ie10 使用flash debug方法: 删除c:\WINDOWS\system32\Macromed\Flash.c:\WINDOWS\SysWOW64\Macromed\Flash里面 ...

  7. phpcms v9取消验证码

    phpcms/modules/admin/index.php// $code = isset($_POST['code']) && trim($_POST['code']) ? tri ...

  8. 【test】

    {"type":[    {"name":"专题分类","num":1,"value":[      ...

  9. Mac安装最新tensorflow遇到的坑,记录下方便后人

    之前其他mac电脑安装tensorflow时候一切顺利,一行命令sudo pip install tensorflow就高搞定了,但是今天在新mac上安装tensorflow时候出现了一个bug,搞了 ...

  10. NGUI动态给EventDelegate加参数

    示例代码如下: 响应的函数声明为: void OnChange(UIToggle toggle) { if(toggle.value) { // do something } }   添加响应的代码如 ...