Guest User

Untitled

a guest
May 26th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.26 KB | None | 0 0
  1. from PIL import Image
  2. import numpy
  3.  
  4. im = Image.open("komiks-0007.jpg")
  5. size = im.size
  6. newim = Image.new("RGB", (1024, 1024), (255,255,255))
  7. newpix = newim.load()
  8. pix = im.load()
  9.  
  10. A = 1 # x' = x * A
  11. B = 0 # y' = y + B * x
  12. C = 2 # x' = x + C * y
  13. D = 1 # y' = y * D
  14. E = 2 # y' = y + E
  15. F = 0 # x' = x + F
  16. a = 3 # w = a * x + b * y + c
  17. b = 0
  18. c = 1
  19.  
  20. matrix = numpy.array([[A, B, a],
  21.                       [C, D, b],
  22.                       [E, F, c]], "f")
  23.                      
  24.          
  25. vector = numpy.array([1, 1, 1], "f")
  26.  
  27. result = numpy.dot(vector.T, matrix)
  28. print size
  29.  
  30. for x in range(1, size[0]):
  31.     for y in range(0, size[1]):
  32.         ##newX = (1.1 * x - 0.2 * y)/(0.00075 * x + 0.000005 * y + 1)
  33.         ##newY = (0.1 * x + 0.9 * y)/(0.00075 * x + 0.000005 * y + 1)
  34.        
  35.         #newX = 1.2 * x + 0.1 * y + 4
  36.         #newY = 0.0 * x + 0.3 * y + 10
  37.        
  38.         vector = numpy.array([x, y, 1], "i")
  39.         newCoord = numpy.dot(vector, matrix)
  40.        
  41.         #print (x, y)
  42.         #print newCoord
  43.         newX = newCoord[0] + 50
  44.         newY = newCoord[1] + 50
  45.         if(newX > 0 and newX < 1024 and newY > 0 and newY < 1024):
  46.             newpix[newX / newCoord[2], newY / newCoord[2]] = pix[x,y]
  47.        
  48. newim.save("a.jpg")
Add Comment
Please, Sign In to add comment