From 4182a108a01df3aa28009716472f0ef291704866 Mon Sep 17 00:00:00 2001 From: Sudipto Mallick Date: Sat, 10 Feb 2024 12:49:55 +0000 Subject: Complete DIP assignments --- opencv/code/a4.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 opencv/code/a4.py (limited to 'opencv/code/a4.py') 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) -- cgit 1.4.1-2-gfad0