Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PIL import Image
- import numpy
- im = Image.open("komiks-0007.jpg")
- size = im.size
- newim = Image.new("RGB", (1024, 1024), (255,255,255))
- newpix = newim.load()
- pix = im.load()
- A = 1 # x' = x * A
- B = 0 # y' = y + B * x
- C = 2 # x' = x + C * y
- D = 1 # y' = y * D
- E = 2 # y' = y + E
- F = 0 # x' = x + F
- a = 3 # w = a * x + b * y + c
- b = 0
- c = 1
- matrix = numpy.array([[A, B, a],
- [C, D, b],
- [E, F, c]], "f")
- vector = numpy.array([1, 1, 1], "f")
- result = numpy.dot(vector.T, matrix)
- print size
- for x in range(1, size[0]):
- for y in range(0, size[1]):
- ##newX = (1.1 * x - 0.2 * y)/(0.00075 * x + 0.000005 * y + 1)
- ##newY = (0.1 * x + 0.9 * y)/(0.00075 * x + 0.000005 * y + 1)
- #newX = 1.2 * x + 0.1 * y + 4
- #newY = 0.0 * x + 0.3 * y + 10
- vector = numpy.array([x, y, 1], "i")
- newCoord = numpy.dot(vector, matrix)
- #print (x, y)
- #print newCoord
- newX = newCoord[0] + 50
- newY = newCoord[1] + 50
- if(newX > 0 and newX < 1024 and newY > 0 and newY < 1024):
- newpix[newX / newCoord[2], newY / newCoord[2]] = pix[x,y]
- newim.save("a.jpg")
Add Comment
Please, Sign In to add comment