How to convert an RGBA image to Grayscale in python?
问题 I have array of shape (height, width, 4) , i.e., RGBA format, and I want to convert this to grayscale. The original array has RGB values as 0 and the picture is rendered completely based on the alpha values over a white background, hence the traditional ways of turning this into grayscale fail (e.g., cv2.cvtColor(img,cv2.COLOR_RGBA2GRAY) ). Source image: 回答1: Assumptions: Your image is always black-n-white; White is defined as a transparency; If these things are true, then you can use the