颜色空间转换

image = imread('image.jpg')
(R, G, B) = cv2.split(image)
zeros = np.zeros(image.shape[:2],dtype='uint8')
show(cv2.merge([R,zeros,zeros]))
show(cv2.merge([zeros,G,zeros]))
show(cv2.merge([zeros,zeros,B]))

 

 

image = imread('image.jpg')
hsv = cv2.cvtColor(image, cv2.COLOR_RGB2HSV)
zeros = np.zeros(image.shape[:2],dtype='uint8')
for (name,chan) in zip(('H','S','V'), cv2.split(hsv)):
    cv2.imshow(name,chan)
cv2.waitKey(0)
cv2.destroyAllWindows()

 

image = imread('image.jpg')
lab = cv2.cvtColor(image, cv2.COLOR_RGB2LAB)
zeros = np.zeros(image.shape[:2],dtype='uint8')
for (name,chan) in zip(('L','A','B'), cv2.split(lab)):
    cv2.imshow(name,chan)
cv2.waitKey(0)
cv2.destroyAllWindows()

 GrayScale 灰度图

 

posted @ 2020-08-30 09:18  yunshangyue  阅读(198)  评论(0编辑  收藏  举报