1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
|
function f=iuwpfbt(c,par,varargin)
%-*- texinfo -*-
%@deftypefn {Function} iuwpfbt
%@verbatim
%IUWPFBT Inverse Undecimated Wavelet Packet Filterbank Tree
% Usage: f=iuwpfbt(c,info);
% f=iuwpfbt(c,wt);
%
% Input parameters:
% c : Coefficients stored in L xM matrix.
% info,wt : Transform parameters struct/Wavelet tree definition.
%
% Output parameters:
% f : Reconstructed data.
%
% f = IUWPFBT(c,info) reconstructs signal f from the wavelet packet
% coefficients c using parameters from info struct. both returned by
% the UWPFBT function.
%
% f = IUWPFBT(c,wt) reconstructs signal f from the wavelet packet
% coefficients c using the undecimated wavelet filterbank tree
% described by wt.
%
% Please see help for WFBT description of possible formats of wt.
%
% Filter scaling:
% ---------------
%
% As in UWPFBT, the function recognizes three flags controlling scaling
% of filters:
%
% 'sqrt'
% Each filter is scaled by 1/sqrt(a), there a is the hop
% factor associated with it. If the original filterbank is
% orthonormal, the overall undecimated transform is a tight
% frame.
% This is the default.
%
% 'noscale'
% Uses filters without scaling.
%
% 'scale'
% Each filter is scaled by 1/a.
%
% If 'noscale' is used, 'scale' must have been used in UWPFBT (and vice
% versa) in order to obtain a perfect reconstruction.
%
% Scaling of intermediate outputs:
% --------------------------------
%
% The following flags control scaling of the intermediate coefficients.
% The intermediate coefficients are outputs of nodes which ale also
% inputs to nodes further in the tree.
%
% 'intsqrt'
% Each intermediate output is scaled by 1/sqrt(2).
% If the filterbank in each node is orthonormal, the overall
% undecimated transform is a tight frame.
% This is the default.
%
% 'intnoscale'
% No scaling of intermediate results is used.
%
% 'intscale'
% Each intermediate output is scaled by 1/2.
%
% If 'intnoscale' is used, 'intscale' must have been used in UWPFBT
% (and vice versa) in order to obtain a perfect reconstruction.
%
% Examples:
% ---------
%
% A simple example showing perfect reconstruction using the "full
% decomposition" wavelet tree:
%
% f = greasy;
% J = 7;
% wtdef = {'db10',J,'full'};
% c = uwpfbt(f,wtdef);
% fhat = iuwpfbt(c,wtdef);
% % The following should give (almost) zero
% norm(f-fhat)
%
%
%@end verbatim
%@strong{Url}: @url{http://ltfat.github.io/doc/wavelets/iuwpfbt.html}
%@seealso{wfbt, wfbtinit}
%@end deftypefn
% Copyright (C) 2005-2016 Peter L. Soendergaard <peter@sonderport.dk>.
% This file is part of LTFAT version 2.3.1
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
complainif_notenoughargs(nargin,2,'IUWPFBT');
if isempty(c) || ~isnumeric(c)
error('%s: Unrecognized coefficient format.',upper(mfilename));
end
if(isstruct(par)&&isfield(par,'fname'))
complainif_toomanyargs(nargin,2,'IUWPFBT');
if ~strcmpi(par.fname,'uwpfbt')
error(['%s: Wrong func name in info struct. The info parameter ',...
'was created by %s.'],upper(mfilename),par.fname);
end
wt = wfbtinit({'dual',par.wt},par.fOrder);
scaling = par.scaling;
interscaling = par.interscaling;
% Use the "oposite" scaling of intermediate node outputs
if strcmp(interscaling,'intscale')
interscaling = 'intnoscale';
elseif strcmp(interscaling,'intnoscale')
interscaling = 'intscale';
end
% Use the "oposite" scaling of filters
if strcmp(scaling,'scale')
scaling = 'noscale';
elseif strcmp(scaling,'noscale')
scaling = 'scale';
end
else
definput.import = {'wfbtcommon','uwfbtcommon'};
definput.flags.interscaling = {'intsqrt', 'intscale', 'intnoscale'};
[flags]=ltfatarghelper({},definput,varargin);
scaling = flags.scaling;
interscaling = flags.interscaling;
% Initialize the wavelet tree structure
wt = wfbtinit(par,flags.forder);
end
wtPath = fliplr(nodeBForder(0,wt));
[pOutIdxs,chOutIdxs] = treeWpBFrange(wt);
nodesUps = nodesFiltUps(wtPath,wt);
f = comp_iuwpfbt(c,wt.nodes(wtPath),nodesUps,pOutIdxs,chOutIdxs,scaling,...
interscaling);
|