编程语言
首页 > 编程语言> > python+openCV图像处理(四)色彩空间转换

python+openCV图像处理(四)色彩空间转换

作者:互联网

import cv2 as cv
import numpy as np

def color_space_demo(image):
    gray = cv.cvtColor(image, cv.COLOR_BGR2GRAY)
    cv.imshow("gray", gray)
    hsv = cv.cvtColor(image, cv.COLOR_BGR2HSV)
    cv.imshow("hsv", hsv)
    yuv = cv.cvtColor(image, cv.COLOR_BGR2YUV)
    cv.imshow("yuv", yuv)
    Ycrcb = cv.cvtColor(image, cv.COLOR_BGR2YCrCb)
    cv.imshow("ycrcb", Ycrcb)

src = cv.imread("D:/vimages/3.png")
cv.namedWindow("input image", cv.WINDOW_AUTOSIZE)
cv.imshow("input image", src)

color_space_demo(src)

cv.waitKey(0)
cv.destroyAllWindows()

标签:src,COLOR,python,image,imshow,openCV,图像处理,cvtColor,cv
来源: https://blog.csdn.net/yang_jianfeng/article/details/110411539