I am trying to make a transparent image and draw on it, and after I will addWeighted over the base image.
How can I initialize fully transparent image with width and hight in openCV python?
EDIT: I want to make a effect like in Photoshop, having stack of the layers, all stacked layers are initially transparent and drawing is performed on fully transparent layer. On the end I will merge all layers to get final image
3
Answers
For creating a transparent image you need a 4 channel matrix, 3 of which would represent RGB colors and the 4th channel would represent Alpha channel, To create a transparent image, you can ignore the RGB values and directly set the alpha channel to be
0
. In Python OpenCV usesnumpy
to manipulate matrices, so a transparent image can be created asIf you want to draw on several “layers” and then stack the drawings together, then how about this:
To convert an image’s white parts to transparent: