Unexpected results while copying transparent image over another image. [closed]
I have a transparent PNG image (shown below)...
and another image (shown below)
I want to copy the resize the first image and place it over the second image, and I tried doing so using the resize() and copyTo() functions. But the result was not what I expected or wanted...
How do I get rid of that green color in the background?
EDIT - So, I did further research and found that this is probably because I am using a three channel image and I need to use a four channel image. So how do I convert a 3-channel image to a 4-channel image?
opencv might be the wrong library for this, entirely.
almost any operations ignore or discard alpha here, as it is of no relevance in computer-vision.
(you'd have to do your own, manual blending, also imshow will just discard alpha.
Take a look at http://answers.opencv.org/question/73...
TL;DR - I created my own blending procedure, but it's pretty basic...
Don't have enough karma points to reopen the question, but I figured out the solution. I imported the overlay image as a 4-channel image, and converted the underlay image into a 4-channel image. Then I set the origin of the overlay image on the underlay image, and ran a
for
loop(i=0->overlay.rows) within afor
loop(j=0->overlay.cols). If the alpha parameter for the overlay[i][j] was 0, I set the underlay[i+origin.y][j+origin.x]'s RGBA to underlay[i][j]'s RGBA....