# -*- coding: utf-8 -*-
"""
Created on Fri Aug 24 15:19:31 2018
@author: Miracle
"""
import cv2
'''
opencv有哪些颜色空间?
'''
print([x for x in dir(cv2) if x.startswith('COLOR_')])
#转换图像颜色空间
image = cv2.imread('../data/lena.jpg')
#BGR->YUV\YCrCb\HSV
yuv_image = cv2.cvtColor(image,cv2.COLOR_BGR2YUV)
YCrCb_image = cv2.cvtColor(image,cv2.COLOR_BGR2YCrCb)
hsv_image = cv2.cvtColor(image,cv2.COLOR_BGR2HSV)
hls_image = cv2.cvtColor(image,cv2.COLOR_BGR2HLS)
#显示各类颜色空间下的图像
cv2.imshow('Original Image',image)
cv2.imshow('yuv Image',yuv_image)
cv2.imshow('YCrCb Image',YCrCb_image)
cv2.imshow('HSV Image',hsv_image)
cv2.imshow('HLS Image',hls_image)
#显示单通道图像B\G\R
cv2.imshow('B channel',image[:,:,0])
cv2.imshow('G channel',image[:,:,1])
cv2.imshow('R channel',image[:,:,2])
cv2.waitKey()