mask = np.zeros_like(frame)
rows, cols,_ = mask.shape
mask=cv2.ellipse(mask, (320, 250), (80, 120), 0, 0, 360, (255,255,255), -1)
result = np.bitwise_and(frame,mask)
bgr = result[:,:,:3] # Channels 0..2
gray = cv2.cvtColor(bgr, cv2.COLOR_BGR2GRAY)
# Some sort of processing...
bgr = cv2.cvtColor(gray, cv2.COLOR_GRAY2BGR)
alpha = result[:,:,3] # Channel 3
result = np.dstack([bgr, alpha])
cv2.imwrite("media/faces/face.png", result)
Can you please help me again @berak ? I manage to change my background to white but the the image gets gray. I think it is due to the this line:
alpha = result[:,:,3] # Channel 3
which throws an error. But, if I change 3 to 2, it works but it doesn’t produce the right result.