Sync.

parent 401a095d
from interpolation import in_image, pv
from interpolation import pv
from numpy import array, zeros
from numpy.linalg import lstsq
from numpy.linalg import lstsq, inv
# url: http://www.leptonica.com/affine.html
......@@ -29,6 +29,7 @@ def affine_transform(image, p1, p2, p3, width, height):
# Calculate transform matrix
p = lstsq(M, q)[0]
T = p.reshape(2, 3).T
T = inv(T)
# Construct the transformed image
result = zeros((width, height))
......@@ -45,7 +46,16 @@ def affine_transform(image, p1, p2, p3, width, height):
orig_pos = array([x, y, 1]).reshape(3, 1) * T
#print x,y, tmp
#result[y][x] =
print orig_pos, len(orig_pos)
# XXX Why is orig_pos in the format listed below?
#
# |g h|
# |i j|
# |k l|
#
result[y][x] = pv(image, orig_pos[0], orig_pos[1], 'linear')
return result
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment