I have two images. In one image, the white pixels are set to be transparent (or colorless) by editing the channel A
in RGBA
image format. Suppose this image name is image_rgba.png
and the other image is image.jpg
. Now, I want to put the image_rgba.png
image in a specific location of the image.jpg
using the following python code
import cv2
import numpy as np
import matplotlib.pyplot as plt
image = cv2.imread('image.jpg')
label = cv2.imread('image_rgba.png')
label = cv2.cvtColor(label, cv2.COLOR_BGR2RGBA)
new_image = image.copy()
new_image = cv2.cvtColor(new_image, cv2.COLOR_BGR2RGBA)
new_image[200:290, 300:384, :] = label
When I write this image, the edges of the image_rgba.png
which is colorless, are set to be white in the output image (the white edges of the green box in the following image).
I want the white edges of the green box label does not to show and instead the background image shown in that pixels. I found the similar question but it does not help me to solve my problem. I would be appreciated it if anybody can help me.