Skip to content

How to find the coordinates of the missing parts in a image compared to the original complete image? #7621

Closed Answered by radarhere
nissansz asked this question in Q&A
Discussion options

You must be logged in to vote

At first, I wanted to suggest

from PIL import Image, ImageChops
with Image.open("complete.png") as complete:
    with Image.open("missing.jpg") as missing:
        delta = ImageChops.subtract_modulo(complete.convert("RGB"), missing)
        print(delta.getbbox())

However, while your first image is a PNG, your second image is a JPEG. Because JPEG is a lossy format, when your image was saved as a JPEG file, subtle changes would have been created, meaning that a simple comparison cannot be made.

Instead, the comparison needs to include a threshold.

from PIL import Image, ImageChops
with Image.open("complete.png") as complete:
    with Image.open("missing.jpg") as missing:
        complete_l = 

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by radarhere
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants