Guest User

Untitled

a guest
Jul 16th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. from pygame import *
  2. def subtract(img1,img2,path):
  3. surf1,surf2=image.load(img1),image.load(img2)
  4. width,height=surf1.get_size()
  5. surf3=Surface((width,height))
  6. for y in range(height):
  7. for x in range(width):
  8. color1=surf1.get_at((x,y))
  9. color2=surf2.get_at((x,y))
  10. diff=255-float(abs(color1[0]-color2[0])+abs(color1[1]-color2[1])+abs(color1[2]-color2[2]))/3
  11. surf3.set_at((x,y),[diff,diff,diff])
  12. image.save(surf3,path)
Add Comment
Please, Sign In to add comment