Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PIL import Image, ImageChops
- import numpy as np
- FOLDER = '/home/username/'
- img1 = Image.open(FOLDER + 'image1.png').convert('RGB') # without A (RGBA) to remove transparency
- img2 = Image.open(FOLDER + 'image2.png').convert('RGB') # without A (RGBA) to remove transparency
- diff = ImageChops.difference(img2, img1).convert('L') # L = grayscale (it will covert three numbers R,G,B into one number)
- diff.save(FOLDER + 'diff.png')
- arr = np.asarray(diff) # convert to numpy's array
- data = np.nonzero(arr) # find nonzero values
- for x, y in zip(data[0], data[1]):
- print(x, y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement