Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pygame import *
- def subtract(img1,img2,path):
- surf1,surf2=image.load(img1),image.load(img2)
- width,height=surf1.get_size()
- surf3=Surface((width,height))
- for y in range(height):
- for x in range(width):
- color1=surf1.get_at((x,y))
- color2=surf2.get_at((x,y))
- diff=255-float(abs(color1[0]-color2[0])+abs(color1[1]-color2[1])+abs(color1[2]-color2[2]))/3
- surf3.set_at((x,y),[diff,diff,diff])
- image.save(surf3,path)
Add Comment
Please, Sign In to add comment