summary refs log blame commit diff stats
path: root/opencv/code/a4.py
blob: dbd14e9c051483c0afb19b545b1534d00c6e3e16 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
















                                                           
import cv2
import numpy as np

image = cv2.imread("4i.jpg")

blue_channel, green_channel, red_channel = cv2.split(image)

zeros = np.zeros_like(blue_channel)

# Merge each channel with zeroes for the other channels
blue_image = cv2.merge([blue_channel, zeros, zeros])
green_image = cv2.merge([zeros, green_channel, zeros])
red_image = cv2.merge([zeros, zeros, red_channel])

cv2.imwrite("4.b.jpg", blue_image)
cv2.imwrite("4.g.jpg", green_image)
cv2.imwrite("4.r.jpg", red_image)