def recompose(self, coeffs, img): if self.dec == wtutils.uiwt: coeffs = [k[0] for k in coeffs] return wtutils.waverec(coeffs, self.wavelet, self.boundary, self.rec, img.shape, thread=self.thread) else: return wtutils.waverec2d(coeffs, self.wavelet, self.boundary, self.rec, img.shape, thread=self.thread)
def do_wavedec(dec, inv): for w in get_all_orthos_wavelets(): for b_wt, b_pywt in get_all_boundaries(): s = nputils.random_walk(maxn=np.random.randint(500, 2000)) level = np.random.randint(3, 8) res = wtutils.wavedec(s, w, level=level, boundary=b_wt, dec=dec) rs = wtutils.waverec(res, w, boundary=b_wt, rec=inv) assert_equal(rs, s)
def test_wavdec(): for w in get_all_orthos_wavelets(): for b_wt, b_pywt in get_all_boundaries(): s = nputils.random_walk(maxn=np.random.randint(500, 2000)) level = np.random.randint(3, 8) res = wtutils.wavedec(s, w, level=level, boundary=b_wt) rese = pywt.wavedec(s, w, mode=b_pywt, level=level) for d, de in zip(res, rese[::-1]): assert_equal(d, de) rs = wtutils.waverec(res, w, boundary=b_wt) rse = pywt.waverec(rese, w, mode=b_pywt) assert_equal(rs, rse) if len(s) % 2 == 0: assert_equal(rs, s) else: assert_equal(rs[:-1], s, atol=1e-5, rtol=1e-3)