图像
1.OpenCV读取图像的格式是BGR
2.shape属性
# 返回一个[h,w,c]元组,即height,width,通道数
img_shape = img.shape
img_shape1 = img_shape[0]
img_shape2 = img_shape[1]
img_shape3 = img_shape[2]
3.彩色图像与灰度图像
# cv2.IMREAD_COLOR; 彩色图像
# cv2.IMREAD_GRAYSCALE; 灰度图像
img = cv2.imread(path,cv2.IMREAD_GRAYSCALE)
4.图像截取
dog = img[0:300,50:300]
5.图像RGB通道数的改变
# R,G,B的索引为0,1,2
# 将B通道置为0,剩R,G通道
img[:,:,0] = 0
# 只保留G通道
img[:,:,0] = 0
img[:,:,2] = 0