Say I have an BGRA image as numpy
array that looks pretty much like this:
[[[233 228 230 128]
[233 228 230 128]
[233 228 230 0]
...
[164 160 159 65]
[199 197 196 65]
[255 255 254 120]]
That looks pretty straightforward - three colour channels + one alpha that controls transparency of pixels. Saving that numpy array in a PNG format results in an image that is semi-transparent as it should be.
However, when saving it as JPEG, the alpha channel is dropped completely and the all of the pixels are fully opaque.
As JPEG does not support alpha-transparency, I would like my semi-transparent image (the numpy array above) to be saved on a white background instead. That way, it would appear as if the pixels would still be semi-transparent.
How can I overlay the semi-transparent numpy array on a fully white background? I am using mainly numpy and OpenCV.