Advertisement
Peaser

Binary Overlay

Jul 31st, 2014
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. from PIL import Image
  2. import lc, ascii_binary
  3.  
  4. def getParts(object, l):
  5.     cma = {'1':(255,255,255),'0':(0,0,0)}
  6.     data = [ascii_binary.binencode(i) for i in lc.recur(object, l)]
  7.     full = [cma[i] for i in ''.join(data)]
  8.     return full[:l]
  9.  
  10. def avTwo(t1, t2):
  11.     return tuple([(a+b)/2 for a, b in [i for i in zip(t1, t2)]])
  12.  
  13. def avList(l1, l2):
  14.     return [avTwo(a, b) for (a, b) in zip(l1, l2)]
  15.  
  16. try:
  17.     b = Image.open('rail.jpg')
  18.     width, height = b.size
  19.     ob = b.getdata()
  20.     ob = list(ob)
  21.     new = [lc.vectorAverage(i) for i in ob]
  22.     total = avList(new, getParts("dick", (width*height)))
  23.     img = Image.new('RGB', (width, height), "white")
  24.     img.putdata(total)
  25.     img.show()
  26. except Exception, e:print str(e)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement