I'm trying to get started with the LTFAT toolbox for Matlab/Octave?
It is easy to get the wavelet and scaling coefficients of a signal
[c,info] = fwt(signal,'sym8',8);
but I don't know how I can get the corresponding "approximations" and "details"...I guess they can be obtained since when you run
plotwavelets(c,info)
they are plotted (the "subbands" d1,d2,...,a5)
Anyone familiar with this toolbox?
UPDATE: I asked in the LTFAT mailing list and they helped me out here (credit goes to Nicki Holighaus). Just in case someone stumbles on this...
LTFAT doesn't have a specific function yielding the approximations and details from the corresponding coefficients, but can be easily computed using the inverse DWT: you just need to reconstruct the signal setting everything to zero except the coefficients whose corresponding details/approximations you want to obtain. This code is working for me
% the DWT coefficients are split according to the different levels
cellCoeffs = wavpack2cell(c,info.Lc);
% number of "bands", including the approximations and all the details
nBands = length(info.Lc);
% a cell array containing the coefficients of the DWT (in the form required by "wavcell2pack") for the reconstruction
emptyCellCoeffs = cell(nBands,1);
% the cell corresponding to each "band" is set to a vector of zeros of the appropriate length
for i=1:nBands
emptyCellCoeffs{i} = zeros(info.Lc(i),1);
end
% it will contain the aproximations and details
res = zeros(nBands,length(signal));
for i=1:nBands
% a copy of the coefficients for the reconstruction with everything set to zero...
aux = emptyCellCoeffs;
% ...except the coefficients for the corresponding level
aux{i} = cellCoeffs{i};
% inverse DWT after turning the cell representation back into a vector
res(i,:) = ifwt(wavcell2pack(aux),info);
end
error = sum(sum(res,1) - signal')
You can probably do better in terms of efficiency...but I think this is easy to understand.
Cheers!