[62fbef]: wavelets / ifwt.m  Maximize  Restore  History

Download this file

133 lines (108 with data), 3.1 kB

  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
function f = ifwt(c,g,varargin)
%IFWT Inverse Fast Wavelet Transform
% Usage: f = ifwt(c,g)
% f = ifwt(c,g,Ls,...)
%
% Input parameters:
% c : Coefficients stored in J+1 cell-array or in packed format.
% g : Synthesis wavelet filters.
% Ls : Length of the reconstructed signal.
%
%
% Output parameters:
% f : Reconstructed data.
%
% The following flags are supported:
%
% 'dec','undec'
% Type of the wavelet transform.
%
% 'per','zpd','sym','symw','asym','asymw','ppd','sp0'
% Type of the boundary handling.%
%
%
% See also:
%
% Demos:
%
% References:
% AUTHOR : Zdenek Prusa.
% TESTING: TEST_IFWT
% REFERENCE: REF_IFWT
if nargin<2
error('%s: Too few input parameters.',upper(mfilename));
end;
%% PARSE INPUT
definput.keyvals.Ls=[];
definput.import = {'fwt'};
if(iscell(c))
[flags,kv,Ls]=ltfatarghelper({'Ls'},definput,varargin);
else
error('%s: Unrecognized coefficient format.',upper(mfilename));
end
%% CHECK INPUT
do_definedfb = 0;
if(iscell(g))
if( length(g)<2)
error('%s: h is expected to be a cell array containing two or more wavelet filters.',upper(mfilename));
end
for ii=2:numel(g)
if(length(g{1})~=length(g{ii}))
error('%s: Wavelet filters have to have equal length.',upper(mfilename));
end
end
if(length(g{1})< 2)
error('%s: Wavelet filters should have at least two coefficients.',upper(mfilename));
end
elseif(isstruct(g))
do_definedfb = 1;
elseif(ischar(g))
g = waveletfb(g);
do_definedfb = 1;
else
error('%s: Unrecognized Wavelet filters definition.',upper(mfilename));
end
if(do_definedfb)
% if type ws not defined use
if(flags.do_type_null)
flags.type = g.type;
end
if(flags.do_ext_null)
flags.ext = g.ext;
end
g = g.g;
else
% manually setting defaults
if(flags.do_type_null)
flags.type = 'dec';
end
if(flags.do_ext_null)
flags.ext = 'per';
end
end
% Determine J from number of elements of c
[cR cC] = size(c);
J = cR-1;
if isempty(Ls)
% Estimate output signal length from the number of coefficients
[sigHalfLen,W] = size(c{end});
% for 'undec' the Ls can be estimated exactly
if(strcmp(flags.type,'undec'))
if(strcmp(flags.ext,'per'))
Ls = sigHalfLen;
else
Ls = sigHalfLen - (length(g{1})-1);
end
elseif(strcmp(flags.type,'dec'))
if(strcmp(flags.ext,'per'))
% estimated Ls can be one sample more, if the original input
% signal length was odd
Ls = 2*sigHalfLen;
else
% estimated Ls can be one sample more, if the original input
% signal length plus length(h{1})-1 was an even number
Ls = 2*sigHalfLen - (length(g{1})-2);
end
end
end
f = comp_ifwt_all(c,g,J,Ls,flags.type,flags.ext);

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks