1

I have a task to find the differences between two images, but the issue is that when I use the code below, there are too many differences between the two images, almost the entire image appears different, even though they should only differ in a few parts. However, the specific differences will have a darker color. Please help me figure out how to accurately identify the differences and use OpenCV to circle the differing points on the two original images

Image1:

Image1

Image2:

Image2 My code:

from PIL import Image, ImageChops
img1, img2 = Image.open('1.png'), Image.open('2.png')
diff = ImageChops.difference(img1,img2)
if diff.getbbox():
    diff.show()

Output:

Output

I use PIL library to detect difference between two images

toyota Supra
  • 3,181
  • 4
  • 15
  • 19
  • Your two images are not aligned. There is a vertical shift between the two. Use feature matching to align them first. – fmw42 Jun 26 '23 at 17:00
  • Please check: https://stackoverflow.com/q/56183201/18667225 – Markus Jun 27 '23 at 06:58
  • Another way to see the misalignment is as follows. Open one image in Photoshop, open the other, copy it and paste it on top of the first. On the new, uppermost layer, set the Blending Mode to "DIFFERENCE". Now select the MOVE Tool and move the top image one pixel at a time with the arrow keys (not with mouse). As you move it up and down, you will see horizontal lines appear. As you move it left and right you will see vertical lines appear. You will note that you cannot get rid of all the differences as the images are either saved at different qualities or slightly distorted. – Mark Setchell Jun 29 '23 at 09:31

0 Answers0