[python-dtcwt] 433/497: registration: more improvements to confidence()
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 d3592a5e67c7c7e3df2a6184c518836863bfe695
Author: Rich Wareham <rjw57 at cam.ac.uk>
Date: Fri Mar 28 14:35:12 2014 +0000
registration: more improvements to confidence()
Only perform the 2nd and 3rd powers once.
---
dtcwt/registration.py | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/dtcwt/registration.py b/dtcwt/registration.py
index 923f7b8..33e60e6 100644
--- a/dtcwt/registration.py
+++ b/dtcwt/registration.py
@@ -75,6 +75,12 @@ def phasegradient(sb1, sb2, w=None):
return dy, dx, dt
+def _pow2(a):
+ return a * a
+
+def _pow3(a):
+ return a * a * a
+
def confidence(sb1, sb2):
"""
Compute the confidence measure of subbands *sb1* and *sb2* which should be
@@ -99,25 +105,28 @@ def confidence(sb1, sb2):
np.concatenate((sb2[-1: ,:1], sb2[-1: ,:], sb2[-1: ,-1:]), axis=1),
), axis=0)
+ us3_abs, vs3_abs = _pow3(np.abs(us)), _pow3(np.abs(vs))
+ prod2_abs = _pow2(np.abs(np.conj(us) * vs))
+
# pixels at -1, -1
region = (slice(0,-2), slice(0,-2))
- numerator += np.power(np.abs(np.conj(us[region]) * vs[region]), 2)
- denominator += np.power(np.abs(us[region]), 3) + np.power(np.abs(vs[region]), 3)
+ numerator += prod2_abs[region]
+ denominator += us3_abs[region] + vs3_abs[region]
# pixels at +1, -1
region = (slice(0,-2), slice(2,None))
- numerator += np.power(np.abs(np.conj(us[region]) * vs[region]), 2)
- denominator += np.power(np.abs(us[region]), 3) + np.power(np.abs(vs[region]), 3)
+ numerator += prod2_abs[region]
+ denominator += us3_abs[region] + vs3_abs[region]
# pixels at -1, +1
region = (slice(2,None), slice(0,-2))
- numerator += np.power(np.abs(np.conj(us[region]) * vs[region]), 2)
- denominator += np.power(np.abs(us[region]), 3) + np.power(np.abs(vs[region]), 3)
+ numerator += prod2_abs[region]
+ denominator += us3_abs[region] + vs3_abs[region]
# pixels at +1, +1
region = (slice(2,None), slice(2,None))
- numerator += np.power(np.abs(np.conj(us[region]) * vs[region]), 2)
- denominator += np.power(np.abs(us[region]), 3) + np.power(np.abs(vs[region]), 3)
+ numerator += prod2_abs[region]
+ denominator += us3_abs[region] + vs3_abs[region]
return numerator / denominator
--
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