DiscreteWaveletPacketTransform[data]
gives the discrete wavelet packet transform (DWPT) of an array of data.
DiscreteWaveletPacketTransform[data,wave]
gives the discrete wavelet packet transform using the wavelet wave.
DiscreteWaveletPacketTransform[data,wave,r]
gives the discrete wavelet packet transform using r levels of refinement.
DiscreteWaveletPacketTransform
DiscreteWaveletPacketTransform[data]
gives the discrete wavelet packet transform (DWPT) of an array of data.
DiscreteWaveletPacketTransform[data,wave]
gives the discrete wavelet packet transform using the wavelet wave.
DiscreteWaveletPacketTransform[data,wave,r]
gives the discrete wavelet packet transform using r levels of refinement.
Details and Options
- DiscreteWaveletPacketTransform gives a DiscreteWaveletData object.
- Properties of the DiscreteWaveletData dwd can be found using dwd["prop"], and a list of available properties can be found using dwd["Properties"].
- DiscreteWaveletPacketTransform is a generalization of DiscreteWaveletTransform where the full tree of wavelet coefficients is computed.
- The data can be any of the following:
-
list arbitrary-rank numerical array image arbitrary Image object audio an Audio or sampled Sound object - The resulting wavelet coefficients are arrays of the same depth as the input data.
- The possible wavelet wave include:
-
BattleLemarieWavelet[…] Battle–Lemarié wavelets based on B-spline BiorthogonalSplineWavelet[…] B-spline-based wavelet CoifletWavelet[…] symmetric variant of Daubechies wavelets DaubechiesWavelet[…] the Daubechies wavelets HaarWavelet[…] classic Haar wavelet MeyerWavelet[…] wavelet defined in the frequency domain ReverseBiorthogonalSplineWavelet[…] B-spline-based wavelet (reverse dual and primal) ShannonWavelet[…] sinc function-based wavelet SymletWavelet[…] least asymmetric orthogonal wavelet - The default wave is HaarWavelet[].
- With higher settings for the refinement level r, larger-scale features are resolved.
- The default refinement level r is given by
, where
is the minimum dimension of data. - With refinement level Full, r is given by
. - The tree of wavelet coefficients at level
consists of coarse coefficients
and detail coefficients
with
representing the input data. - The forward transform is given by
,
,
, and
. - The inverse transform is given by
. - The
are lowpass filter coefficients and
are highpass filter coefficients that are defined for each wavelet family. - The dimensions of
and
are given by
where
is the input data dimension and fl is the filter length for the corresponding wspec. - The following options can be given:
-
Method Automatic method to use Padding "Periodic" how to extend data beyond boundaries WorkingPrecision MachinePrecision precision to use in internal computations - The settings for Padding are the same as available in ArrayPad.
- InverseWaveletTransform gives the inverse transform.
- By default, InverseWaveletTransform uses coefficients represented by dwd["BasisIndex"] for reconstruction. Use WaveletBestBasis to compute and set an optimal basis.
Examples
open all close allBasic Examples (3)
Compute a wavelet packet transform:
dwd = DiscreteWaveletPacketTransform[{0, 0, 1, 0, 0}]The resulting DiscreteWaveletData represents a full tree of wavelet coefficients:
dwd["TreeView"]The inverse transform reconstructs the input:
InverseWaveletTransform[dwd]a = Audio["ExampleData/rule30.wav"]dwd = DiscreteWaveletPacketTransform[a, Automatic, 2]Use dwd[…,"Audio"] to extract coefficient signals:
dwd[All, "Audio"]Compute the inverse transform:
InverseWaveletTransform[dwd]Transform an Image object:
dwd = DiscreteWaveletPacketTransform[[image], Automatic, 2]Use dwd[…,"Image"] to extract coefficient images:
dwd[All, "Image"]Compute the inverse transform:
InverseWaveletTransform[dwd]Scope (34)
Basic Uses (5)
Useful properties can be extracted from the DiscreteWaveletData object:
dwd = DiscreteWaveletPacketTransform[RandomReal[1, {16}], DaubechiesWavelet[4], 2]Get a full list of properties:
dwd["Properties"]Get data and coefficient dimensions:
dwd["DataDimensions"]dwd["Dimensions"]Use Normal to get all wavelet coefficients explicitly:
dwd = DiscreteWaveletPacketTransform[Range[5]];Normal[dwd]Also use All as an argument to get all coefficients:
dwd[All]Use Automatic to get only the coefficients used in the inverse transform:
dwd[Automatic]Use the "TreeView" or "IndexMap" to find out what wavelet coefficients are available:
dwd = DiscreteWaveletPacketTransform[Range[5]];dwd["TreeView"]dwd["IndexMap"]Extract specific coefficient arrays:
dwd[{0}]dwd[{0, 0}]Extract several wavelet coefficients corresponding to a list of wavelet index specifications:
dwd[{{0}, {0, 1}}]Extract all coefficients whose wavelet indexes match a pattern:
dwd[{_}]dwd[{{_, 0}, {_, 1}}]Use WaveletBestBasis to compute an optimal basis of wavelet packet coefficients:
dwd = DiscreteWaveletPacketTransform[Table[Sin[x ^ 2], {x, 0, 10, 0.2}]];dwd = WaveletBestBasis[dwd]Highlight the best basis in a block grid of all coefficients:
dwd["BestBasisBlockView"]Extract the best basis using "BasisIndex":
dwd["BasisIndex"]The computed best basis is used by default in functions like WaveletListPlot:
WaveletListPlot[dwd]Use a higher refinement level to increase the frequency resolution:
data = Table[Sin[x ^ 2] + RandomReal[{-0.2, 0.2}], {x, 0, 10, 0.02}];ListLinePlot[data]With a smaller refinement level, more of the signal energy is left in {0,0}:
dwd1 = DiscreteWaveletPacketTransform[data, DaubechiesWavelet[4], 2];WaveletListPlot[dwd1, PlotLayout -> "CommonYAxis"]With further refinement, {0,0} is resolved into further components:
dwd2 = DiscreteWaveletPacketTransform[data, DaubechiesWavelet[4], 3];WaveletListPlot[dwd2, PlotLayout -> "CommonYAxis"]Wavelet Families (10)
Compute the wavelet packet transform using different wavelet families:
data = Table[Sin[x ^ 2], {x, 0, 10, 0.02}];dwd1 = DiscreteWaveletPacketTransform[data, DaubechiesWavelet[4], 3];
dwd2 = DiscreteWaveletPacketTransform[data, SymletWavelet[4], 3];{WaveletListPlot[dwd1], WaveletListPlot[dwd2]}Use different families of wavelets to capture different features:
data = Table[4 Exp[-100 (t - 0.5) ^ 2] + Sin[5Pi t], {t, 0, 1, 0.01}];ListLinePlot[data]HaarWavelet (default):
dwd = DiscreteWaveletPacketTransform[data, HaarWavelet[], 3];WaveletListPlot[dwd, All, PlotLayout -> "CommonYAxis", Filling -> Axis]data = Table[4 Exp[-100 (t - 0.5) ^ 2] + Sin[5Pi t], {t, 0, 1, 0.01}];dwd = DiscreteWaveletPacketTransform[data, DaubechiesWavelet[2], 3];WaveletListPlot[dwd, All, PlotLayout -> "CommonYAxis", Filling -> Axis]data = Table[4 Exp[-100 (t - 0.5) ^ 2] + Sin[5Pi t], {t, 0, 1, 0.01}];dwd = DiscreteWaveletPacketTransform[data, BattleLemarieWavelet[3], 3];WaveletListPlot[dwd, All, PlotLayout -> "CommonYAxis", Filling -> Axis]data = Table[4 Exp[-100 (t - 0.5) ^ 2] + Sin[5Pi t], {t, 0, 1, 0.01}];dwd = DiscreteWaveletPacketTransform[data, BiorthogonalSplineWavelet[4, 2], 3];WaveletListPlot[dwd, All, PlotLayout -> "CommonYAxis", Filling -> Axis]data = Table[4 Exp[-100 (t - 0.5) ^ 2] + Sin[5Pi t], {t, 0, 1, 0.01}];dwd = DiscreteWaveletPacketTransform[data, CoifletWavelet[2], 3];WaveletListPlot[dwd, All, PlotLayout -> "CommonYAxis", Filling -> Axis]data = Table[4 Exp[-100 (t - 0.5) ^ 2] + Sin[5Pi t], {t, 0, 1, 0.01}];dwd = DiscreteWaveletPacketTransform[data, MeyerWavelet[3], 3];WaveletListPlot[dwd, All, PlotLayout -> "CommonYAxis", Filling -> Axis]ReverseBiorthogonalSplineWavelet:
data = Table[4 Exp[-100 (t - 0.5) ^ 2] + Sin[5Pi t], {t, 0, 1, 0.01}];dwd = DiscreteWaveletPacketTransform[data, ReverseBiorthogonalSplineWavelet[4, 2], 3];WaveletListPlot[dwd, All, PlotLayout -> "CommonYAxis", Filling -> Axis]data = Table[4 Exp[-100 (t - 0.5) ^ 2] + Sin[5Pi t], {t, 0, 1, 0.01}];dwd = DiscreteWaveletPacketTransform[data, ShannonWavelet[8], 3];WaveletListPlot[dwd, All, PlotLayout -> "CommonYAxis", Filling -> Axis]data = Table[4 Exp[-100 (t - 0.5) ^ 2] + Sin[5Pi t], {t, 0, 1, 0.01}];dwd = DiscreteWaveletPacketTransform[data, SymletWavelet[3], 3];WaveletListPlot[dwd, All, PlotLayout -> "CommonYAxis", Filling -> Axis]Vector Data (6)
Plot the coefficients over a common horizontal axis using WaveletListPlot:
dwd = DiscreteWaveletPacketTransform[Table[Sin[x ^ 2], {x, 0, 10, 0.02}], Automatic, 3];WaveletListPlot[dwd, FrameTicks -> Full]Plot against a common vertical axis:
WaveletListPlot[dwd, PlotLayout -> "CommonYAxis"]Visualize coefficients as a function of time and refinement level using WaveletScalogram:
dwd = DiscreteWaveletPacketTransform[Table[Sin[20x] + Sin[10x], {x, 1, 10, 0.01}]];The coefficient indexes appear as tooltips when the mouse pointer is moved over a coefficient:
WaveletScalogram[dwd, All]WaveletScalogram of the best tree representation of the data:
WaveletScalogram[WaveletBestBasis[dwd]]data = Table[1, {x, 0, 10, 0.02}];ListLinePlot[data]All coefficients are small except coarse coefficients {0,0,…}:
dwd = DiscreteWaveletPacketTransform[data, DaubechiesWavelet[4], 3];WaveletListPlot[dwd, All, PlotLayout -> "CommonYAxis"]Data oscillating at the highest resolvable frequency (Nyquist frequency):
data = Table[(-1)^n, {n, 80}];ListLinePlot[data]Only the first detail coefficient {1} and its coarse child coefficients {1,0,0,…} are not small:
dwd = DiscreteWaveletPacketTransform[data, Automatic, 3];WaveletListPlot[dwd, All, PlotLayout -> "CommonYAxis"]Data with large discontinuities:
data = Table[Piecewise[{{1, 1 < x < 3.1}}, 0], {x, 0, 4, 0.02}];ListLinePlot[data]Coarse coefficients {0,…} have the same large-scale structure as the data:
dwd = DiscreteWaveletPacketTransform[data, Automatic, 3];WaveletListPlot[dwd, {0..}, FrameTicks -> Full]Detail coefficients are sensitive to discontinuities:
WaveletListPlot[dwd, Except[{0..}]]Data with both spatial and frequency structure:
data = Table[Piecewise[{{5, n <= 30}, {2 + (-1)^n, Inequality[30, Less, n, LessEqual, 60]}, {5, 60 < n}}], {n, 90}];ListLinePlot[data, PlotRange -> {0, 5}]Coarse coefficients {0,…} track the local mean of the data:
dwd = DiscreteWaveletPacketTransform[data, Automatic, 3];WaveletListPlot[dwd, {0..}, FrameTicks -> Full]First detail coefficient {1} and its coarse child coefficients {1,0,…} represent the oscillations:
WaveletListPlot[dwd, {1, 0...}, FrameTicks -> Full]All coefficients on a common vertical axis:
WaveletListPlot[dwd, All, PlotLayout -> "CommonYAxis"]Matrix Data (5)
Compute a two-dimensional wavelet packet transform:
dwd = DiscreteWaveletPacketTransform[(| | | | | |
| - | - | - | - | - |
| 0 | 0 | 1 | 0 | 0 |
| 0 | 1 | 1 | 1 | 0 |
| 1 | 1 | 1 | 1 | 1 |
| 0 | 1 | 1 | 1 | 0 |
| 0 | 0 | 1 | 0 | 0 |)]View the tree of wavelet coefficients:
dwd[{"TreeView", Center}]Inverse transform to get back the original signal:
InverseWaveletTransform[dwd]//Chop//MatrixFormUse WaveletMatrixPlot to visualize the different wavelet coefficients:
dwd = DiscreteWaveletPacketTransform[DiamondMatrix[32], Automatic, 2]WaveletMatrixPlot[dwd, ImageSize -> Small]WaveletMatrixPlot of best tree representation:
WaveletMatrixPlot[WaveletBestBasis[dwd], ImageSize -> Small]In two dimensions, the vector of filtering operations in each direction can be computed:
Tuples[{0, 1}, 2] /. {0 -> "lowpass", 1 -> "highpass"}Interpreting these vectors as binary digit expansions results in wavelet index numbers:
FromDigits[#, 2]& /@ Tuples[{0, 1}, 2]Get the lowpass and highpass filters for a Haar wavelet:
{lp, hp} = Map[Last, WaveletFilterCoefficients[HaarWavelet[], {"PrimalLowpass", "PrimalHighpass"}], {2}]The resulting 2D filters are outer products of filters in the two directions:
Apply[KroneckerProduct, Tuples[{lp, hp}, 2], {1}]Map[MatrixPlot, %]Wavelet transform of step data:
step[{a_, b_, c_, d_}] :=
ArrayFlatten[{{ConstantArray[a, {3, 3}], ConstantArray[b, {3, 5}]}, {ConstantArray[c, {5, 3}], ConstantArray[d, {5, 5}]}}];Data with a vertical discontinuity:
MatrixPlot[step[{0, 1, 0, 1}], FrameTicks -> False]All horizontal and diagonal detail coefficients, wavelet index {___,2|3,___}, are zero:
WaveletMatrixPlot[DiscreteWaveletPacketTransform[step[{0, 1, 0, 1}]], ImageSize -> Small]Data with horizontal discontinuity:
MatrixPlot[step[{0, 0, 1, 1}], FrameTicks -> False]All vertical and diagonal detail coefficients, wavelet index {___,1|3,___}, are zero:
WaveletMatrixPlot[DiscreteWaveletPacketTransform[step[{0, 0, 1, 1}]], ImageSize -> Small]Data with diagonal discontinuity:
MatrixPlot[Reverse@IdentityMatrix[8], FrameTicks -> False]All horizontal and vertical detail coefficients, wavelet index {___,1|2,___}, are zero:
WaveletMatrixPlot[DiscreteWaveletPacketTransform[Reverse@IdentityMatrix[8]], ImageSize -> Small]Array Data (2)
Compute a three-dimensional wavelet packet transform:
data = RandomReal[1, {16, 16, 16}];dwd = DiscreteWaveletPacketTransform[data, Automatic, 2]Block grid view of all coefficients:
dwd["BestBasisBlockView"]Inverse transform to get back the original signal:
Norm[Flatten[data - InverseWaveletTransform[dwd]]]//ChopWavelet transform of a three-dimensional cross array:
data = CrossMatrix[All, {8, 8, 8}];Graphics3D[{StandardRed, Cuboid /@ Position[data, 1]}]dwd = DiscreteWaveletPacketTransform[data, Automatic, 2]Visualize lowpass wavelet coefficients {___,0}:
Table[i -> Graphics3D[{If[Positive[Extract[dwd[i][[1, 2]], #]], StandardRed, StandardGreen], Cuboid[#]}& /@ Position[dwd[i][[1, 2]], u_ /; Abs[u] > 0], PlotRange -> Automatic], {i, Cases[dwd["IndexMap"], {___, 0}]}]Energy of the original data is conserved within the transformed coefficients:
Total[Flatten[data]^2] == Total[Flatten[dwd[Automatic][[All, 2]]]^2]Image Data (3)
Transform an Image object:
img = Image[DiamondMatrix[All, {64, 64}]]dwd = DiscreteWaveletPacketTransform[img, HaarWavelet[], 3]The inverse transform yields a reconstructed Image object:
InverseWaveletTransform[dwd]Wavelet coefficients are normally given as lists of data for each image channel:
dwd = DiscreteWaveletPacketTransform[[image], HaarWavelet[], 2];Dimensions[{1, 1} /. dwd[{1, 1}]]Get all coefficients as Image objects instead:
dwd[All, {"Image"}]Get raw Image objects with no rescaling of color levels:
dwd[All, {"Image", "ImageFunction" -> Identity}]Get the inverse transform of the {0,1} coefficient as an Image object:
dwd[{0, 1}, {"Image", "Inverse"}]Compute a best tree of coefficients from a packet transform of image data:
dwd = DiscreteWaveletPacketTransform[[image], HaarWavelet[], 4];best = WaveletBestBasis[dwd]Plot the best tree in a hierarchical grid using WaveletImagePlot:
WaveletImagePlot[best, ImageSize -> Medium]Sound Data (3)
Transform a Sound object:
snd = ExampleData[{"Sound", "Apollo11ReturnSafely"}]dwd = DiscreteWaveletPacketTransform[snd]The inverse transform yields a reconstructed Sound object:
InverseWaveletTransform[dwd]By default, coefficients are given as lists of data for each sound channel:
dwd = DiscreteWaveletPacketTransform[ExampleData[{"Sound", "PianoScale"}]];Dimensions[{1, 1} /. dwd[{1, 1}]]Get the {1,1} coefficient as a Sound object:
dwd[{1, 1}, "Sound"]Inverse transform of {1,1} coefficient as a Sound object:
dwd[{1, 1}, {"Sound", "Inverse"}]Compute a best tree of coefficients from a packet transform of sound data:
dwd = DiscreteWaveletPacketTransform[ExampleData[{"Sound", "Clarinet"}]];best = WaveletBestBasis[dwd]Browse the best tree coefficients using a MenuView:
MenuView[best[Automatic, "Sound"]]Generalizations & Extensions (3)
DiscreteWaveletPacketTransform works on arrays of symbolic quantities:
dwd = DiscreteWaveletPacketTransform[{a, b, c, d}, WorkingPrecision -> ∞];Normal[dwd]//SimplifyInverse transform recovers the input exactly:
InverseWaveletTransform[dwd]//SimplifySpecify any internal working precision:
dwd = DiscreteWaveletPacketTransform[{1, 2, 5, 2}, WorkingPrecision -> 20];Normal[dwd]data = Exp[I RandomReal[1, 4]];dwd = DiscreteWaveletPacketTransform[data]The wavelets coefficients are complex:
dwd[Automatic]Options (5)
Padding (2)
The settings for Padding are the same as the methods for ArrayPad, including "Periodic":
ArrayPad[{a, b, c}, 4, "Periodic"]ArrayPad[{a, b, c}, 4, "Reversed"]ArrayPad[{a, b, c}, 4, "ReversedNegation"]ArrayPad[{a, b, c}, 4, "Reflected"]ArrayPad[{a, b, c}, 3, "ReflectedDifferences"]ArrayPad[{a, b, c}, 4, "ReversedDifferences"]ArrayPad[{a, b, c}, 3, "Extrapolated"]Padding can remove boundary effects:
data = Table[UnitStep[x], {x, -2, 2, 4 / 255}];ListLinePlot[data]Use the default "Periodic" padding:
dwt1 = DiscreteWaveletPacketTransform[data, DaubechiesWavelet[2], 3];WaveletListPlot[dwt1]"Extrapolated" padding lessens boundary effects for nonperiodic data:
dwt2 = DiscreteWaveletPacketTransform[data, DaubechiesWavelet[2], 3, Padding -> "Extrapolated"];WaveletListPlot[dwt2]WorkingPrecision (3)
By default, WorkingPrecision->MachinePrecision is used:
data = RandomInteger[1, {10}];dwd1 = DiscreteWaveletPacketTransform[data]dwd2 = DiscreteWaveletPacketTransform[data, WorkingPrecision -> MachinePrecision]dwd1 == dwd2Use higher-precision computation:
data = {0, 0, 1, 1};dwd = Normal@DiscreteWaveletPacketTransform[data, Automatic, 2, WorkingPrecision -> 25]With numbers close to zero, accuracy is the better indicator of the number of correct digits:
{Precision[dwd], Accuracy[dwd]}Use WorkingPrecision->∞ for exact computation:
data = RandomInteger[10, {4}];Normal@DiscreteWaveletPacketTransform[data, WorkingPrecision -> ∞]//SimplifyApplications (3)
Best Tree Analysis (2)
The default reconstruction tree contains the coefficients at the maximum refinement level:
dwd = DiscreteWaveletPacketTransform[Table[Piecewise[{{5, n <= 30}, {2 + (-1)^n, Inequality[30, Less, n, LessEqual, 60]}, {5, 60 < n}}], {n, 90}]];dwd["BestBasisBlockView"]Choose a reconstruction tree with energy concentrated in a small number of coefficients:
best = WaveletBestBasis[dwd]best["BestBasisBlockView"]Plot the best tree coefficients against a common vertical axis:
WaveletListPlot[best, PlotLayout -> "CommonYAxis"]Visualize default reconstruction tree coefficients for image data:
dwd = DiscreteWaveletPacketTransform[[image], Automatic];WaveletImagePlot[dwd, ImageSize -> Small]Compute the reconstruction tree whose coefficients have the smallest total log energy:
best = WaveletBestBasis[dwd, "ShannonEntropy"]WaveletImagePlot[best, ImageSize -> Small]Compression (1)
Lossless compression of matrix data:
data = DiskMatrix[All, {12, 12}];MatrixPlot[data, FrameTicks -> None]In the best tree wavelet packet representation many coefficients are zero:
dwd = WaveletBestBasis[DiscreteWaveletPacketTransform[data]];WaveletMatrixPlot[dwd, ImageSize -> Small]Count nonzero coefficients as a measure of compressed size:
Count[Last /@ dwd[Automatic], Except[0.], {3}]Nonzero values in original data:
Count[data, Except[0], {2}]Times@@Dimensions[data]Properties & Relations (11)
DiscreteWaveletPacketTransform computes the full tree of wavelet coefficients:
dwpt = DiscreteWaveletPacketTransform[{1, 1, 3, 1, 1}];dwpt[{"TreeView", Left}]DiscreteWaveletTransform computes a subset of the full tree of coefficients:
dwt = DiscreteWaveletTransform[{1, 1, 3, 1, 1}];dwt[{"TreeView", Left}]DiscreteWaveletPacketTransform coefficients halve in length with each level of refinement:
Normal[DiscreteWaveletPacketTransform[{1, 2, 3, 4}]]Rotated data gives different coefficients:
Normal[DiscreteWaveletPacketTransform[{2, 3, 4, 1}]]StationaryWaveletPacketTransform coefficients have the same length as the original data:
Normal[StationaryWaveletPacketTransform[{1, 2, 3, 4}]]Rotated data gives rotated coefficients:
Normal[StationaryWaveletPacketTransform[{2, 3, 4, 1}]]Multidimensional discrete wavelet transform is related to one-dimensional packet transform:
dwt = DiscreteWaveletTransform[(| | |
| - | - |
| a | b |
| c | d |), WorkingPrecision -> ∞];Simplify[dwt[Automatic]]dwpt = DiscreteWaveletPacketTransform[{a, b, c, d}, WorkingPrecision -> ∞];Simplify[dwpt[Automatic]]For Haar wavelet (default) and data length
, the computed coefficients are identical:
Flatten[Sort[Last /@ dwt[Automatic]]] == Flatten[Sort[Last /@ dwpt[Automatic]]]The default refinement is given by Min[Round[Log2[Min[Dimensions[data]]]],4]:
data = RandomReal[1, {100}];r = Min[Round[Log2[Min[Dimensions[data]]]], 4]DiscreteWaveletPacketTransform[data] == DiscreteWaveletPacketTransform[data, Automatic, r]data = RandomReal[1, {100, 10, 10}];r = Min[Round[Log2[Min[Dimensions[data]]]], 4]DiscreteWaveletPacketTransform[data] == DiscreteWaveletPacketTransform[data, Automatic, r]The energy norm is conserved for orthogonal wavelet families:
data = RandomReal[1, {100}];dwt = DiscreteWaveletPacketTransform[data, Padding -> 0.];Norm[data] == Norm[Flatten[Last /@ dwt[Automatic]]]The energy norm is approximately conserved for biorthogonal wavelet families:
data = RandomReal[1, {100}];dwt = DiscreteWaveletPacketTransform[data, BiorthogonalSplineWavelet[2, 4], Padding -> 0.];Norm[data]Norm[Flatten[Last /@ dwt[Automatic]]]The mean of the data is captured at the maximum refinement level of the transform:
data = RandomReal[1, {64}];dwt = DiscreteWaveletPacketTransform[data, HaarWavelet[], Full];Extract the coefficient for the maximum refinement level:
r = dwt["Refinement"]dwt[ConstantArray[0, {r}]]Compensate for the
normalization at each refinement level:
%[[1, 2, 1]] / (Sqrt[2])^rMean[data]The sum of inverse transforms from individual coefficient arrays gives the original data:
data = Table[DiscreteDelta[n], {n, -2, 2}]dwd = DiscreteWaveletPacketTransform[data];dwd["TreeView"]Individually inverse transform each wavelet coefficient array:
data1 = InverseWaveletTransform[dwd, Automatic, {0, 0}]data2 = InverseWaveletTransform[dwd, Automatic, {0, 1}]data3 = InverseWaveletTransform[dwd, Automatic, {1, 0}]data4 = InverseWaveletTransform[dwd, Automatic, {1, 1}]The sum gives the original data:
data1 + data2 + data3 + data4HaarWavelet corresponds to averaging (lowpass filter) and differencing (highpass filter):
low[v_] := Partition[v, 2].{(1/Sqrt[2]), (1/Sqrt[2])}
high[v_] := Partition[v, 2].{(1/Sqrt[2]), -(1/Sqrt[2])}HaarWaveletTransform[v_] := {{0} -> low[v], {1} -> high[v]};Compute {0} and {1} wavelet coefficients:
HaarWaveletTransform[{a, b, c, d}]Compare with DiscreteWaveletPacketTransform:
DiscreteWaveletPacketTransform[{a, b, c, d}, HaarWavelet[], 1, WorkingPrecision -> ∞][All]In two dimensions a separate filter is applied in each dimension:
f2d[fx_, fy_] := Composition[Map[fy, #]&, Map[fx, #]&]Lowpass and highpass filters for Haar wavelet:
low[v_] := Partition[v, 2].{(1/Sqrt[2]), (1/Sqrt[2])}
high[v_] := Partition[v, 2].{(1/Sqrt[2]), -(1/Sqrt[2])}Haar wavelet transform of matrix data:
data = Table[Sin[x y], {x, -2, 2, 4 / 63}, {y, -2, 2, 4 / 63}];Table[MatrixPlot[f2d[fx, fy][data], PlotLabel -> {fx, fy}, FrameTicks -> None], {fx, {low, high}}, {fy, {low, high}}]//FlattenCompare with DiscreteWaveletPacketTransform using HaarWavelet:
dwd = DiscreteWaveletPacketTransform[data, HaarWavelet[], 1];Table[MatrixPlot[Last[p], PlotLabel -> First[p], FrameTicks -> None], {p, Normal[dwd]}]Image channels are transformed individually:
dwds = Map[DiscreteWaveletPacketTransform, ColorSeparate[[image]]]Combine {0} coefficients of separately transformed image channels:
w = Image[Table[First[{0} /. Normal[t]], {t, dwds}], Interleaving -> False]Compare with {0} coefficient of DiscreteWaveletPacketTransform of original image:
dwd = DiscreteWaveletPacketTransform[[image]];{0} /. dwd[All, {"Image", "ImageFunction" -> Identity}]ImageSubtract[w, %]Possible Issues (1)
Padding can affect the total energy of wavelet coefficients:
data = RandomReal[1, {10}];dwd1 = DiscreteWaveletPacketTransform[data, DaubechiesWavelet[4], Padding -> "Fixed"];{Norm[data]^2, Norm[Flatten[Last /@ dwd1[Automatic]]]^2}Pad with 0s to ensure energy conservation in the coefficients:
dwd2 = DiscreteWaveletPacketTransform[data, DaubechiesWavelet[4], Padding -> 0];{Norm[data]^2, Norm[Flatten[Last /@ dwd2[Automatic]]]^2}Related Guides
Text
Wolfram Research (2010), DiscreteWaveletPacketTransform, Wolfram Language function, https://reference.wolfram.com/language/ref/DiscreteWaveletPacketTransform.html (updated 2017).
CMS
Wolfram Language. 2010. "DiscreteWaveletPacketTransform." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2017. https://reference.wolfram.com/language/ref/DiscreteWaveletPacketTransform.html.
APA
Wolfram Language. (2010). DiscreteWaveletPacketTransform. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DiscreteWaveletPacketTransform.html
BibTeX
@misc{reference.wolfram_2026_discretewaveletpackettransform, author="Wolfram Research", title="{DiscreteWaveletPacketTransform}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/DiscreteWaveletPacketTransform.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_discretewaveletpackettransform, organization={Wolfram Research}, title={DiscreteWaveletPacketTransform}, year={2017}, url={https://reference.wolfram.com/language/ref/DiscreteWaveletPacketTransform.html}, note=[Accessed: 13-June-2026]}