I have two pictures that I need to put together as one. The first one is about a beach with the ocean. The second picture is a cactus with a very bright green screen behind it. I need to find a way to tune down the green screen in the cactus picture so that I can place it over the beach picture and make it look like there is a cactus at the beach. I can change the pixel colors but I can not seem to take out the bright green screen color of the cactus picture. I can also put both pictures together but the green screen of the cactus picture over writes the coloring of the beach picture. Could any please help show me how to tune down the green pixels of the cactus picture or get rid of the green screen part? Here is the code that I am working with. It's in the google docs. I am at a lost. here is a link to see what I need to do. The last picture is how it should look
https://docs.google.com/document/d/1ZYrigN1LXSMq3_llc6eimZqBh2R9ZVeBmmxSUx63__E/edit?usp=sharing
Here you have to change (r, g, b) value for best mask. You can use range also. Check this out.
from PIL import Image
from PIL import ImageFilter
import os
im1 = Image.open('beach.jpg')
im2 = Image.open('cactus.jpg')
back_im = im1.copy()
for filename in os.listdir("."):
if filename[-3:] == "jpg":
img = Image.open(filename)
img = img.convert("RGBA")
pixdata = img.load()
for y in range(img.size[1]):
for x in range(img.size[0]):
r, g, b, a = img.getpixel((x, y))
if (r == 76) and (g == 244) and (b == 24):
pixdata[x, y] = (255, 255, 255, 0)
if r == 0 and g == 0 and b == 0:
pixdata[x, y] = (255, 255, 255, 0)
img2 = img.filter(ImageFilter.GaussianBlur(radius=1))
back_im.paste(img2,mask=img2)
back_im.save('filename.jpg')