Advertisement
Guest User

Untitled

a guest
Mar 1st, 2021
975
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. from PIL import Image, ImageChops
  2. im1 = Image.open('lemur.png')
  3. im2 = Image.open('flag.png')
  4.  
  5. pix1 = im1.load()
  6. pix2 = im2.load()
  7.  
  8. #Both images have the same width & height
  9. w, h = im1.size
  10.  
  11. imn = Image.new("RGB", (w, h), "black")
  12. pixn = imn.load()
  13.  
  14. for i in range(w):    
  15.     for j in range(h):
  16.    
  17.         r1, g1, b1 = pix1[i, j]
  18.         r2, g2, b2 = pix2[i, j]
  19.        
  20.         rn = r1^r2
  21.         gn = g1^g2
  22.         bn = b1^b2
  23.  
  24.        
  25.         pixn[i,j] =  (rn, gn, bn)
  26.        
  27. #imn.show()
  28. imn.save("new.png")
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement