Reputation: 65
I'm a beginner in python and i have some difficulties to do what i want to do.
I want to spot the difference between two images in a game "spot seven diffenrecies".
from PIL import Image
from PIL import ImageChops
a = Image.open("pict1.jpg")
b = Image.open("pict2.jpg")
diff = ImageChops.difference (a, b)
Now i want to enlight in red the differences like that:
https://i.sstatic.net/3cDh3.jpg
https://i.sstatic.net/LXgzG.jpg
Can you help me (and my awesome english) ? :D
Upvotes: 1
Views: 1059
Reputation: 28370
I would suggest, from where you are above you could do something like:
from PIL import Image
from PIL import ImageChops
a = Image.open("pict1.jpg")
b = Image.open("pict2.jpg")
diff = ImageChops.difference (a, b)
RED = ('red')
RL = Image.new('RGB', diff.size, RED) # Make a red layer the same size
RedDiff = ImageChops.multiply(RL, diff)
Result = ImageChops.blend(RedDiff, b, 0.7)
Result.show()
Upvotes: 5
Reputation: 662
try to read your images to separate arrays and compare arrays together
then manipulate the diff parts by change the color you want
Upvotes: 0