代码如下:
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()
运行结果:
代码解释:
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()