I have a 2d numpy array that has 0's where there is not an object, and 1's where there is an object.
matrix.shape = (500, 425)
I want to create a numpy array mask of shape (500, 425, 3) such that:
mask = np.zeros((500, 425, 3))
if matrix[x][y] == 0:
mask[x][y] = np.array([0, 0, 0]) # Black pixel if no object
else:
mask[x][y] = np.array([0, 255, 0]) # Green pixel if object
So that I have green pixels where the object are, black pixels everywhere else. How do I create this mask? Will this work correctly, such that if I use cv2.addWeighted to the image and the mask, the object will have a transparent green mask over it?