Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import matplotlib.pyplot as plt
- from PIL import Image
- img = Image.open("C:\\Users\Shadow\Desktop\JohnTravolta\GreenScreen.png")
- print(img.size)
- img.convert("RGBA")
- background = Image.open('C:\\Users\Shadow\Desktop\JohnTravolta\Background.png')
- print(background.size)
- size = img.size
- background.convert("RGBA")
- background = background.resize(size, Image.ANTIALIAS)
- print(background.size)
- pixelData = img.load()
- width,height = img.size
- for y in range(height):
- for x in range(width):
- if pixelData[x,y] == (103,254,3,255) :
- pixelData[x,y] = (255,255,255,0)
- background.paste(img, (0, 0), img)
- background.save('new_image.png', "PNG")
- plt.imshow(background)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement