读取图像首先要导入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