[python-dtcwt] 428/497: registration: increase performance of phasegradient
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Tue Jul 21 18:06:35 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 5e6cc59c2452db5ce2c245ec4185b0cb43654d5b
Author: Rich Wareham <rjw57 at cam.ac.uk>
Date: Fri Mar 28 13:32:59 2014 +0000
registration: increase performance of phasegradient
Previously phasegradient abused the bilinear sampling functions to sum
neighbouring values. Perform the sum directly and explicitly.
---
dtcwt/registration.py | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/dtcwt/registration.py b/dtcwt/registration.py
index 7c1b73f..ea898e5 100644
--- a/dtcwt/registration.py
+++ b/dtcwt/registration.py
@@ -50,19 +50,24 @@ def phasegradient(sb1, sb2, w=None):
if sb1.size != sb2.size:
raise ValueError('Subbands should have identical size')
- xs, ys = np.meshgrid(np.arange(sb1.shape[1]), np.arange(sb1.shape[0]))
-
# Measure horizontal phase gradients by taking the angle of
# summed conjugate products across horizontal pairs.
- A = sb1[:,1:] * np.conj(sb1[:,:-1])
- B = sb2[:,1:] * np.conj(sb2[:,:-1])
- dx = np.angle(dtcwt.sampling.sample((A+B) * np.exp(-1j * w[0]), xs-0.5, ys, method='bilinear')) + w[0]
+ S = (sb1[:,1:] * np.conj(sb1[:,:-1]) + sb2[:,1:] * np.conj(sb2[:,:-1])) * np.exp(-1j * w[0])
+ #dx = np.angle(dtcwt.sampling.sample(S, xs-0.5, ys, method='bilinear')) + w[0]
+ dx = np.hstack((
+ np.angle(S[:,:1]),
+ np.angle(0.5 * (S[:,:-1] + S[:,1:])),
+ np.angle(S[:,-1:])
+ )) + w[0]
# Measure vertical phase gradients by taking the angle of
# summed conjugate products across vertical pairs.
- A = sb1[1:,:] * np.conj(sb1[:-1,:])
- B = sb2[1:,:] * np.conj(sb2[:-1,:])
- dy = np.angle(dtcwt.sampling.sample((A+B) * np.exp(-1j * w[1]), xs, ys-0.5, method='bilinear')) + w[1]
+ S = (sb1[1:,:] * np.conj(sb1[:-1,:]) + sb2[1:,:] * np.conj(sb2[:-1,:])) * np.exp(-1j * w[1])
+ dy = np.vstack((
+ np.angle(S[:1,:]),
+ np.angle(0.5 * (S[:-1,:] + S[1:,:])),
+ np.angle(S[-1:,:])
+ )) + w[1]
# Measure temporal phase differences between refh and prevh
A = sb2 * np.conj(sb1)
--
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