[python-dtcwt] 429/497: registration: improve performance of 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 110a9e32bdee22f732f23e7e750bd02196a26ec2
Author: Rich Wareham <rjw57 at cam.ac.uk>
Date:   Fri Mar 28 13:46:24 2014 +0000

    registration: improve performance of confidence()
    
    Instead of using the sampling routines to simply shuffle matrices,
    perform the shuffling ourselves explicitly.
---
 dtcwt/registration.py | 53 +++++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 47 insertions(+), 6 deletions(-)

diff --git a/dtcwt/registration.py b/dtcwt/registration.py
index ea898e5..448c4c9 100644
--- a/dtcwt/registration.py
+++ b/dtcwt/registration.py
@@ -89,12 +89,53 @@ def confidence(sb1, sb2):
 
     numerator, denominator = 0, 1e-6
 
-    for dx, dy in ((-1,-1), (-1,1), (1,-1), (1,1)):
-        us = dtcwt.sampling.sample(sb1, xs+dx, ys+dy, method='nearest')
-        vs = dtcwt.sampling.sample(sb2, xs+dx, ys+dy, method='nearest')
-
-        numerator += np.power(np.abs(np.conj(us) * vs), 2)
-        denominator += np.power(np.abs(us), 3) + np.power(np.abs(vs), 3)
+    # pixels at -1, -1
+    us = np.vstack((
+        np.hstack((sb1[ :1,:1 ], sb1[:1 ,:-1])),
+        np.hstack((sb1[:-1,:1 ], sb1[:-1,:-1]))
+    ))
+    vs = np.vstack((
+        np.hstack((sb2[ :1,:1 ], sb2[:1 ,:-1])),
+        np.hstack((sb2[:-1,:1 ], sb2[:-1,:-1]))
+    ))
+    numerator += np.power(np.abs(np.conj(us) * vs), 2)
+    denominator += np.power(np.abs(us), 3) + np.power(np.abs(vs), 3)
+
+    # pixels at +1, -1
+    us = np.vstack((
+        np.hstack((sb1[ :1,1: ], sb1[:1 ,-1:])),
+        np.hstack((sb1[:-1,1: ], sb1[:-1,-1:]))
+    ))
+    vs = np.vstack((
+        np.hstack((sb2[ :1,1: ], sb2[:1 ,-1:])),
+        np.hstack((sb2[:-1,1: ], sb2[:-1,-1:]))
+    ))
+    numerator += np.power(np.abs(np.conj(us) * vs), 2)
+    denominator += np.power(np.abs(us), 3) + np.power(np.abs(vs), 3)
+
+    # pixels at -1, +1
+    us = np.vstack((
+        np.hstack((sb1[ 1:,:1 ], sb1[ 1:,:-1])),
+        np.hstack((sb1[-1:,:1 ], sb1[-1:,:-1]))
+    ))
+    vs = np.vstack((
+        np.hstack((sb2[ 1:,:1 ], sb2[ 1:,:-1])),
+        np.hstack((sb2[-1:,:1 ], sb2[-1:,:-1]))
+    ))
+    numerator += np.power(np.abs(np.conj(us) * vs), 2)
+    denominator += np.power(np.abs(us), 3) + np.power(np.abs(vs), 3)
+
+    # pixels at +1, +1
+    us = np.vstack((
+        np.hstack((sb1[ 1:,1: ], sb1[ 1:,-1:])),
+        np.hstack((sb1[-1:,1: ], sb1[-1:,-1:]))
+    ))
+    vs = np.vstack((
+        np.hstack((sb2[ 1:,1: ], sb2[ 1:,-1:])),
+        np.hstack((sb2[-1:,1: ], sb2[-1:,-1:]))
+    ))
+    numerator += np.power(np.abs(np.conj(us) * vs), 2)
+    denominator += np.power(np.abs(us), 3) + np.power(np.abs(vs), 3)
 
     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