读取图像首先要导入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. React-Native基础_5.列表视图ListView

    列表视图ListView 用来显示垂直滚动列表,需要指定两个东西,1 数据的来源 dataSource,2 渲染列表的条目布局 rendRow 'use strict' import React, { ...

  2. 轻量级网络 - PVANet & SuffleNet

    一. PVANet 论文:PVANET: Deep but Lightweight Neural Networks for Real-time Object Detection    [点击下载] C ...

  3. [OpenCV笔记]0.OpenCV中显示多张图像

    摘要 本文主要介绍OpenCV中同时显示多张IplImage图像的方法(C++形式的多图显示需要修改,用vector<Mat>可能比较方便),有点类似MATLAB中的subplot,只是暂 ...

  4. PHP 关于empty和isset对于参数的判断结果

    <?php class test{} $a1 = null; $a2 = ""; //$a3 = $a4 = 0; $a5 = '0'; $a6 = false; $a7 = ...

  5. 写一个Python的windows服务

    1. 安装pywin32和pyinstaller pip install pywin32 pip install pyinstaller 2.写一个服务Demo # -*- coding: utf-8 ...

  6. linux自学(一)之vmware虚拟机安装

    之前有研究过linux,后来一段时间没有操作了,现在有点陌生,而且当初也没有记录学习内容.现在想从新开始包括虚拟机安装到部署Javaweb项目,把这之间所需要的全都记录下来,以便后边学习参考使用. 虚 ...

  7. test20190320

    全连 \(n\leq 10^6\) ,保证答案在 \(long\ long​\) 范围内. 比较浅显的 \(dp\ ?\) 记 \(f[i]\) 表示考虑前 \(i\) 个音符,其中第 \(i\) 个 ...

  8. Luogu 1452 Beauty Contest

    Luogu 1452 Beauty Contest 求平面最远点对,先求出凸包,再找凸包的直径. 使用旋转卡壳,直径一定出现在对踵点对间.比较不同点到同一直线距离可以用叉积算三角形面积来比较. 实现时 ...

  9. 获取web.config 内的值

    获取 System.Configuration.ConfigurationManager.AppSettings[DrugPackageRegistrationName]//获取web.config ...

  10. LOJ#3054. 「HNOI 2019」鱼

    LOJ#3054. 「HNOI 2019」鱼 https://loj.ac/problem/3054 题意 平面上有n个点,问能组成几个六个点的鱼.(n<=1000) 分析 鱼题,劲啊. 容易想 ...