MCPcopy Create free account
hub / github.com/PyWavelets/pywt / waverec2

Function waverec2

pywt/_multilevel.py:256–337  ·  view source on GitHub ↗

Multilevel 2D Inverse Discrete Wavelet Transform. coeffs : list or tuple Coefficients list [cAn, (cHn, cVn, cDn), ... (cH1, cV1, cD1)] wavelet : Wavelet object or name string, or 2-tuple of wavelets Wavelet to use. This can also be a tuple containing a wavelet to

(coeffs, wavelet, mode='symmetric', axes=(-2, -1))

Source from the content-addressed store, hash-verified

254
255
256def waverec2(coeffs, wavelet, mode='symmetric', axes=(-2, -1)):
257 """
258 Multilevel 2D Inverse Discrete Wavelet Transform.
259
260 coeffs : list or tuple
261 Coefficients list [cAn, (cHn, cVn, cDn), ... (cH1, cV1, cD1)]
262 wavelet : Wavelet object or name string, or 2-tuple of wavelets
263 Wavelet to use. This can also be a tuple containing a wavelet to
264 apply along each axis in ``axes``.
265 mode : str or 2-tuple of str, optional
266 Signal extension mode, see :ref:`Modes <ref-modes>`. This can
267 also be a tuple containing a mode to apply along each axis in ``axes``.
268 axes : 2-tuple of ints, optional
269 Axes over which to compute the IDWT. Repeated elements are not allowed.
270
271 Returns
272 -------
273 2D array of reconstructed data.
274
275 Notes
276 -----
277 It may sometimes be desired to run ``waverec2`` with some sets of
278 coefficients omitted. This can best be done by setting the corresponding
279 arrays to zero arrays of matching shape and dtype. Explicitly removing
280 list or tuple entries or setting them to None is not supported.
281
282 Specifically, to ignore all detail coefficients at level 2, one could do::
283
284 coeffs[-2] == tuple([np.zeros_like(v) for v in coeffs[-2]])
285
286 Examples
287 --------
288 >>> import pywt
289 >>> import numpy as np
290 >>> coeffs = pywt.wavedec2(np.ones((4,4)), 'db1')
291 >>> # Levels:
292 >>> len(coeffs)-1
293 2
294 >>> pywt.waverec2(coeffs, 'db1')
295 array([[ 1., 1., 1., 1.],
296 [ 1., 1., 1., 1.],
297 [ 1., 1., 1., 1.],
298 [ 1., 1., 1., 1.]])
299 """
300 if not isinstance(coeffs, (list, tuple)):
301 raise ValueError("Expected sequence of coefficient arrays.")
302
303 if len(axes) != len(set(axes)):
304 raise ValueError("The axes passed to waverec2 must be unique.")
305
306 if len(coeffs) < 1:
307 raise ValueError(
308 "Coefficient list too short (minimum 1 array required).")
309 elif len(coeffs) == 1:
310 # level 0 transform (just returns the approximation coefficients)
311 return coeffs[0]
312
313 a, ds = coeffs[0], coeffs[1:]

Callers

nothing calls this directly

Calls 1

idwt2Function · 0.85

Tested by

no test coverage detected