[python-dtcwt] 246/497: registration: document all external functions

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Tue Jul 21 18:06:10 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch debian/sid
in repository python-dtcwt.

commit 2c6c3b456f1f5ec57df9121ebe85e08cfc477df3
Author: Rich Wareham <rjw57 at cam.ac.uk>
Date:   Mon Jan 27 19:00:50 2014 +0000

    registration: document all external functions
---
 dtcwt/registration.py | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/dtcwt/registration.py b/dtcwt/registration.py
index 8dea564..d4c3fe3 100644
--- a/dtcwt/registration.py
+++ b/dtcwt/registration.py
@@ -258,6 +258,14 @@ def affinewarp(Yh, a, method=None):
     return normsample(Yh, xs+vxs, ys+vys, method=method)
 
 def estimateflow(reference_h, target_h):
+    """
+    Given highpass subbands from the reference and target image, estimate the
+    local distortion at 8x8 pixel scales. Return a NxMx6 array where the
+    6-element vector at (N,M) corresponds to the affine distortion parameters
+    for that section of the image. The returned array is 8x downsampled from
+    the original.
+
+    """
     # Make a copy of reference_h for warping
     warped_h = list(reference_h)
 
@@ -301,23 +309,46 @@ def estimateflow(reference_h, target_h):
     return avecs
 
 def velocityfield(avecs, shape, method=None):
+    """
+    Given the affine distortion parameters returned from :py:func:`estimateflow`, return
+    a tuple of 2D arrays giving the x- and y- components of the velocity field. The
+    shape of the velocity component field is *shape*. The velocities are measured in
+    terms of normalised units where the image has width and height of unity.
+
+    The *method* parameter is interpreted as in :py:func:`dtcwt.sampling.rescale` and
+    is the sampling method used to resize *avecs* to *shape*.
+
+    """
     h, w = shape[:2]
     pxs, pys = np.meshgrid(np.arange(0, w, dtype=np.float32) / w,
                            np.arange(0, h, dtype=np.float32) / h)
 
-    avecs = dtcwt.sampling.rescale(avecs, shape, method='bilinear')
+    avecs = dtcwt.sampling.rescale(avecs, shape, method=method)
     vxs = avecs[:,:,0] + avecs[:,:,2] * pxs + avecs[:,:,4] * pys
     vys = avecs[:,:,1] + avecs[:,:,3] * pxs + avecs[:,:,5] * pys
 
     return vxs, vys
 
 def warphighpass(Yh, avecs, method=None):
+    """
+    A convenience function to warp a highpass subband image according to the
+    velocity field implied by *avecs*.
+
+    This function correctly 'de-rotates' the highpass image before sampling and
+    're-rotates' afterwards.
+
+    """
     X, Y = np.meshgrid(np.arange(Yh.shape[1], dtype=np.float32)/Yh.shape[1],
                        np.arange(Yh.shape[0], dtype=np.float32)/Yh.shape[0])
     vxs, vys = velocityfield(avecs, Yh.shape, method=method)
     return normsamplehighpass(Yh, X+vxs, Y+vys, method=method)
 
 def warp(I, avecs, method=None):
+    """
+    A convenience function to warp an image according to the velocity field
+    implied by *avecs*.
+
+    """
     X, Y = np.meshgrid(np.arange(I.shape[1], dtype=np.float32)/I.shape[1],
                        np.arange(I.shape[0], dtype=np.float32)/I.shape[0])
     vxs, vys = velocityfield(avecs, I.shape, method=method)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/python-dtcwt.git



More information about the debian-science-commits mailing list