opencv教程CV2模块系列——复制图片、灰度模式并保存
import cv2
img = cv2.imread('./imgg/1.jpeg',cv2.IMREAD_UNCHANGED)
# 复制图片
imgcopy = img.copy()
#彩色图像转为灰度图像
img2 = cv2.cvtColor(imgcopy,cv2.COLOR_RGB2GRAY)
#灰度图像转为彩色图像
img3 = cv2.cvtColor(img2,cv2.COLOR_GRAY2RGB)
# cv2.COLOR_X2Y,其中X,Y = RGB, BGR, GRAY, HSV, YCrCb, XYZ, Lab, Luv, HLS
cv2.imshow('image',img3)
cv2.imwrite('./out/1_4.jpg',img3, [int(cv2.IMWRITE_PNG_COMPRESSION), 3])