import cv2 import numpy as np def annotate_masks(image, masks): canvas = np.zeros_like(image) for i, mask in enumerate(masks): # Generate a unique color for each mask (you can also choose specific colors) color = np.random.randint(0, 256, size=3) # Random color (R, G, B) # Apply the color to the masked regions canvas[mask == 1] = color overlay_image = cv2.addWeighted(image, 0.7, canvas, 0.3, 0) return overlay_image