I have been trying to obtain a circle ROI based on this post (so I can try and find the average RGB color within the circle). I created a white-filled circle mask at the center of the image and put the mask into the alpha channel of the image. cv2.imshow()
, however, seems to ignore the alpha channel. How can I get cv2.imshow() to show the circle?
Here is my code:
import cv2
import numpy as np
img = cv2.imread("Assets/Setup.jpg")
height, width = img.shape[:2]
mask = cv2.circle(np.zeros((height, width), dtype=np.uint8), (width // 2, height // 2), width // 2, 255, -1)
result = cv2.cvtColor(img, cv2.COLOR_BGR2BGRA)
result[:, :, 3] = mask
cv2.imshow("Frame", result)
cv2.waitKey(0)
cv2.destroyAllWindows()