ENH: Implement fast coordinate transformations.

This commit is contained in:
Stefan van der Walt
2012-05-02 21:31:23 -07:00
parent 12669d62e6
commit 7df3707c33
7 changed files with 268 additions and 8 deletions
+3 -7
View File
@@ -4,18 +4,12 @@
import numpy as np
from scipy.ndimage import interpolation as ndii
from .warp import _stackcopy
__all__ = ['homography']
eps = np.finfo(float).eps
def _stackcopy(a, b):
"""a[:,:,0] = a[:,:,1] = ... = b"""
if a.ndim == 3:
a.transpose().swapaxes(1, 2)[:] = b
else:
a[:] = b
def homography(image, H, output_shape=None, order=1,
mode='constant', cval=0.):
"""Perform a projective transformation (homography) on an image.
@@ -106,6 +100,8 @@ def homography(image, H, output_shape=None, order=1,
coords = np.empty(np.r_[3, output_shape], dtype=float)
# TODO: Refactor this method to use transform.warp instead.
# Construct transformed coordinates
rows, cols = output_shape[:2]
rows, cols = np.mgrid[:rows, :cols]