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 灰度图