import cv2 import numpy as np def create_anaglyph(left_image, right_image): # Ensure both images have the same dimensions height, width = left_image.shape[:2] right_image_resized = cv2.resize(right_image, (width, height)) # Extract the red channel from the left image and green-blue channels from the resized right image left_red = left_image[:, :, 2] # Red channel from left image right_green_blue = right_image_resized[ :, :, :2 ] # Green and blue channels from right image # Combine channels into a single anaglyph image anaglyph = np.zeros_like(left_image) anaglyph[:, :, 2] = left_red # Red channel from left image anaglyph[:, :, :2] = right_green_blue # Green and blue channels from right image return anaglyph