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()
上一篇:Opencv基础自学七(加减乘除)


下一篇:阈值分割