I need to merge two images with respect to its coordinate values.
I have done merging using single point to point merge using
Paste an image to another image at two given co-ordinates with altered opacity using PIL or OpenCV in Python - Stack Overflow[
^]
I got output for that.
But I need to do multiple coordinate merge in same 2 images..
Is there any possible way to do that?
What I have tried:
"""
Paste one image on top of another such that given points in each are coincident.
"""
from PIL import Image
im1 = Image.open('1.png').convert('RGB')
im2 = Image.open('2.png').convert('RGB')
p1x, p1y = 280, 250
p2x, p2y = 12, 25
pL = max(p1x, p2x)
pR = max(im1.width-p1x, im2.width-p2x)
pT = max(p1y, p2y)
pB = max(im1.height-p1y, im2.height-p2y)
bg = Image.new('RGB', (pL+pR, pT+pB),'white')
bg.save('DEBUG-bg.png')
bg.paste(im1, (pL-p1x, pT-p1y))
bg.save('DEBUG-bg+im1.png')
alpha = Image.new('L', (im2.width,im2.height), int(40*255/100))
alpha.save('DEBUG-alpha.png')
bg.paste(im2, (pL-p2x, pT-p2y), alpha)
bg.save('result.png')