Spaces:
Runtime error
Runtime error
File size: 470 Bytes
1d29cdb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
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
|