I need to draw a 2D binary mask based on array of vertexes of N convex polygons.
import numpy as np
mask = np.zeros((100, 100), dtype=np.int8)
polys = np.array([[[30,32], [36,46], [41,48], [50, 36]],
[[10,32], [16,46], [30,48], [40, 36]],
[[56,44], [58,70], [78,90], [75,34]]], np.int32)
Area of intersection between polygons should be also masked. I know how to implement it using cv2 library:
import cv2
for i in polys.tolist():
cv2.fillConvexPoly(mask, np.array(i), 1)
imshow(mask, cmap='gray')
But I cannot figure out how to do that using native numpy operations (without for loops) to reduce time to run the function.