[python-dtcwt] 239/497: add tennis imagery to registration example
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Tue Jul 21 18:06:09 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 86c2e2d1811af33fc38ce3ab03730f218b8be650
Author: Rich Wareham <rjw57 at cam.ac.uk>
Date: Mon Jan 27 15:50:56 2014 +0000
add tennis imagery to registration example
---
examples/image-registration-2.py | 95 +++++++++++++++++++++------------------
tests/tennis.npz | Bin 0 -> 425927 bytes
tests/tennis.source.txt | 1 +
3 files changed, 52 insertions(+), 44 deletions(-)
diff --git a/examples/image-registration-2.py b/examples/image-registration-2.py
index 1f2278a..5575fd5 100755
--- a/examples/image-registration-2.py
+++ b/examples/image-registration-2.py
@@ -21,49 +21,56 @@ from dtcwt.registration import *
logging.basicConfig(level=logging.INFO)
-# Load test images
-logging.info('Loading frames')
-test_frames = np.load(os.path.join(os.path.dirname(__file__), '..', 'tests', 'traffic.npz'))
-f1 = test_frames['f1']
-f2 = test_frames['f2']
-
-# Take the DTCWT of both frames.
-logging.info('Taking DTCWT')
-nlevels = 6
-Yl1, Yh1 = dtcwt.dtwavexfm2(f1, nlevels=nlevels)
-Yl2, Yh2 = dtcwt.dtwavexfm2(f2, nlevels=nlevels)
-
-# Solve for transform
-logging.info('Finding flow')
-avecs = estimateflow(Yh1, Yh2)
-
-logging.info('Computing warped image')
-warped_f1 = warp(f1, avecs, method='bilinear')
-
-logging.info('Computing velocity field')
-step = 8
-X, Y = np.meshgrid(np.arange(f1.shape[1]), np.arange(f1.shape[0]))
-vxs, vys = velocityfield(avecs, f1.shape, method='bilinear')
-
-figure()
-subplot(221)
-imshow(np.dstack((f1, f2, np.zeros_like(f1))))
-title('Overlaid frames')
-
-subplot(222)
-imshow(np.dstack((warped_f1, f2, np.zeros_like(f2))))
-title('Frame 1 warped to Frame 2 (image domain)')
-
-subplot(223)
-imshow(np.dstack((f1, f2, np.zeros_like(f2))))
-quiver(X[::step,::step], Y[::step,::step],
- -vxs[::step,::step]*f1.shape[1], -vys[::step,::step]*f1.shape[0],
- color='b', angles='xy', scale_units='xy', scale=1)
-title('Computed velocity field')
-
-subplot(224)
-imshow(np.sqrt(vxs*vxs + vys*vys), interpolation='none', cmap=cm.hot)
-colorbar()
-title('Magnitude of computed velocity')
+def register_frames(filename):
+ # Load test images
+ logging.info('Loading frames from "{0}"'.format(filename))
+ test_frames = np.load(filename)
+ f1 = test_frames['f1']
+ f2 = test_frames['f2']
+
+ # Take the DTCWT of both frames.
+ logging.info('Taking DTCWT')
+ nlevels = 6
+ Yl1, Yh1 = dtcwt.dtwavexfm2(f1, nlevels=nlevels)
+ Yl2, Yh2 = dtcwt.dtwavexfm2(f2, nlevels=nlevels)
+
+ # Solve for transform
+ logging.info('Finding flow')
+ avecs = estimateflow(Yh1, Yh2)
+
+ logging.info('Computing warped image')
+ warped_f1 = warp(f1, avecs, method='bilinear')
+
+ logging.info('Computing velocity field')
+ step = 8
+ X, Y = np.meshgrid(np.arange(f1.shape[1]), np.arange(f1.shape[0]))
+ vxs, vys = velocityfield(avecs, f1.shape, method='bilinear')
+
+ vxs -= np.median(vxs.flat)
+ vys -= np.median(vys.flat)
+
+ figure()
+ subplot(221)
+ imshow(np.dstack((f1, f2, np.zeros_like(f1))))
+ title('Overlaid frames')
+
+ subplot(222)
+ imshow(np.dstack((warped_f1, f2, np.zeros_like(f2))))
+ title('Frame 1 warped to Frame 2 (image domain)')
+
+ subplot(223)
+ imshow(np.dstack((f1, f2, np.zeros_like(f2))))
+ quiver(X[::step,::step], Y[::step,::step],
+ -vxs[::step,::step]*f1.shape[1], -vys[::step,::step]*f1.shape[0],
+ color='b', angles='xy', scale_units='xy', scale=1)
+ title('Computed velocity field (median subtracted)')
+
+ subplot(224)
+ imshow(np.sqrt(vxs*vxs + vys*vys), interpolation='none', cmap=cm.hot)
+ colorbar()
+ title('Magnitude of computed velocity (median subtracted)')
+
+register_frames(os.path.join(os.path.dirname(__file__), '..', 'tests', 'traffic.npz'))
+register_frames(os.path.join(os.path.dirname(__file__), '..', 'tests', 'tennis.npz'))
show()
diff --git a/tests/tennis.npz b/tests/tennis.npz
new file mode 100644
index 0000000..feb0cd1
Binary files /dev/null and b/tests/tennis.npz differ
diff --git a/tests/tennis.source.txt b/tests/tennis.source.txt
new file mode 100644
index 0000000..90e2103
--- /dev/null
+++ b/tests/tennis.source.txt
@@ -0,0 +1 @@
+Tennis imagery downloaded from: http://lmb.informatik.uni-freiburg.de/resources/binaries/
--
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