I am trying to use Python to compare 2 images and to produce a third image that highlights the differences between the two. For example the two images below are taken a few years apart. The second one shows an impact crater (the dark section in the bottom right) that isnt on the first one. Obviously there are differences in the position of the sun in both causing the general background to differ. Also because I manually cut up these images and resized them they may be very slightly different scale and they may have been taken at a slightly different viewing angle. The extra dark area in image 2 however is very noticeable from image 1. What is the best way in Python to identify and mark on these different areas?
I have tried the following code which works as I would like for very simple basic images with differences but it doesnt even generate a final image when I try it with these images. I guess they are too complicated and it cant cope.
from PIL import Image, ImageChops im1 = Image.open("C:/Users/xxx/Python/Compare_Images/image1.png") im2 = Image.open("C:/Users/xxx/Python/Compare_Images/image2.png") diff = ImageChops.difference(im2, im1) if diff.getbbox(): diff.show()