I have a numpy array img(640, 400, 3) It basically contains a pixel array of an image loaded via OpenCV library. Some of the pixels are zero [0, 0, 0] and other are non-zero [r, g, b] values
How do I -
- insert another column to make the shape of it (640, 400, 4) to add the alpha values, so that the pixels become [r, g, b, a], where a is the alpha value
- In this new column, the alpha value needs to be set based on a condition: if [r, g, b] == 0 then alpha == 0 else alpha == 255. i.e, my new pixels should be either [0, 0, 0, 0] or [r, g, b, 255]
How do I do this in numpy itself, I don't want to use OpenCV to re-read the image to generate the alpha values.