summary refs log tree commit diff stats
path: root/opencv/code/a4.py
diff options
context:
space:
mode:
Diffstat (limited to 'opencv/code/a4.py')
-rw-r--r--opencv/code/a4.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/opencv/code/a4.py b/opencv/code/a4.py
new file mode 100644
index 0000000..dbd14e9
--- /dev/null
+++ b/opencv/code/a4.py
@@ -0,0 +1,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)