Skip to content
Snippets Groups Projects
Commit d082e2e6 authored by Sander Mathijs van Veen's avatar Sander Mathijs van Veen
Browse files

Sync.

parent 401a095d
No related branches found
No related tags found
No related merge requests found
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
......@@ -28,7 +28,8 @@ def affine_transform(image, p1, p2, p3, width, height):
# Calculate transform matrix
p = lstsq(M, q)[0]
T = p.reshape(2, 3).T
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
......@@ -58,7 +68,7 @@ if __name__ == '__main__':
half_height = image.shape[1] / 2
M, N = image.shape
# TODO: validate MxN -> width x height
result = affine_transform(image, (0., 0.), (0., half_height),
(half_width, half_height), M, N)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment