#Day 1
#学习内容:图像读取,显示,删除,另存为,像素读取和修改,
import cv2
import numpy as np
image=cv2.imread("D:\OpenCV\CVproject\image/lenacolor.png")#图像读取
cv2.imshow("show",image)#图像显示

#ROI人脸提取
a=np.ones((100,100,3))
a=image[200:390,230:350]#lenacolor人脸位置
cv2.imshow("face1",a)
image[0:190,0:120]=a
cv2.imshow("face2",image)#一张图片突出人脸部分

#BGR三像素分离
b,g,r=cv2.split(image)#也可单个提取b=cv2.split(image)[0]
cv2.imshow("blue",b)

print(image.shape)#输出image的行,列,通道
rows,cols,chn=image.shape
g=np.zeros((rows,cols),image.dtype)#令g通道为0
r=np.zeros((rows,cols),image.dtype)
m=cv2.merge([b,g,r])
cv2.imshow("merge",m)

cv2.imwrite("D:\OpenCV\image/merge.jpg",m)#窗口另存为

cv2.waitKey(0)#窗口等待
cv2.destroyAllWindows()#窗口删除