[python-dtcwt] 90/497: fix ext_mode behaviour
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Tue Jul 21 18:05:52 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 c43ac3e64fd96f2c6d3323b3261e93114825d89c
Author: Rich Wareham <rjw57 at cam.ac.uk>
Date: Fri Aug 9 15:30:30 2013 +0100
fix ext_mode behaviour
Some sizes of input were not successfully inverse-transforming.
---
dtcwt/transform3d.py | 37 +++++++++++++++++++++++++++++--------
1 file changed, 29 insertions(+), 8 deletions(-)
diff --git a/dtcwt/transform3d.py b/dtcwt/transform3d.py
index b614483..788910d 100644
--- a/dtcwt/transform3d.py
+++ b/dtcwt/transform3d.py
@@ -139,7 +139,7 @@ def dtwaveifm3(Yl, Yh, biort=DEFAULT_BIORT, qshift=DEFAULT_QSHIFT, ext_mode=4):
if level == nlevels-1: # non-obviously this is the 'first' level
Yl = _level1_ifm(Yl, Yh[-level-1], g0o, g1o)
else:
- Yl = _level2_ifm(Yl, Yh[-level-1], g0a, g0b, g1a, g1b, ext_mode, Yh[-level][0].shape[:3])
+ Yl = _level2_ifm(Yl, Yh[-level-1], g0a, g0b, g1a, g1b, ext_mode, Yh[-level-2].shape)
return Yl
@@ -387,13 +387,34 @@ def _level2_ifm(Yl, Yh, g0a, g0b, g1a, g1b, ext_mode, prev_level_size):
y = work[:, f, :].T
work[:, f, :] = (colifilt(y[s2a, :], g0b, g0a) + colifilt(y[s2b, :], g1b, g1a)).T
- # FIXME: Original dtcwt3dC_xa.m has a comment to this effect but,
- # unfortunately, I can't trigger the need for this behaviour:
- #
- # Now check if the size of the previous level is exactly twice the size
- # of the current level. If YES, this means we have not done the extension
- # in the previous level. If NO, then we have to remove the appended row /
- # column / frame from the previous level DTCWT coefs.
+ # Now check if the size of the previous level is exactly twice the size of
+ # the current level. If YES, this means we have not done the extension in
+ # the previous level. If NO, then we have to remove the appended row /
+ # column / frame from the previous level DTCWT coefs.
+
+ prev_level_size = np.asarray(prev_level_size)
+ curr_level_size = np.asarray(Yh.shape)
+
+ if ext_mode == 4:
+ if curr_level_size[0] * 2 != prev_level_size[0]:
+ # Discard the top and bottom rows
+ work = work[1:-1,:,:]
+ if curr_level_size[1] * 2 != prev_level_size[1]:
+ # Discard the top and bottom rows
+ work = work[:,1:-1,:]
+ if curr_level_size[2] * 2 != prev_level_size[2]:
+ # Discard the top and bottom rows
+ work = work[:,:,1:-1]
+ elif ext_mode == 8:
+ if curr_level_size[0] * 2 != prev_level_size[0]:
+ # Discard the top and bottom rows
+ work = work[2:-2,:,:]
+ if curr_level_size[1] * 2 != prev_level_size[1]:
+ # Discard the top and bottom rows
+ work = work[:,2:-2,:]
+ if curr_level_size[2] * 2 != prev_level_size[2]:
+ # Discard the top and bottom rows
+ work = work[:,:,2:-2]
return work
--
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