Advertisement
Peaser

fgasgfasdasddsadsa

Aug 7th, 2014
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.12 KB | None | 0 0
  1. from PIL import Image
  2. import itertools
  3.  
  4. def chop(object,n):
  5.     return [object[i:i+n] for i in range(0, len(object), n)]
  6.  
  7. def organize(object):
  8.     a = []
  9.     b = []
  10.     c = []
  11.     for i in object:
  12.         a.append(i[0])
  13.         b.append(i[1])
  14.         c.append(i[2])
  15.     a = (sum(a)/len(a))
  16.     b = (sum(b)/len(b))
  17.     c = (sum(c)/len(c))
  18.     total = []
  19.     for i in range(len(object)):
  20.         total.append((a,b,c))
  21.     return total
  22.  
  23. def rngmirror(object):
  24.     from lc import halflist
  25.     full = halflist(object)
  26.     final = full[0]+list(reversed(full[1]))
  27.     return final
  28.  
  29. def gradientize(object):
  30.     increments = range(1, len(object)+1)
  31.     increments = rngmirror(increments)
  32.     total = []
  33.     for i, i2 in zip(object, increments):
  34.         tep = []
  35.         for a in i:
  36.             tep.append(a*i2/len(object))
  37.         total.append(tuple(tep))
  38.     return total
  39.  
  40. img = Image.open('ex.jpg')
  41. data = img.getdata()
  42.  
  43. data = list(itertools.chain(*[gradientize(a) for a in [organize(i) for i in chop(list(data), img.size[0]/8)]]))
  44.  
  45. es = Image.new('RGB', img.size, "white")
  46. es.putdata(data)
  47. es.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement