Marc
Marc

Reputation: 65

Color in red diffrencies between two pictures

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

Answers (2)

Steve Barnes
Steve Barnes

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()

enter image description here

Upvotes: 5

dare
dare

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

Related Questions