OpenCV---如何在RGB和HSV色彩空间之间转换(8)

代码如下:

import cv2 as cv
import numpy as np
def color():
    src = cv.imread("D:/matplotlib/0.jpg")
    cv.imshow("rgbimage",src)
    hsv = cv.cvtColor(src,cv.COLOR_BGR2HSV)
    cv.imshow("hsvimage",hsv)
    cv.waitKey(0)
    cv.destroyAllWindows()
color()

运行结果:

OpenCV---如何在RGB和HSV色彩空间之间转换(8)_第1张图片

代码解释:

import cv2 as cv
import numpy as np
def color():
    #色彩空间的转换
    src = cv.imread("D:/matplotlib/0.jpg")
    cv.imshow("rgbimage",src)
    hsv = cv.cvtColor(src,cv.COLOR_BGR2HSV)
    #通过hsv色彩通道读取图片
    cv.imshow("hsvimage",hsv)
    cv.waitKey(0)
    cv.destroyAllWindows()
color()

你可能感兴趣的:(OpenCV)