1function [Lc,L]=fwtclength(Ls,w,J,varargin) 2%-*- texinfo -*- 3%@deftypefn {Function} fwtclength 4%@verbatim 5%FWTCLENGTH FWT subbands lengths from a signal length 6% Usage: Lc=fwtclength(Ls,w,J); 7% [Lc,L]=fwtclength(...); 8% 9% Lc=FWTCLENGTH(Ls,w,J) returns the lengths of the wavelet coefficient 10% subbands for a signal of length Ls. Please see the help on FWT for 11% an explanation of the parameters w and J. 12% 13% [Lc,L]=FWTCLENGTH(...) additianally the function returns the next 14% legal length of the input signal for the given extension type. 15% 16% The function support the same boundary-handling flags as the FWT 17% does. 18% 19%@end verbatim 20%@strong{Url}: @url{http://ltfat.github.io/doc/wavelets/fwtclength.html} 21%@seealso{fwt, fwtlength} 22%@end deftypefn 23 24% Copyright (C) 2005-2016 Peter L. Soendergaard <peter@sonderport.dk>. 25% This file is part of LTFAT version 2.3.1 26% 27% This program is free software: you can redistribute it and/or modify 28% it under the terms of the GNU General Public License as published by 29% the Free Software Foundation, either version 3 of the License, or 30% (at your option) any later version. 31% 32% This program is distributed in the hope that it will be useful, 33% but WITHOUT ANY WARRANTY; without even the implied warranty of 34% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 35% GNU General Public License for more details. 36% 37% You should have received a copy of the GNU General Public License 38% along with this program. If not, see <http://www.gnu.org/licenses/>. 39 40% AUTHOR: Zdenek Prusa 41 42complainif_notposint(Ls,'Ls','FWTCLENGTH'); 43complainif_notposint(J,'J','FWTCLENGTH'); 44 45w = fwtinit(w); 46 47definput.import = {'fwtext'}; 48[flags,kv]=ltfatarghelper({},definput,varargin); 49 50% Get the next legal length 51L = fwtlength(Ls,w,J,flags.ext); 52 53filtNo = length(w.g); 54subbNo = (filtNo-1)*J+1; 55Lc = zeros(subbNo,1); 56runPtr = 0; 57levelLen = L; 58if flags.do_per 59 % Non-expansive case 60 for jj=1:J 61 for ff=filtNo:-1:2 62 Lc(end-runPtr) = ceil(levelLen/w.a(ff)); 63 runPtr = runPtr + 1; 64 end 65 levelLen = ceil(levelLen/w.a(1)); 66 end 67% elseif flags.do_valid 68% % Valid coef. case 69% filts = w.g; 70% for jj=1:J 71% for ff=filtNo:-1:2 72% Lc(end-runPtr) = floor((levelLen-(length(filts{ff}.h)-1))/w.a(ff)); 73% runPtr = runPtr + 1; 74% end 75% levelLen = floor((levelLen-(length(filts{1}.h)-1))/w.a(1)); 76% end 77else 78 % Expansive case 79 filts = w.g; 80 for jj=1:J 81 for ff=filtNo:-1:2 82 skip = w.a(ff) - 1; 83 Lc(end-runPtr) = ceil((levelLen+(length(filts{ff}.h)-1)-skip)/w.a(ff)); 84 runPtr = runPtr + 1; 85 end 86 skip = w.a(1) - 1; 87 levelLen = ceil((levelLen+(length(filts{1}.h)-1)-skip)/w.a(1)); 88 end 89end 90Lc(1)=levelLen; 91 92