Ltfat
Ltfat
Peter L. Søndergaard
Peter Balazs
Monika Dörfler
Nicki Holighaus
Florent Jaillet
Nathanael Perraudin
Zdeněk Průša
Kai Siedenburg
Bruno Torrésani
Christoph Wiesmeyr
Jordy van Velthoven
Thibaud Necciari
2
Contents
3
4 CONTENTS
2.3.8 iwmdct2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
2.3.9 wil2rect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
2.3.10 rect2wil . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
2.3.11 wilwin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
2.3.12 dwiltlength . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
2.4 Reconstructing windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
2.4.1 gabdual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
2.4.2 gabtight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
2.4.3 gabfirdual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
2.4.4 gaboptdual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
2.4.5 gabfirtight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
2.4.6 gabopttight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
2.4.7 gabconvexopt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
2.4.8 gabprojdual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
2.4.9 gabmixdual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
2.4.10 wilorth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
2.4.11 wildual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
2.5 Conditions numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
2.5.1 gabframebounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
2.5.2 gabrieszbounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
2.5.3 wilbounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
2.5.4 gabdualnorm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
2.5.5 gabframediag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
2.5.6 wilframediag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
2.6 Phase gradient methods and reassignment . . . . . . . . . . . . . . . . . . . . . . . . . . 56
2.6.1 gabphasegrad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
2.6.2 gabphasederiv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
2.6.3 gabreassign . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
2.6.4 gabreassignadjust . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
2.7 Phase reconstruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
2.7.1 constructphase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
2.7.2 constructphasereal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
2.8 Phase conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
2.8.1 phaselock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
2.8.2 phaseunlock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
2.8.3 phaselockreal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
2.8.4 phaseunlockreal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
2.8.5 symphase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
2.9 Support for non-separable lattices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
2.9.1 matrix2latticetype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
2.9.2 latticetype2matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
2.9.3 shearfind . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
2.9.4 noshearlength . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
2.10 Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
2.10.1 tfplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
2.10.2 plotdgt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
2.10.3 plotdgtreal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
2.10.4 plotdwilt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
2.10.5 plotwmdct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
2.10.6 sgram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
2.10.7 gabimagepars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
2.10.8 resgram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
2.10.9 instfreqplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
2.10.10 phaseplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
CONTENTS 5
ltfatstart;
Description
ltfatstart starts the LTFAT toolbox. This command must be run before using any of the functions in
the toolbox.
To configure default options for functions, you can use the ltfatsetdefaults function in your startup script.
A typical startup file could look like:
addpath(’/path/to/my/work/ltfat’);
ltfatstart;
ltfatsetdefaults(’sgram’,’nocolorbar’);
This will add the main LTFAT directory to you path, start the toolbox, and configure sgram to not display
the colorbar.
The function walks the directory tree and adds a subdirectory to path if the directory contain a [subdirectory,init.m]
script setting a status variable to some value greater than 0. status==1 identifies a toolbox module
any other value just a directory to be added to path.
ltfatstart(0) supresses any status messages.
The function indirectly calls clear all, which clears all your global and persistent variables. It comes
with calling javaaddpath in blockproc/blockprocinit.m. You can avoid calling it by passing additional
’nojava’ flag.
ltfatstop;
Description
13
14 CHAPTER 1. LTFAT - BASE ROUTINES
Description
ltfathelp displays some general help on the LTFAT toolbox.
ltfathelp(’version’) returns the version number.
ltfathelp(’modules’) returns a cell array of installed modules and corresponding version num-
bers.
Description
ltfatmex compiles the C backend in order to speed up the execution of the toolbox. The C backend
is linked to Matlab and Octave through Mex and Octave C++ interfaces. Please see INSTALL-Matlab or
INSTALL-Octave for the requirements.
The action of ltfatmex is determined by one of the following flags:
’test’ Run some small tests that verify that the compiled functions work.
’gpc’ Perform action on the GPC code for use with MULACLAB
’auto’ Choose automatically which targets to work on from the previous ones
based on the operation system etc. This is the default.
’playrec’ Perform action on the playrec code for use with real-time block stream-
ing framework.
’java’ Perform compilation of JAVA classes into the bytecode. The classes
makes the GUI for the blockproc. framework.
Other:
’debug’ Build a debug version. This will disable compiler optimizations and include debug
symbols.
1.2. PARAMETER HANDLING 15
Description
ltfatbasepath returns the top level directory in which the LTFAT files are installed.
Description
isoctave returns 1 if the operating environment is Octave, otherwise it returns 0 (Matlab)
Input parameters
posdepnames Names of the position dependant parameters.
Output parameters
flags Struct with information about flags.
Description
[flags,keyvals]=ltfatarghelper(posdepnames,definput,arglist) assists in parsing
input parameters for a function in LTFAT. Parameters come in four categories:
∙ Position dependant parameters. These must not be strings. These are the first parameters passed to a
function, and they are really just a short way of specifying key/value pairs. See below.
∙ Flags. These are single string appearing after the position dependant parameters.
∙ Key/value pairs. The key is always a string followed by the value, which can be anything.
∙ Expansions. These appear as flags, that expand into a pre-defined list of parameters. This is a short-
hand way of specifying standard sets of flags and key/value pairs.
16 CHAPTER 1. LTFAT - BASE ROUTINES
The parameters are parsed in order, so parameters appearing later in varargin will override previously
set values.
The following example for calling ltfatarghelper is taken from dgt:
definput.keyvals.L=[];
definput.flags.phase={’freqinv’,’timeinv’};
[flags,kv]=ltfatarghelper({’L’},definput,varargin);
The first line defines a key/value pair with the key ’L’ having an initial value of [] (the empty matrix).
The second line defines a group of flags by the name of phase. The group phase contains the flags
’freqinv’ and ’timeinv’, which can both be specified on the command line by the user. The group-
name phase is just for internal use, and does not appear to the user. The flag mentioned first in the list
will be selected by default, and only one flag in a group can be selected at any time. A group can contain as
many flags as desired.
The third line is the actual call to ltfatarghelper which defines the output flags and kv. The
input {’L’} indicates that the value of the parameter ’L’ can also be given as the very first value in
varargin.
The output struct kv contains the key/value pairs, so the value associated to ’L’ is stored in kv.L.
The output struct flags contains information about the flags choosen by the user. The value of
flags.phase will be set to the selected flag in the group phase and additionally, the value of flags.do_timeinv
will be 1 if ’timeinv’ was selected and 0 otherwise, and similarly for ’freqinv’. This allows for easy
checking of selected flags.
Description
[...]=scalardistribute(...) copies the input parameters to the output parameters.
∙ If one of the input parameters is an array, all the output parameters will be column vectors containing
the same number of elements. If one of the other input parameters is a scalar, it will be replicated to
the correct length. This allows a scalar value to be repeated for all conditions.
∙ If two or more input parameters are arrays, the must have the exact same size. They will be converted
to vectors and returned in the output parameters. This allows two arrays to co-vary at the same time.
This operator is usefull for sanitizing input parameters: The user is allowed to enter scalars or arrays
as input paremeters. These input are in turn passed to scalardistribute, which makes sure that the
arrays have the same shape, and that scalars are replicated. The user of scalardistibute can now
generate conditions based on all the parameters, and be sure the have the right sizes.
As an example, consider:
[a,b,c]=scalardistribute(1,[2,3],[4,5])
1.3. GRAPHICAL USER INTERFACES 17
1
1
b =
2
3
c =
4
5
Description
When starting the interface, the user is asked to choose the processed signal, named original signal in the
interface. Possible signals are .wav files and .mat files containing decompositions preliminarily saved
using the mulaclab interface. The interface only handles monochannel signals. So for a multichannel
.wav files, the first channel is used as the original signal.
After choosing the original signal, the user is presented with the main interface. This interface is divided
in two areas:
∙ The right part of the figure contains the visualizations, which represent the spectrograms of the orig-
inal and modified signals.
The ’Original signal’ visualization is used to display the original signal spectrogram and to graphi-
cally define the symbol of the Gabor multiplier that will be applied on this signal.
The ’Overview of original signal’ visualization also represents the original signal spectrogram and
can be used for fast zooming and moving of the other visualizations. Zooming and moving is con-
trolled by mouse interaction with the white rectangle displayed on this visualization.
The ’Modified signal’ visualization is used to display the spectrogram of the modified signal after
application of the multiplier.
It is possible to hide the ’Overview of original signal’ and ’Modified signal’ visulizations using the
’Visualization’ menu.
∙ The left part of the figure contains panels with tools for user interaction.
The ’Audioplayer’ panel contains the controls for audio playback of the original and modified signal.
The ’Visualization’ panel contains tools used to adapt the display of the visualizations.
The ’Selection’ panel contains tools and information concerning the multilayered selection used to
graphically specify the symbol of the multiplier.
Known Matlab limitations:
18 CHAPTER 1. LTFAT - BASE ROUTINES
∙ When using Matlab on Linux with multiple screens, there might be a Matlab bug preventing the
display of the multiplier symbol. This can be solved by docking the figure.
∙ When using a Matlab version prior to 7.3 (R2006b), the rectangle displayed on the ’Overview of
original signal’ visualization is not automatically updated when using the zoom and pan tools of the
’Zoom’ panel. It can be manually updated by re-clicking on the currently selected tool or by changing
the current tool.
The Matlab Image Processing Toolbox is required by the mulaclab function.
MULACLAB uses the GPC library available from http://www.cs.man.ac.uk/~toby/gpc/.
This library is distributed alongside LTFAT, but under different licensing conditions. Please see the ltfat/thirdparty/gpc/
file for the exact conditions.
Chapter 2
Description
tconv(f,g) computes the twisted convolution of the square matrices f and g.
Let h=tconv(f,g) for f,g being L × L matrices. Then h is given by
L−1 L−1
h (m + 1, n + 1) = ∑ ∑ f (k + 1, l + 1) g (m − k + 1, n − l + 1) e−2πi(m−k)l/L
l=0 k=0
where m − k and n − l are computed modulo L.
If both f and g are of class sparse then h will also be a sparse matrix. The number of non-zero
elements of h is usually much larger than the numbers for f and g. Unless f and g are very sparse, it can be
faster to convert them to full matrices before calling tconv.
The routine ?? can be used to calculate an inverse convolution. Define h and r by:
h=tconv(f,g);
r=tconv(spreadinv(f),h);
then r is equal to g.
Description
dsft(F) computes the discrete symplectic Fourier transform of F. F must be a matrix or a 3D array. If F
is a 3D array, the transformation is applied along the first two dimensions.
Let F be a K × L matrix. Then the DSFT of F is given by
1 L−1 K−1
C (m + 1, n + 1) = √ ∑ ∑ F (k + 1, l + 1) e2πi(kn/K−lm/L)
KL l=0 k=0
for m = 0, . . . , L − 1 and n = 0, . . . , K − 1.
The dsft is its own inverse.
References: [31]
19
20 CHAPTER 2. LTFAT - GABOR ANALYSIS
c=zak(f,a);
Description
zak(f,a) computes the Zak transform of f with parameter a. The coefficients are arranged in an a × L/a
matrix, where L is the length of f.
If f is a matrix then the transformation is applied to each column. This is then indexed by the third
dimension of the output.
Assume that c = zak( f , a), where f is a column vector of length L and N = L/a. Then the following
holds for m = 0, . . . , a − 1 and n = 0, . . . , N − 1
1 N−1
c(m + 1, n + 1) = √ ∑ f (m − ka + 1)e2πink/M
N k=0
Examples:
This figure shows the absolute value of the Zak-transform of a Gaussian. Notice that the Zak-transform is
0 in only a single point right in the middle of the plot
a=64;
L=a^2;
g=pgauss(L);
zg=zak(g,a);
surf(abs(zg));
This figure shows the absolute value of the Zak-transform of a 4th order Hermite function. Notice how
the Zak transform of the Hermite functions is zero on a circle centered on the corner
a=64;
L=a^2;
g=pherm(L,4);
zg=zak(g,a);
surf(abs(zg));
2.1. BASIC TIME/FREQUENCY ANALYSIS 21
Description
izak(c) computes the inverse Zak transform of c. The parameter of the Zak transform is deduced from
the size of c.
References: [47], [16]
Description
col2diag(cin) will rearrange the elements in the square matrix cin so that columns of cin appears as
diagonals. Column number n will appear as diagonal number −n and L − n, where L is the size of the
matrix.
The function is its own inverse.
col2diag performs the underlying coordinate transform for spreading function and Kohn-Nirenberg
calculus in the finite, discrete setting.
Description
s0norm(f) computes the S0 -norm of a vector.
If the input is a matrix or ND-array, the S0 -norm is computed along the first (non-singleton) dimension,
and a vector of values is returned.
22 CHAPTER 2. LTFAT - GABOR ANALYSIS
WARNING: The S0 -norm is computed by computing a full Short-time Fourier transform of a signal,
which can be quite time-consuming. Use this function with care for long signals.
s0norm takes the following flags at the end of the line of input parameters:
’dim’,d Work along specified dimension. The default value of [] means to work
along the first non-singleton one.
’rel’ Return the result relative to the l 2 norm (the energy) of the signal.
Input parameters
f Input data.
g Window function.
M Number of channels.
Output parameters
c M × N array of coefficients.
Description
dgt(f,g,a,M) computes the Gabor coefficients (also known as a windowed Fourier transform) of the
input signal f with respect to the window g and parameters a and M. The output is a vector/matrix in a
rectangular layout.
The length of the transform will be the smallest multiple of a and M that is larger than the signal. f
will be zero-extended to the length of the transform. If f is a matrix, the transformation is applied to each
column. The length of the transform done can be obtained by L=size(c,2)*a;
The window g may be a vector of numerical values, a text string or a cell array. See the help of gabwin
for more details.
dgt(f,g,a,M,L) computes the Gabor coefficients as above, but does a transform of length L. f will
be cut or zero-extended to length L before the transform is done.
[c,Ls]=dgt(f,g,a,M) or [c,Ls]=dgt(f,g,a,M,L) additionally returns the length of the
input signal f. This is handy for reconstruction:
[c,Ls]=dgt(f,g,a,M);
fr=idgt(c,gd,a,Ls);
2.2. GABOR SYSTEMS 23
will reconstruct the signal f no matter what the length of f is, provided that gd is a dual window of g.
[c,Ls,g]=dgt(...) additionally outputs the window used in the transform. This is useful if the
window was generated from a description in a string or cell array.
The Discrete Gabor Transform is defined as follows: Consider a window g and a one-dimensional signal
f of length L and define N = L/a. The output from c=dgt(f,g,a,M) is then given by:
L−1
c (m + 1, n + 1) = ∑ f (l + 1)g(l − an + 1)e−2πilm/M
l=0
Non-separable lattices:
dgt(f,g,a,M,’lt’,lt) computes the DGT for a non-separable lattice given by the time-shift a, num-
ber of channels M and lattice type lt. Please see the help of matrix2latticetype for a precise description of
the parameter lt.
The non-separable discrete Gabor transform is defined as follows: Consider a window g and a one-
dimensional signal f of length L and define N = L/a. The output from c=dgt(f,g,a,M,L,lt) is then
given by:
L−1
c (m + 1, n + 1) = ∑ f (l + 1)g(l − an + 1)e−2πil(m+w(n))/M
l=0
Additional parameters:
dgt takes the following flags at the end of the line of input arguments:
Examples:
In the following example we create a Hermite function, which is a complex-valued function with a circular
spectrogram, and visualize the coefficients using both imagesc and plotdgt:
a=10;
M=40;
L=a*M;
h=pherm(L,4); % 4th order hermite function.
c=dgt(h,’gauss’,a,M);
Input parameters
c Array of coefficients.
g Window function.
a Length of time shift.
Ls Length of signal.
lt Lattice type (for non-separable lattices)
Output parameters
f Signal.
2.2. GABOR SYSTEMS 25
Description
idgt(c,g,a) computes the Gabor expansion of the input coefficients c with respect to the window g and
time shift a. The number of channels is deduced from the size of the coefficients c.
idgt(c,g,a,Ls) does as above but cuts or extends f to length Ls.
[f,g]=idgt(...) additionally outputs the window used in the transform. This is useful if the
window was generated from a description in a string or cell array.
For perfect reconstruction, the window used must be a dual window of the one used to generate the
coefficients.
The window g may be a vector of numerical values, a text string or a cell array. See the help of gabwin
for more details.
If g is a row vector, then the output will also be a row vector. If c is 3-dimensional, then idgt will
return a matrix consisting of one column vector for each of the TF-planes in c.
Assume that f=idgt(c,g,a,L) for an array c of size M × N. Then the following holds for k =
0, . . . , L − 1:
N−1 M−1
f (l + 1) = ∑ ∑ c(m + 1, n + 1)e2πiml/M g(l − an + 1)
n=0 m=0
Non-separable lattices:
idgt(c,g,a,’lt’,lt) computes the Gabor expansion of the input coefficients c with respect to the
window g, time shift a and lattice type lt. Please see the help of matrix2latticetype for a precise description
of the parameter lt.
Assume that f=dgt(c,g,a,L,lt) for an array c of size M × N. Then the following holds for
k = 0, . . . , L − 1:
N−1 M−1
f (l + 1) = ∑ ∑ c(m + 1, n + 1)e2πiml/M g(l − an + 1)
n=0 m=0
Additional parameters:
idgt takes the following flags at the end of the line of input arguments:
’freqinv’ Compute an IDGT using a frequency-invariant phase. This is the de-
fault convention described above.
’timeinv’ Compute an IDGT using a time-invariant phase. This convention is
typically used in FIR-filter algorithms.
Examples:
The following example demostrates the basic pricinples for getting perfect reconstruction (short version):
f=greasy; % test signal
a=32; % time shift
M=64; % frequency shift
gs={’blackman’,128}; % synthesis window
ga={’dual’,gs}; % analysis window
[c,Ls]=dgt(f,ga,a,M); % analysis
r=idgt(c,gs,a,Ls); % synthesis
norm(f-r) % test
This code produces the following output:
26 CHAPTER 2. LTFAT - GABOR ANALYSIS
ans =
5.971590714093986e-15
The following example does the same as the previous one, with an explicit construction of the analysis
and synthesis windows:
% Length of transform to do
L=dgtlength(Ls,a,M);
c=dgt(f,ga,a,M); % analysis
r=idgt(c,gs,a,Ls); % synthesis
norm(f-r) % test
ans =
6.028280895685831e-15
Input parameters
c Array of coefficients.
g Window function.
Ls length of signal.
Output parameters
f Signal.
Description
isgram(s,g,a) attempts to invert a spectrogram computed by
s = abs(dgt(f,g,a,M)).^2;
’tol’,t Stop if relative residual error is less than the specified tolerance.
’printstep’,p If ’print’ is specified, then print every p’th iteration. Default value is
p=10;
The BFGS method makes use of the minFunc software. To use the BFGS method, please install the
minFunc software from: http://www.cs.ubc.ca/~schmidtm/Software/minFunc.html.
Examples:
To reconstruct the phase of ’greasy’, use the following:
d1=abs(theta-theta_r);
d2=2*pi-d1;
anglediff=min(d1,d2);
figure(2);
plotdgt(anglediff,a,16000,’lin’);
colormap(bone);
title(’Difference in angle’);
[f,relres,iter]=isgramreal(...);
Input parameters
c Array of coefficients.
g Window function.
a Length of time shift.
M Number of channels.
Ls length of signal.
Output parameters
f Signal.
relres Vector of residuals.
iter Number of iterations done.
Description
isgramreal(s,g,a,M) attempts to invert a spectrogram computed by
s = abs(dgtreal(f,g,a,M)).^2;
by an iterative method.
isgramreal(s,g,a,M,Ls) does as above but cuts or extends f to length Ls.
If the phase of the spectrogram is known, it is much better to use dgtreal
f,relres,iter]=isgramreal(...) additionally returns the residuals in a vector relres and the
number of iteration steps done.
Generally, if the spectrogram has not been modified, the iterative algorithm will converge slowly to the
correct result. If the spectrogram has been modified, the algorithm is not guaranteed to converge at all.
isgramreal takes the following parameters at the end of the line of input arguments:
’lt’,lt Specify the lattice type. See the help on matrix2latticetype. Only the
rectangular or quinqux lattices can be specified.
’zero’ Choose a starting phase of zero. This is the default
’rand’ Choose a random starting phase.
’int’ Construct a starting phase by integration. Only works for Gaussian
windows.
’griflim’ Use the Griffin-Lim iterative method, this is the default.
’bfgs’ Use the limited-memory Broyden Fletcher Goldfarb Shanno (BFGS)
method.
’tol’,t Stop if relative residual error is less than the specified tolerance.
’maxit’,n Do at most n iterations.
’print’ Display the progress.
’quiet’ Don’t print anything, this is the default.
’printstep’,p If ’print’ is specified, then print every p’th iteration. Default value is
p=10.
The BFGS method makes use of the minFunc software. To use the BFGS method, please install the
minFunc software from: http://www.cs.ubc.ca/~schmidtm/Software/minFunc.html.
References: [39], [27], [59]
30 CHAPTER 2. LTFAT - GABOR ANALYSIS
c=dgt2(f,g,a,M);
c=dgt2(f,g1,g2,[a1,a2],[M1,M2]);
c=dgt2(f,g1,g2,[a1,a2],[M1,M2],[L1,L2]);
[c,Ls]=dgt2(f,g1,g2,[a1,a2],[M1,M2]);
[c,Ls]=dgt2(f,g1,g2,[a1,a2],[M1,M2],[L1,L2]);
Input parameters
Output parameters
c array of coefficients.
Description
dgt2(f,g,a,M) will calculate a separable two-dimensional discrete Gabor transformation of the input
signal f with respect to the window g and parameters a and M.
For each dimension, the length of the transform will be the smallest possible that is larger than the
length of the signal along that dimension. f will be appropriately zero-extended.
dgt2(f,g,a,M,L) computes a Gabor transform as above, but does a transform of length L along
each dimension. f will be cut or zero-extended to length L before the transform is done.
[c,Ls]=dgt2(f,g,a,M) or [c,Ls]=dgt2(f,g,a,M,L) additionally returns the length of the
input signal f. This is handy for reconstruction:
[c,Ls]=dgt2(f,g,a,M);
fr=idgt2(c,gd,a,Ls);
will reconstruct the signal f no matter what the size of f is, provided that gd is a dual window of g.
dgt2(f,g1,g2,a,M) makes it possible to use a different window along the two dimensions.
The parameters a, M, L and Ls can also be vectors of length 2. In this case the first element will be used
for the first dimension and the second element will be used for the second dimension.
The output c has 4 or 5 dimensions. The dimensions index the following properties:
Input parameters
c Array of coefficients.
Output parameters
f Output data, matrix.
Description
idgt2(c,g,a,M) will calculate a separable two dimensional inverse discrete Gabor transformation of
the input coefficients c using the window g and parameters a, along each dimension. The number of
channels is deduced from the size of the coefficients c.
idgt2(c,g1,g2,a) will do the same using the window g1 along the first dimension, and window
g2 along the second dimension.
idgt2(c,g,a,Ls) or idgt2(c,g1,g2,a,Ls) will cut the signal to size Ls after the transfor-
mation is done.
The parameters a and Ls can also be vectors of length 2. In this case the first element will be used for
the first dimension and the second element will be used for the second dimension.
Input parameters
f Input data
g Window function.
M Number of modulations.
Output parameters
c M * N array of coefficients.
Description
dgtreal(f,g,a,M) computes the Gabor coefficients (also known as a windowed Fourier transform) of
the real-valued input signal f with respect to the real-valued window g and parameters a and M. The output
is a vector/matrix in a rectangular layout.
As opposed to dgt only the coefficients of the positive frequencies of the output are returned. dgtreal
will refuse to work for complex valued input signals.
The length of the transform will be the smallest multiple of a and M that is larger than the signal. f
will be zero-extended to the length of the transform. If f is a matrix, the transformation is applied to each
column. The length of the transform done can be obtained by L=size(c,2)*a.
The window g may be a vector of numerical values, a text string or a cell array. See the help of gabwin
for more details.
dgtreal(f,g,a,M,L) computes the Gabor coefficients as above, but does a transform of length L.
f will be cut or zero-extended to length L before the transform is done.
[c,Ls]=dgtreal(f,g,a,M) or [c,Ls]=dgtreal(f,g,a,M,L) additionally returns the length
of the input signal f. This is handy for reconstruction:
[c,Ls]=dgtreal(f,g,a,M);
fr=idgtreal(c,gd,a,M,Ls);
will reconstruct the signal f no matter what the length of f is, provided that gd is a dual window of g.
[c,Ls,g]=dgtreal(...) additionally outputs the window used in the transform. This is useful if
the window was generated from a description in a string or cell array.
See the help on dgt for the definition of the discrete Gabor transform. This routine will return the
coefficients for channel frequencies from 0 to floor(M/2).
dgtreal takes the following flags at the end of the line of input arguments:
dgtreal can be used to manually compute a spectrogram, if you want full control over the parameters
and want to capture the output
Input parameters
c Array of coefficients.
g Window function.
a Length of time shift.
M Number of channels.
Ls length of signal.
Output parameters
f Signal.
Description
idgtreal(c,g,a,M) computes the Gabor expansion of the input coefficients c with respect to the real-
valued window g, time shift a and number of channels M. c is assumed to be the positive frequencies of the
Gabor expansion of a real-valued signal.
It must hold that size(c,1)==floor(M/2)+1. Note that since the correct number of channels
cannot be deduced from the input, idgtreal takes an additional parameter as opposed to idgt.
The window g may be a vector of numerical values, a text string or a cell array. See the help of gabwin
for more details.
idgtreal(c,g,a,M,Ls) does as above but cuts or extends f to length Ls.
[f,g]=idgtreal(...) additionally outputs the window used in the transform. This is usefull if
the window was generated from a description in a string or cell array.
For perfect reconstruction, the window used must be a dual window of the one used to generate the
coefficients.
If g is a row vector, then the output will also be a row vector. If c is 3-dimensional, then idgtreal
will return a matrix consisting of one column vector for each of the TF-planes in c.
See the help on idgt for the precise definition of the inverse Gabor transform.
34 CHAPTER 2. LTFAT - GABOR ANALYSIS
idgtreal takes the following flags at the end of the line of input arguments:
’freqinv’ Use a frequency-invariant phase. This is the default convention de-
scribed in the help for dgt.
’timeinv’ Use a time-invariant phase. This convention is typically used in filter
bank algorithms.
Examples:
The following example demostrates the basic pricinples for getting perfect reconstruction (short version):
f=greasy; % test signal
a=32; % time shift
M=64; % frequency shift
gs={’blackman’,128}; % synthesis window
ga={’dual’,gs}; % analysis window
[c,Ls]=dgtreal(f,ga,a,M); % analysis
r=idgtreal(c,gs,a,M,Ls); % synthesis
norm(f-r) % test
This code produces the following output:
ans =
5.926290334081506e-15
The following example does the same as the previous one, with an explicit construction of the analysis
and synthesis windows:
f=greasy; % test signal
a=32; % time shift
M=64; % frequency shift
Ls=length(f); % signal length
% Length of transform to do
L=dgtlength(Ls,a,M);
c=dgtreal(f,ga,a,M); % analysis
r=idgtreal(c,gs,a,M,Ls); % synthesis
norm(f-r) % test
This code produces the following output:
ans =
6.026604080005277e-15
2.2. GABOR SYSTEMS 35
Description
[g,info]=gabwin(g,a,M,L) computes a window that fits well with the specified number of channels
M, time shift a and transform length L. The window itself is specified by a text description or a cell array
containing additional parameters.
The window can be specified directly as a vector of numerical values. In this case, gabwin only checks
assumptions about transform sizes etc.
[g,info]=gabwin(g,a,M) does the same, but the window must be a FIR window, as the transform
length is unspecified.
gabwin(g,a,M,L,lt) or gabwin(g,a,M,[],lt) does as above but for a non-separable lattice
specified by lt. Please see the help of matrix2latticetype for a precise description of the parameter lt.
The window can be specified as one of the following text strings:
It is also possible to specify one of the window names from firwin as the first field in the cell array. In
this case, the remaining entries of the cell array are passed directly to firwin.
Some examples: To compute a Gaussian window of length L fitted for a system with time-shift a and M
channels use:
g=gabwin(’gauss’,a,M,L);
To compute Gaussian window with equal time and frequency support irrespective of a and M:
g=gabwin({’gauss’,1},a,M,L);
To compute the canonical dual of a Gaussian window fitted for a system with time-shift a and M chan-
nels:
gd=gabwin(’gaussdual’,a,M,L);
To compute the canonical tight window of the Gaussian window fitted for the system:
gd=gabwin({’tight’,’gauss’},a,M,L);
g=gabwin({’dual’,{’hann’,20}},a,M,L);
The structure info provides some information about the computed window:
cout=projkern(cin,a);
cout=projkern(cin,g,a);
cout=projkern(cin,ga,gs,a);
Input parameters
g analysis/synthesis window
ga analysis window
gs synthesis window
Output parameters
Description
cout=projkern(cin,a) projects a set of Gabor coefficients c onto the space of possible Gabor co-
efficients. This means that cin and cout synthesize to the same signal. A tight window generated from a
Gaussian will be used for both analysis and synthesis.
The rationale for this function is a follows: Because the coefficient space of a Gabor frame is larger than
the signal space (since the frame is redundant) then there are many coefficients that correspond to the same
signal.
Therefore, you might desire to work with the coefficients cin, but you are in reality working with cout.
cout=projkern(cin,g,a) does the same, using the window g for analysis and synthesis.
cout=projkern(cin,ga,gs,a) does the same, but for different analysis ga and synthesis gs
windows.
L=dgtlength(Ls,a,M);
L=dgtlength(Ls,a,M,lt);
2.3. WILSON BASES AND WMDCT 37
Description
dgtlength(Ls,a,M) returns the length of a Gabor system that is long enough to expand a signal of
length Ls. Please see the help on dgt for an explanation of the parameters a and M.
If the returned length is longer than the signal length, the signal will be zero-padded by dgt.
A valid transform length must be divisable by both a and M. This means that the minumal admissable
transform length is
Lsmallest = lcm(a,M);
Non-separable lattices:
dgtlength(Ls,a,M,lt) does as above for a non-separable lattice with lattice-type lt. For non-
separable lattices, there is the additinal requirement on the transform length, that the structure of the lattice
must be periodic. This gives a minimal transform length of
Lsmallest = lcm(a,M)*lt(2);
Input parameters
f Input data
g Window function.
M Number of bands.
Output parameters
c 2M × N array of coefficients.
Description
dwilt(f,g,M) computes a discrete Wilson transform with M bands and window g.
The length of the transform will be the smallest possible that is larger than the signal. f will be zero-
extended to the length of the transform. If f is a matrix, the transformation is applied to each column.
The window g may be a vector of numerical values, a text string or a cell array. See the help of wilwin
for more details.
dwilt(f,g,M,L) computes the Wilson transform as above, but does a transform of length L. f will
be cut or zero-extended to length L before the transform is done.
[c,Ls]=dwilt(f,g,M) or [c,Ls]=dwilt(f,g,M,L) additionally return the length of the in-
put signal f. This is handy for reconstruction:
[c,Ls]=dwilt(f,g,M);
fr=idwilt(c,gd,M,Ls);
38 CHAPTER 2. LTFAT - GABOR ANALYSIS
will reconstruct the signal f no matter what the length of f is, provided that gd is a dual Wilson window
of g.
[c,Ls,g]=dwilt(...) additionally outputs the window used in the transform. This is useful if
the window was generated from a description in a string or cell array.
A Wilson transform is also known as a maximally decimated, even-stacked cosine modulated filter bank.
Use the function wil2rect to visualize the coefficients or to work with the coefficients in the TF-plane.
Assume that the following code has been executed for a column vector f :
c=dwilt(f,g,M); % Compute a Wilson transform of f.
N=size(c,2)*2; % Number of translation coefficients.
The following holds for m = 0, . . . , M − 1 and n = 0, . . . , N/2 − 1:
If m = 0:
L−1
c (1, n + 1) = ∑ f (l + 1)g (l − 2nM + 1)
l=0
If m is odd and less than M
√ L−1 m
c (m + 1, n + 1) = 2 ∑ f (l + 1) sin(π l)g(l − 2nM + 1)
l=0 M
√ L−1 m
c (m + M + 1, n + 1) = 2 ∑ f (l + 1) cos(π l)g (l − (2n + 1) M + 1)
l=0 M
If m is even and less than M
√ L−1 m
c (m + 1, n + 1) = 2 ∑ f (l + 1) cos(π l)g(l − 2nM + 1)
l=0 M
√ L−1 m
c (m + M + 1, n + 1) = 2 ∑ f (l + 1) sin(π l)g (l − (2n + 1) M + 1)
l=0 M
if m = M and M is even:
L−1
c (M + 1, n + 1) = ∑ f (l + 1)(−1)l g(l − 2nM + 1)
l=0
else if m = M and M is odd
L−1
c (M + 1, n + 1) = ∑ f (l + 1)(−1)l g (l − (2n + 1) M + 1)
k=0
References: [14], [58], [26]
Input parameters
c 2M × N array of coefficients.
g Window function.
Ls Final length of function (optional)
2.3. WILSON BASES AND WMDCT 39
Output parameters
f Input data
Description
idwilt(c,g) computes an inverse discrete Wilson transform with window g. The number of channels
is deduced from the size of the coefficient array c.
The window g may be a vector of numerical values, a text string or a cell array. See the help of wilwin
for more details.
idwilt(f,g,Ls) does the same, but cuts of zero-extend the final result to length Ls.
[f,g]=idwilt(...) additionally outputs the window used in the transform. This is usefull if the
window was generated from a description in a string or cell array.
References: [14], [58]
Input parameters
f Input data, matrix.
Output parameters
c array of coefficients.
Description
dwilt2(f,g,M) calculates a two dimensional discrete Wilson transform of the input signal f using the
window g and parameter M along each dimension.
For each dimension, the length of the transform will be the smallest possible that is larger than the
length of the signal along that dimension. f will be appropriately zero-extended.
All windows must be whole-point even.
dwilt2(f,g,M,L) computes a Wilson transform as above, but does a transform of length L along
each dimension. f will be cut or zero-extended to length L before the transform is done.
[c,Ls]=dwilt(f,g,M) or [c,Ls]=dwilt(f,g,M,L) additionally returns the length of the
input signal f. This is handy for reconstruction.
c=dwilt2(f,g1,g2,M) makes it possible to use a different window along the two dimensions.
The parameters L, M and Ls can also be vectors of length 2. In this case the first element will be used
for the first dimension and the second element will be used for the second dimension.
The output c has 4 or 5 dimensions. The dimensions index the following properties:
Examples:
The following example visualize the dwilt2 coefficients of a test image. For clarity, only the 50 dB largest
coefficients are show::
c=dwilt2(cameraman,’itersine’,16);
c=reshape(c,256,256);
figure(1);
imagesc(cameraman), colormap(gray), axis(’image’);
figure(2);
cc=dynlimit(20*log10(abs(c)),50);
imagesc(cc), colormap(flipud(bone)), axis(’image’), colorbar;
f=idwilt2(c,g1,g2);
f=idwilt2(c,g1,g2,Ls);
Input parameters
c Array of coefficients.
g, g1, g2 Window functions.
Ls Size of reconstructed signal.
Output parameters
f Output data, matrix.
Description
idwilt2(c,g) calculates a separable two dimensional inverse discrete Wilson transformation of the
input coefficients c using the window g. The number of channels is deduced from the size of the coefficients
c.
idwilt2(c,g1,g2) does the same using the window g1 along the first dimension, and window g2
along the second dimension.
idwilt2(c,g1,g2,Ls) cuts the signal to size Ls after the transformation is done.
Input parameters
f Input data
g Window function.
M Number of bands.
L Length of transform to do.
Output parameters
c M × N array of coefficients.
Ls Length of input signal.
Description
wmdct(f,g,M) computes a Windowed Modified Discrete Cosine Transform with M bands and window
g.
The length of the transform will be the smallest possible that is larger than the signal. f will be zero-
extended to the length of the transform. If f is a matrix, the transformation is applied to each column. g
must be whole-point even.
The window g may be a vector of numerical values, a text string or a cell array. See the help of wilwin
for more details.
wmdct(f,g,M,L) computes the MDCT transform as above, but does a transform of length L. f will
be cut or zero-extended to length L before the transform is done.
[c,Ls]=wmdct(f,g,M) or [c,Ls]=wmdct(f,g,M,L)‘ additionally returns the length of the input sig-
nal f. This is handy for reconstruction:
42 CHAPTER 2. LTFAT - GABOR ANALYSIS
[c,Ls]=wmdct(f,g,M);
fr=iwmdct(c,gd,M,Ls);
will reconstruct the signal f no matter what the length of f is, provided that gd is a dual Wilson window
of g.
[c,Ls,g]=wmdct(...) additionally outputs the window used in the transform. This is useful if
the window was generated from a description in a string or cell array.
The WMDCT is sometimes known as an odd-stacked cosine modulated filter bank. The WMDCT
defined by this routine is slightly different from the most common definition of the WMDCT, in order to be
able to use the same window functions as the Wilson transform.
Assume that the following code has been executed for a column vector f of length L:
c=wmdct(f,g,M); % Compute the WMDCT of f.
N=size(c,2); % Number of translation coefficients.
The following holds for m = 0, . . . , M − 1 and n = 0, . . . , N − 1:
If m + n is even:
√ L−1
π 1 π
c (m + 1, n + 1) = 2 ∑ f (l + 1) cos m+ l+ g(l − nM + 1)
l=0 M 2 4
If m + n is odd:
√ L−1
π 1 π
c (m + 1, n + 1) = 2 ∑ f (l + 1) sin m+ l+ g(l − nM + 1)
l=0 M 2 4
Examples:
The following example shows the WMDCT coefficients (128 channels) of the greasy test signal:
fs=16000; % Sampling rate
c=wmdct(greasy,{’hann’,0.02*fs},128);
plotwmdct(c,fs,90);
Compare the visual difference with the redundant expansion of the same signal given in the example of
the dgtreal function.
References: [73], [74], [64], [15]
Input parameters
c M*N array of coefficients.
g Window function.
Output parameters
f Input data
Description
iwmdct(c,g) computes an inverse windowed MDCT with window g. The number of channels is deduced
from the size of the coefficient array c.
The window g may be a vector of numerical values, a text string or a cell array. See the help of wilwin
for more details.
iwmdct(f,g,Ls) does the same, but cuts or zero-extends the final result to length Ls.
[f,g]=iwmdct(...) additionally outputs the window used in the transform. This is usefull if the
window was generated from a description in a string or cell array.
References: [73], [74], [64], [15]
Input parameters
f Input data, matrix.
Output parameters
c array of coefficients.
Description
wmdct2(f,g,M) calculates a two dimensional Modified Discrete Cosine transform of the input signal f
using the window g and parameter M along each dimension.
For each dimension, the length of the transform will be the smallest possible that is larger than the
length of the signal along that dimension. f will be appropriately zero-extended.
All windows must be whole-point even.
wmdct2(f,g,M,L) computes a 2D windowed MDCT as above, but does a transform of length L
along each dimension. f will be cut or zero-extended to length L before the transform is done.
[c,Ls]=wmdct(f,g,M) or [c,Ls]=wmdct(f,g,M,L) additionally return the length of the in-
put signal f. This is handy for reconstruction.
c=wmdct2(f,g1,g2,M) makes it possible to use different windows along the two dimensions.
44 CHAPTER 2. LTFAT - GABOR ANALYSIS
The parameters L, M and Ls can also be vectors of length 2. In this case the first element will be used
for the first dimension and the second element will be used for the second dimension.
The output c has 4 or 5 dimensions. The dimensions index the following properties:
Input parameters
c Array of coefficients.
Output parameters
f Output data, matrix.
Description
iwmdct2(c,g) calculates a separable two dimensional inverse wmdct transform of the input coefficients
c using the window g. The number of channels is deduced from the size of the coefficients c.
iwmdct2(c,g1,g2) does the same using the window g1 along the first dimension, and window g2
along the second dimension.
iwmdct2(c,g1,g2,Ls) cuts the signal to size Ls after the transform is done.
Description
wil2rect(c) rearranges the coefficients c in a rectangular shape. The coefficients must have been ob-
tained from dwilt. After rearrangement the coefficients are placed correctly on the time/frequency-plane.
The rearranged array is larger than the input array: it contains zeros on the spots where the Wilson
transform is missing a DC or Nyquest component.
Description
rect2wil(c) takes Wilson coefficients processed by wil2rect and puts them back in the compact form
used by dwilt and idwilt. The coefficients can then be processed by idwilt.
Description
[g,info]=wilwin(g,M,L) computes a window that fits well with the specified number of channels
M and transform length L. The window itself is specified by a text description or a cell array containing
additional parameters.
The window can be specified directly as a vector of numerical values. In this case, wilwin only checks
assumptions about transform sizes etc.
[g,info]=wilwin(g,M) does the same, but the window must be a FIR window, as the transform
length is unspecified.
The window can be specified as one of the following text strings:
’gauss’ Gaussian window with optimal concentration
’dualgauss’ Riesz dual of Gaussian window with optimal concentration.
’tight’ Window generating an orthonormal basis
In these cases, a long window is generated with a length of L.
It is also possible to specify one of the window names from firwin. In such a case, wilwin generates
the specified FIR window with a length of M.
The window can also be specified as cell array. The possibilities are:
{’gauss’,...} Additional parameters are passed to PGAUSS
{’dual’,...} Dual window of whatever follows. See the examples below.
{’tight’,...} Orthonormal window of whatever follows.
It is also possible to specify one of the window names from firwin as the first field in the cell array. In
this case, the remaining entries of the cell array are passed directly to firwin.
Some examples:
g=wilwin(’gauss’,M,L);
This computes a Gaussian window of length L fitted for a system with M channels.
g=wilwin({’gauss’,1},M,L);
This computes a Gaussian window with equal time and frequency support irrespective of M.
gd=wilwin(’gaussdual’,M,L);
This computes the dual of a Gaussian window fitted for a system with M channels.
gd=wilwin({’tight’,’gauss’},M,L);
This computes the orthonormal window of the Gaussian window fitted for the system.
g=wilwin({’dual’,{’hann’,20}},M,L);
This computes the dual of a Hann window of length 20.
The structure info provides some information about the computed window:
info.gauss True if the window is a Gaussian.
46 CHAPTER 2. LTFAT - GABOR ANALYSIS
info.tfr Time/frequency support ratio of the window. Set whenever it makes sense.
info.wasrow Input was a row window
info.isfir Input is an FIR window
info.isdual Output is the dual window of the auxiliary window.
info.istight Output is known to be a tight window.
info.auxinfo Info about auxiliary window.
info.gl Length of window.
L=dwiltlength(Ls,M);
Description
dwiltlength(Ls,M) returns the length of a Wilson / WMDCT system with M channels system is long
enough to expand a signal of length Ls. Please see the help on dwilt or wmdct for an explanation of the
parameter M.
If the returned length is longer than the signal length, the signal will be zero-padded by dwilt or wmdct.
A valid transform length must be divisable by 2M. This means that the minumal admissable transform
length is
Lsmallest = 2*M;
gd=gabdual(g,a,M);
gd=gabdual(g,a,M,L);
gd=gabdual(g,a,M,’lt’,lt);
Input parameters
g Gabor window.
M Number of channels.
Output parameters
Description
gabdual(g,a,M) computes the canonical dual window of the discrete Gabor frame with window g and
parameters a, M.
The window g may be a vector of numerical values, a text string or a cell array. See the help of gabwin
for more details.
If the length of g is equal to M, then the input window is assumed to be an FIR window. In this case, the
canonical dual window also has length of M. Otherwise the smallest possible transform length is chosen as
the window length.
gabdual(g,a,M,L) returns a window that is the dual window for a system of length L. Unless the
dual window is a FIR window, the dual window will have length L.
gabdual(g,a,M,’lt’,lt) does the same for a non-separable lattice specified by lt. Please see
the help of matrix2latticetype for a precise description of the parameter lt.
If a > M then the dual window of the Gabor Riesz sequence with window g and parameters a and M
will be calculated.
Examples:
The following example shows the canonical dual window of the Gaussian window:
a=20;
M=30;
L=300;
g=pgauss(L,a*M/L);
gd=gabdual(g,a,M);
% Frequency domain
figure(2);
magresp(gd,’dynrange’,100);
48 CHAPTER 2. LTFAT - GABOR ANALYSIS
Input parameters
g Gabor window.
a Length of time shift.
M Number of modulations.
L Length of window. (optional)
lt Lattice type (for non-separable lattices).
Output parameters
gt Canonical tight window, column vector.
Description
gabtight(a,M,L) computes a nice tight window of length L for a lattice with parameters a, M. The
window is not an FIR window, meaning that it will only generate a tight system if the system length is equal
to L.
gabtight(g,a,M) computes the canonical tight window of the Gabor frame with window g and
parameters a, M.
The window g may be a vector of numerical values, a text string or a cell array. See the help of gabwin
for more details.
If the length of g is equal to M, then the input window is assumed to be a FIR window. In this case, the
canonical dual window also has length of M. Otherwise the smallest possible transform length is chosen as
the window length.
gabtight(g,a,M,L) returns a window that is tight for a system of length L. Unless the input win-
dow g is a FIR window, the returned tight window will have length L.
gabtight(g,a,M,’lt’,lt) does the same for a non-separable lattice specified by lt. Please see
the help of matrix2latticetype for a precise description of the parameter lt.
2.4. RECONSTRUCTING WINDOWS 49
If a > M then an orthonormal window of the Gabor Riesz sequence with window g and parameters a
and M will be calculated.
Examples:
The following example shows the canonical tight window of the Gaussian window. This is calculated by
default by gabtight if no window is specified:
a=20;
M=30;
L=300;
gt=gabtight(a,M,L);
% Frequency domain
figure(2);
magresp(gt,’dynrange’,100);
50 CHAPTER 2. LTFAT - GABOR ANALYSIS
Input parameters
Ldual Length of dual window
g Window function
a Time shift
M Number of Channels
Output parameters
gd Dual window
Description
gabfirdual(Ldual,g,a,M) computes an FIR window gd which is an approximate dual window of
the Gabor system defined by g, a and M. The FIR dual window will be supported on Ldual samples.
This function solve a convex optimization problem that can be written as:
+ ‖ω(x − gl )‖22
Note: This function require the unlocbox. You can download it at http://unlocbox.sourceforge.
net
The function uses an iterative algorithm to compute the approximate FIR dual. The algorithm can be
controlled by the following flags:
’glike’,g_l gl is a windows in time. The algorithm try to shape the dual win-
dow like gl . Normalization of gl is done automatically. To use option
omega should be different from 0. By default gd = 0.
’tol’,t Stop if relative residual error is less than the specified tolerance.
’slow’ Safer algorithm, you can try this if the fast algorithm is not working.
Before using this, try to iterate more.
’printstep’,p If ’print’ is specified, then print every p’th iteration. Default value is
p=10;
Input parameters
g Window function
a Time shift
M Number of Channels
52 CHAPTER 2. LTFAT - GABOR ANALYSIS
Output parameters
gd Dual window
Description
gaboptdual(g,a,M) computes a window gd which is an approximate dual window of the Gabor system
defined by g, a and M.
This function solve a convex optimization problem that can be written as:
+ ‖ω(x − gl )‖22
Note: This function require the unlocbox. You can download it at http://unlocbox.sourceforge.
net
The function uses an iterative algorithm to compute the approximate optimized dual. The algorithm can
be controlled by the following flags:
’alpha’,alpha Weight in time. If it is a scalar, it represent the weights of the entire L1
function in time. If it is a vector, it is the associated weight assotiated
to each component of the L1 norm (length: Ldual). Default value is
α = 0. Warning: this value should not be too big in order to avoid the
the L1 norm proximal operator kill the signal. No L1-time constraint:
α =0
’beta’,beta Weight in frequency. If it is a scalar, it represent the weights of the en-
tire L1 function in frequency. If it is a vector, it is the associated weight
assotiated to each component of the L1 norm in frequency. (length:
Ldual). Default value is β = 0. Warning: this value should not be too
big in order to avoid the the L1 norm proximal operator kill the signal.
No L1-frequency constraint: β = 0
’omega’,omega Weight in time of the L2-norm. If it is a scalar, it represent the weights
of the entire L2 function in time. If it is a vector, it is the associated
weight assotiated to each component of the L2 norm (length: Ldual).
Default value is ω = 0. No L2-time constraint: ω = 0
’glike’,g_l gl is a windows in time. The algorithm try to shape the dual win-
dow like gl . Normalization of gl is done automatically. To use option
omega should be different from 0. By default gd = 0.
’mu’,mu Weight of the smooth constraint Default value is 1. No smooth con-
straint: µ = 0
’gamma’,gamma Weight of the smooth constraint in frequency. Default value is 1. No
smooth constraint: γ = 0
’delta’,delta Weight of the S0-norm. Default value is 0. No S0-norm: δ = 0
’dual’ Look for a dual windows (default)
’painless’ Construct a starting guess using a painless-case approximation. This
is the default
2.4. RECONSTRUCTING WINDOWS 53
Input parameters
Lsupport Length of the tight window
g Initial window function
a Time shift
M Number of Channels
Output parameters
gt Tight window
Description
gabfirtight(Lsupport,g,a,M) computes an FIR window gd which is tight. The FIR dual window
will be supported on Lsupport samples.
This function solve a convex optimization problem that can be written as:
+ ‖ω(x − gl )‖22
Note: This function require the unlocbox. You can download it at http://unlocbox.sourceforge.
net
The function uses an iterative algorithm to compute the approximate FIR tight windows. Warning The
algorithm solve a non convex problem and might be stack in bad local minima. The algorithm can be
controlled by the following flags:
’alpha’,alpha Weight in time. If it is a scalar, it represent the weights of the entire L1
function in time. If it is a vector, it is the associated weight assotiated
to each component of the L1 norm (length: Ldual). Default value is
α = 0. Warning: this value should not be too big in order to avoid the
the L1 norm proximal operator kill the signal. No L1-time constraint:
α =0
’beta’,beta Weight in frequency. If it is a scalar, it represent the weights of the en-
tire L1 function in frequency. If it is a vector, it is the associated weight
assotiated to each component of the L1 norm in frequency. (length:
Ldual). Default value is β = 0. Warning: this value should not be too
big in order to avoid the the L1 norm proximal operator kill the signal.
No L1-frequency constraint: β = 0
’omega’,omega Weight in time of the L2-norm. If it is a scalar, it represent the weights
of the entire L2 function in time. If it is a vector, it is the associated
weight assotiated to each component of the L2 norm (length: Ldual).
Default value is ω = 0. No L2-time constraint: ω = 0
’glike’,g_l gl is a windows in time. The algorithm try to shape the dual win-
dow like gl . Normalization of gl is done automatically. To use option
omega should be different from 0. By default gd = 0.
’mu’,mu Weight of the smooth constraint Default value is 1. No smooth con-
straint: µ = 0
’gamma’,gamma Weight of the smooth constraint in frequency. Default value is 1. No
smooth constraint: γ = 0
’delta’,delta Weight of the S0-norm. Default value is 0. No S0-norm: δ = 0
’dual’ Look for a dual windows (default)
’painless’ Construct a starting guess using a painless-case approximation. This
is the default
’zero’ Choose a starting guess of zero.
’rand’ Choose a random starting phase.
’tol’,t Stop if relative residual error is less than the specified tolerance.
’maxit’,n Do at most n iterations. default 200
’print’ Display the progress.
’debug’ Display all the progresses.
’quiet’ Don’t print anything, this is the default.
’fast’ Fast algorithm, this is the default.
’slow’ Safer algorithm, you can try this if the fast algorithm is not working.
Before using this, try to iterate more.
’printstep’,p If ’print’ is specified, then print every p’th iteration. Default value is
p=10;
’hardconstraint’ Force the projection at the end (default)
’softconstaint’ Do not force the projection at the end
2.4. RECONSTRUCTING WINDOWS 55
Input parameters
g Initial window function
a Time shift
M Number of Channels
Output parameters
gt Tight window
Description
gabopttight(g,a,M) computes a tight window gt for a frame of parameter a and M
This function solves a convex optimization problem that can be written as:
+ ‖ω(x − gl )‖22
Note: This function require the unlocbox. You can download it at http://unlocbox.sourceforge.
net
The function uses an iterative algorithm to compute the approximate optimized tight window. Warning
The algorithm solve a non convex problem and might be stack in bad local minima. The algorithm can be
controlled by the following flags:
’glike’,g_l gl is a windows in time. The algorithm try to shape the dual win-
dow like gl . Normalization of gl is done automatically. To use option
omega should be different from 0. By default gd = 0.
Input parameters
g Window function /initial point (tight case)
a Time shift
M Number of Channels
Output parameters
gout Output window
iter Number of iterations
relres Reconstruction error
2.4. RECONSTRUCTING WINDOWS 57
Description
gabconvexopt(g,a,M) computes a window gout which is the optimal solution of the convex optimiza-
tion problem below
+ ‖ω(x − gl )‖22
’support’ Ldual Add a constraint on the support. The windows should be com-
pactly supported on Ldual.
58 CHAPTER 2. LTFAT - GABOR ANALYSIS
Input parameters
gm Window to project.
g Window function.
a Length of time shift.
M Number of modulations.
L Length of transform to consider
Output parameters
gd Dual window.
Description
gabprojdual(gm,g,a,M) calculates the dual window of the Gabor frame given by g, a and M closest
to gm measured in the l 2 norm. The function projects the suggested window gm onto the subspace of
admissable dual windows, hence the name of the function.
gabprojdual(gm,g,a,M,L) first extends the windows g and gm to length L.
gabprojdual(...,’lt’,lt) does the same for a non-separable lattice specified by lt. Please see
the help of matrix2latticetype for a precise description of the parameter lt.
2.4. RECONSTRUCTING WINDOWS 59
Input parameters
g1 Window 1
g2 Window 2
M Number of modulations.
Output parameters
gammaf Mixdual of window 1.
Description
gabmixdual(g1,g2,a,M) computes a dual window of g1 from a mix of the canonical dual windows
of g1 and g2.
References: [94]
Input parameters
g Auxiliary window window function (optional).
M Number of modulations.
Output parameters
gt Window generating an orthonormal Wilson basis.
Description
wilorth(M,L) computes a nice window of length L generating an orthonormal Wilson or WMDCT basis
with M frequency bands for signals of length L.
wilorth(g,M) computes a window generating an orthonomal basis from the window g and number
of channels M.
The window g may be a vector of numerical values, a text string or a cell array. See the help of wilwin
for more details.
If the length of g is equal to 2 × M, then the input window is assumed to be a FIR window. In this
case, the orthonormal window also has length of 2 × M. Otherwise the smallest possible transform length
is chosen as the window length.
wilorth(g,M,L) pads or truncates g to length L before calculating the orthonormal window. The
output will also be of length L.
60 CHAPTER 2. LTFAT - GABOR ANALYSIS
The input window g must be real whole-point even. If g is not whole-point even, the computed window
will not generate an orthonormal system (i.e. reconstruction will not be perfect). For a random window g,
the window closest to g that satisfies these restrictions can be found by
g_wpe = real(peven(g));
All Gabor windows in the toolbox satisfies these restrictions unless clearly stated otherwise.
gamma=wildual(g,M);
gamma=wildual(g,M,L);
Input parameters
g Gabor window.
M Number of modulations.
Output parameters
Description
wildual(g,M) returns the dual window of the Wilson or WMDCT basis with window g, parameter M
and length equal to the length of the window g.
The window g may be a vector of numerical values, a text string or a cell array. See the help of wilwin
for more details.
If the length of g is equal to 2 · M then the input window is assumed to be an FIR window. In this case,
the dual window also has length of 2 · M. Otherwise the smallest possible transform length is chosen as the
window length.
wildual(g,M,L) does the same, but now L is used as the length of the Wilson basis.
The input window g must be real and whole-point even. If g is not whole-point even, then reconstruction
using the dual window will not be perfect. For a random window g, the window closest to g that satisfies
these restrictions can be found by
g_wpe = real(peven(g));
All windows in the toolbox satisfies these restrictions unless clearly stated otherwise.
fcond=gabframebounds(g,a,M);
[A,B]=gabframebounds(g,a,M);
[A,B]=gabframebounds(g,a,M,L);
[A,B]=gabframebounds(g,a,M,’lt’,lt);
2.5. CONDITIONS NUMBERS 61
Input parameters
g The window function.
M Number of channels.
Output parameters
fcond Frame condition number (B/A)
A, B Frame bounds.
Description
gabframebounds(g,a,M) calculates the ratio B/A of the frame bounds of the Gabor system with
window g, and parameters a, M.
[A,B]=gabframebounds(...) returns the frame bounds A and B instead of just the ratio.
The window g may be a vector of numerical values, a text string or a cell array. See the help of gabwin
for more details.
gabframebounds(g,a,M,L) will cut or zero-extend the window to length L.
gabframebounds(g,a,M,’lt’,lt) does the same for a non-separable lattice specified by lt.
Please see the help of matrix2latticetype for a precise description of the parameter lt.
Input parameters
g The window function.
M Number of channels.
Output parameters
fcond Frame condition number (B/A)
A, B Frame bounds.
Description
gabrieszbounds(g,a,M) calculates the ratio B/A of the Riesz bounds of the Gabor system with
window g, and parameters a, M.
[A,B]=gabrieszbounds(g,a,M) calculates the Riesz bounds A and B instead of just the ratio.
The window g may be a vector of numerical values, a text string or a cell array. See the help of gabwin
for more details.
If the optional parameter L is specified, the window is cut or zero-extended to length L.
62 CHAPTER 2. LTFAT - GABOR ANALYSIS
Input parameters
g Window function.
M Number of channels.
Output parameters
AF, BF Frame bounds.
Description
wilbounds(g,M) calculates the frame bounds of the Wilson frame operator of the Wilson basis with
window g and M channels.
[A,B]=wilbounds(g,a,M) returns the frame bounds A and B instead of just the ratio.
The window g may be a vector of numerical values, a text string or a cell array. See the help of wilwin
for more details.
If the length of g is equal to 2 · M then the input window is assumed to be a FIR window. Otherwise the
smallest possible transform length is chosen as the window length.
If the optional parameter L is specified, the window is cut or zero-extended to length L.
Input parameters
gamma input window..
g window function.
M Number of modulations.
Output parameters
dn dual norm.
res Residual
2.5. CONDITIONS NUMBERS 63
Description
gabdualnorm(g,gamma,a,M) calculates how close gamma is to being a dual window of the Gabor
frame with window g and parameters a and M.
The windows g and gamma may be vectors of numerical values, text strings or cell arrays. See the help
of gabwin for more details.
[scal,res]=gabdualnorm(...) computes two entities: scal determines if the windows are
scaled correctly, it must be 1 for the windows to be dual. res is close to zero if the windows (scaled
correctly) are dual windows.
gabdualnorm(g,gamma,a,M,L) does the same, but considers a transform length of L.
gabdualnorm(g,gamma,a,M,’lt’,lt) does the same for a non-separable lattice specified by
lt. Please see the help of matrix2latticetype for a precise description of the parameter lt.
gabdualnorm can be used to get the maximum relative reconstruction error when using the two
specified windows. Consider the following code for some signal f, windows g, gamma, parameters a and M
and transform-length L (See help on dgt on how to obtain L):
fr=idgt(dgt(f,g,a,M),gamma,a);
er=norm(f-fr)/norm(f);
eest=gabdualnorm(g,gamma,a,M,L);
eest=gabdualnorm(gt,gt,a,M,L);
Input parameters
g Window function.
M Number of channels.
Output parameters
d Diagonal stored as a column vector
Description
gabframediag(g,a,M,L) computes the diagonal of the Gabor frame operator with respect to the
window g and parameters a and M. The diagonal is stored a as column vector of length L.
The diagonal of the frame operator can for instance be used as a preconditioner.
Input parameters
g Window function.
M Number of channels.
Output parameters
d Diagonal stored as a column vector
Description
wilframediag(g,M,L) computes the diagonal of the Wilson or WMDCT frame operator with respect
to the window g and number of channels M. The diagonal is stored a as column vector of length L.
The diagonal of the frame operator can for instance be used as a preconditioner.
Description
[tgrad,fgrad]=gabphasegrad(method,...) computes the time-frequency gradient of the phase
of the dgt of a signal. The derivative in time tgrad is the relative instantaneous frequency while the frequency
derivative fgrad is the local group delay.
tgrad and fgrad measure the deviation from the current time and frequency, so a value of zero means
that the instantaneous frequency is equal to the center frequency of the considered channel.
tgrad is scaled such that distances are measured in samples. Similarly, fgrad is scaled such that the
Nyquist frequency (the highest possible frequency) corresponds to a value of L/2. The absolute time and
frequency positions can be obtained as
The computation of tgrad and fgrad is inaccurate when the absolute value of the Gabor coefficients is
low. This is due to the fact the the phase of complex numbers close to the machine precision is almost
random. Therefore, tgrad and fgrad may attain very large random values when abs(c) is close to zero.
The computation can be done using four different methods.
’dgt’ Directly from the signal using algorithm by Auger and Flandrin.
’phase’ From the phase of a DGT of the signal. This is the classic method used
in the phase vocoder.
’abs’ From the absolute value of the DGT. Currently this method works only
for Gaussian windows.
The window g may be specified as in dgt. If the window used is ’gauss’, the computation will be done
by a faster algorithm.
[tgrad,fgrad,c]=gabphasegrad(’dgt’,f,g,a,M) additionally returns the Gabor coeffi-
cients c, as they are always computed as a byproduct of the algorithm.
[tgrad,fgrad]=gabphasegrad(’cross’,f,g,a,M) does the same as above but this time
using algorithm by Nelson which is based on computing several DGTs.
[tgrad,fgrad]=gabphasegrad(’phase’,cphase,a) computes the phase gradient from the
phase cphase of a DGT of the signal. The original DGT from which the phase is obtained must have been
computed using a time-shift of a using the default phase convention (’freqinv’) e.g.:
[tgrad,fgrad]=gabphasegrad(’phase’,angle(dgt(f,g,a,M)),a)
[tgrad,fgrad]=gabphasegrad(’abs’,s,g,a) computes the phase gradient from the spec-
trogram s. The spectrogram must have been computed using the window g and time-shift a e.g.:
[tgrad,fgrad]=gabphasegrad(’abs’,abs(dgt(f,g,a,M)),g,a)
[tgrad,fgrad]=gabphasegrad(’abs’,s,g,a,difforder) uses a centered finite diffence
scheme of order difforder to perform the needed numerical differentiation. Default is to use a 4th order
scheme.
Currently the ’abs’ method only works if the window g is a Gaussian window specified as a string or
cell array.
References: [10], [22], [34]
Description
phased=gabphasederiv(dflag,method,...) computes the time-frequency derivative dflag
of the phase of the dgt of a signal using algorithm method.
The following strings can be used in place of dflag:
’t’ First phase derivative in time.
’f’ First phase derivative in frequency.
’tt’ Second phase derivative in time.
’ff’ Second phase derivative in frequency.
’tf’ or ’ft Second order mixed phase derivative.
phased is scaled such that (possibly non-integer) distances are measured in samples. Similarly, the
frequencies are scaled such that the Nyquist frequency (the highest possible frequency) corresponds to a
value of L/2.
The computation of phased is inaccurate when the absolute value of the Gabor coefficients is low. This
is due to the fact the the phase of complex numbers close to the machine precision is almost random.
Therefore, phased attain very large random values when abs(c) is close to zero.
The phase derivative computation can be done using four different methods depending on the string
method:
’dgt’ Directly from the signal using algorithm by Auger and Flandrin.
66 CHAPTER 2. LTFAT - GABOR ANALYSIS
Phase conventions
First derivatives in either direction are subject to phase convention. The following additional flags define
the phase convention the original phase would have had:
’freqinv’ Derivatives reflect the frequency-invariant phase of dgt. This is the
default.
’timeinv’ Derivatives reflect the time-invariant phase of dgt.
’symphase’ Derivatives reflect the symmetric phase of dgt.
’relative’ This is a combination of ’freqinv and ’timeinv’. It uses ’timeinv’ for
derivatives along frequency and and ’freqinv’ for derivatives along
time and for the mixed derivative. This is usefull for the reassignment
functions.
Please see ltfatnote042 for the description of relations between the phase derivatives with differnet phase
conventions. Note that for the ’relative’ convention, the following holds:
gabphasederiv(’t’,...,’relative’) == gabphasederiv(’t’,...,’freqinv’)
gabphasederiv(’f’,...,’relative’) == -gabphasederiv(’f’,...,’timeinv’)
gabphasederiv(’tt’,...,’relative’) == gabphasederiv(’tt’,...)
gabphasederiv(’ff’,...,’relative’) == -gabphasederiv(’ff’,...)
gabphasederiv(’tf’,...,’relative’) == gabphasederiv(’tf’,...,’freqinv’)
2.6. PHASE GRADIENT METHODS AND REASSIGNMENT 67
Description
gabreassign(s,tgrad,fgrad,a) reassigns the values of the positive time-frequency distribution s
using the phase gradient given by fgrad and tgrad. The lattice is determined by the time shift a and the
number of channels deduced from the size of s.
fgrad and tgrad can be obtained by the routine gabphasegrad.
Examples:
The following example demonstrates how to manually create a reassigned spectrogram. An easier way is
to just call resgram:
% Create reassigned vector field of the bat signal.
a=4; M=100;
[tgrad, fgrad, c] = gabphasegrad(’dgt’,bat,’gauss’,a,M);
References: [10]
68 CHAPTER 2. LTFAT - GABOR ANALYSIS
Usage
sr = gabreassignadjust(s,pderivs,a,mu);
Description
pderivs = gabphasederiv({’t’,’f’,’tt’,’ff’,’tf’},...,’relative’);
Algorithm
Examples:
% Reassignemt parameter
mu = 0.1;
% Perform the actual reassignment
sr = gabreassignadjust(abs(c).^2,pderivs,a,mu);
c=constructphase(s,g,a);
c=constructphase(s,g,a,tol);
c=constructphase(c,g,a,tol,mask);
c=constructphase(c,g,a,tol,mask,usephase);
[c,newphase,usedmask,tgrad,fgrad] = constructphase(...);
Input parameters
s Initial coefficients.
a Hop factor.
Output parameters
Description
constructphase(s,g,a) will construct a suitable phase for the postive valued coefficients s.
If s is the absolute values of the Gabor coefficients of a signal obtained using the window g and time-shift
a, i.e.:
c=dgt(f,g,a,M); s=abs(c);
’freqinv’ The constructed phase complies with the frequency invariant phase convention such
that it can be directly used in idgtreal. This is the default.
’timeinv’ The constructed phase complies with the time-invariant phase convention. The
same flag must be used in the other functions e.g. idgtreal
This function requires a computational subroutine that is only available in C. Use ltfatmex to compile
it.
References: [76]
c=constructphasereal(s,g,a,M);
c=constructphasereal(s,g,a,M,tol);
c=constructphasereal(c,g,a,M,tol,mask);
c=constructphasereal(c,g,a,M,tol,mask,usephase);
[c,newphase,usedmask,tgrad,fgrad] = constructphasereal(...);
Input parameters
s Initial coefficients.
a Hop factor.
M Number of channels.
Output parameters
c Coefficients with the constructed phase.
newphase Just the (unwrapped) phase.
usedmask Mask for selecting coefficients with the new phase.
tgrad Relative time phase derivative.
fgrad Relative frequency phase derivative.
Description
constructphasereal(s,g,a,M) will construct a suitable phase for the positive valued coefficients
s.
If s contains the absolute values of the Gabor coefficients of a signal obtained using the window g,
time-shift a and number of channels M, i.e.:
c=dgtreal(f,g,a,M); s=abs(c);
then constuctphasereal(s,g,a,M) will attempt to reconstruct c.
The window g must be Gaussian, i.e. g must have the value ’gauss’ or be a cell array {’gauss’,...}.
constructphasereal(s,g,a,M,tol) does as above, but sets the phase of coefficients less than
tol to random values. By default, tol has the value 1e-10.
constructphasereal(c,g,a,M,tol,mask) accepts real or complex valued c and real valued
mask of the same size. Values in mask which can be converted to logical true (anything other than 0) deter-
mine coefficients with known phase which is used in the output. Only the phase of remaining coefficients
(for which mask==0) is computed.
constructphasereal(c,g,a,M,tol,mask,usephase) does the same as before but uses
the known phase values from usephase rather than from c.
In addition, tol can be a vector containing decreasing values. In that case, the algorithm is run numel(tol)
times, initialized with the result from the previous step in the 2nd and the further steps.
Further, the function accepts the following flags:
’freqinv’ The constructed phase complies with the frequency invariant phase convention such
that it can be directly used in idgtreal. This is the default.
’timeinv’ The constructed phase complies with the time-invariant phase convention. The
same flag must be used in the other functions e.g. idgtreal
This function requires a computational subroutine that is only available in C. Use ltfatmex to compile
it.
References: [76]
Description
phaselock(c,a) phaselocks the Gabor coefficients c. The coefficients must have been obtained from a
dgt with parameter a.
Phaselocking the coefficients modifies them so as if they were obtained from a time-invariant Gabor
system. A filter bank produces phase locked coefficients.
Phaselocking of Gabor coefficients correspond to the following transform: Consider a signal f of length
L and define N = L/a. The output from c=phaselock(dgt(f,g,a,M),a) is given by
72 CHAPTER 2. LTFAT - GABOR ANALYSIS
L−1
c (m + 1, n + 1) = ∑ f (l + 1)e−2πim(l−na)/M g(l − an + 1)
l=0
Description
phaseunlock(c,a) removes phase locking from the Gabor coefficients c. The coefficient must have
been obtained from a dgt with parameter a.
Phase locking the coefficients modifies them so as if they were obtained from a time-invariant Gabor
system. A filter bank produces phase locked coefficients.
References: [77]
Description
phaselockreal(c,a,M) phaselocks the Gabor coefficients c. The coefficients must have been ob-
tained from a dgtreal with parameter a.
Phaselocking the coefficients modifies them so as if they were obtained from a time-invariant Gabor
system. A filter bank produces phase locked coefficients.
Please see help of phaselock for more details.
References: [77]
Description
phaseunlockreal(c,a,M) removes phase locking from the Gabor coefficients c. The coefficient
must have been obtained from a dgtreal with parameter a.
Phase locking the coefficients modifies them so as if they were obtained from a time-invariant Gabor
system. A filter bank produces phase locked coefficients.
References: [77]
Description
symphase(c,a) alters the phase of the Gabor coefficients c so as if they were obtained from a Gabor
transform based on symmetric time/frequency shifts. The coefficient must have been obtained from a dgt
with parameter a.
Gabor coefficients with symmetric phase correspond to the following transform: Consider a signal f of
length L and define N = L/a. The output from c=symphase(dgt(f,g,a,M),a) is given by
L−1
c (m + 1, n + 1) = ∑ f (l + 1)e−2πim(l−na/2)/M g(l − an + 1)
l=0
[a,M,lt] = matrix2latticetype(L,V);
Description
a =
10
M =
12
lt =
1 2
74 CHAPTER 2. LTFAT - GABOR ANALYSIS
Coefficient layout:
The following code generates plots which show the coefficient layout and enumeration of the first 4 lattices
in the time-frequecy plane:
a=6;
M=6;
L=36;
b=L/M;
N=L/a;
cw=3;
ftz=12;
[x,y]=meshgrid(a*(0:N-1),b*(0:M-1));
lt1=[0 1 1 2];
lt2=[1 2 3 3];
for fignum=1:4
subplot(2,2,fignum);
z=y;
if lt2(fignum)>0
z=z+mod(lt1(fignum)*x/lt2(fignum),b);
end;
for ii=1:M*N
text(x(ii)-cw/4,z(ii),sprintf(’%2.0i’,ii),’Fontsize’,ftz);
rectangle(’Curvature’,[1 1], ’Position’,[x(ii)-cw/2,z(ii)-cw/2,cw,cw]);
end;
axis([-cw L -cw L]);
axis(’square’);
title(sprintf(’lt=[%i %i]’,lt1(fignum),lt2(fignum)),’Fontsize’,ftz);
end;
V=latticetype2matrix(L,a,M,lt);
2.10. PLOTS 75
Description
V=latticetype2matrix(L,a,M,lt) converts a standard description of a lattice using the a, M and
lt parameters into a 2 × 2 integer matrix description. The conversion is only valid for the specified transform
length L.
The output will be in lower triangular Hemite normal form.
For more information, see http://en.wikipedia.org/wiki/Hermite_normal_form.
An example:
V = latticetype2matrix(120,10,12,[1 2])
V =
10 0
5 10
Description
[s0,s1,br]=shearfind(L,a,M,lt) computes three numbers, the first two represent a frequency
and time shear respectively. With the returned choices of s0 and s1 one can transform an initial lattice given
by a, M and lt into a separable (rectangular) lattice given by
aL L
ar = , Mr = .
br M br
If s0 is non-zero, the transformation from general to separable lattice requires a frequency-side shear. Sim-
ilarly, if s1 is non-zero, a time-side shear is required.
Description
noshearlength(Ls,a,M,lt) computes the next larger transform length bigger or equal to Ls for
which the shear algorithm does not require a frequency side shear for a non-separable Gabor system speci-
fied by a, M and lt.
This property makes computation of the canonical dual and tight Gabor windows gabdual and gabtight
and the dgt for a full length window faster, if this transform length is choosen.
2.10 Plots
2.10.1 TFPLOT - Plot coefficient matrix on the TF plane
Usage
tfplot(coef,step,yr);
tfplot(coef,step,yr,...);
76 CHAPTER 2. LTFAT - GABOR ANALYSIS
Description
tfplot(coef,step,yr) will plot a rectangular coefficient array on the TF-plane. The shift in samples
between each column of coefficients is given by the variable step. The vector yr is a 1 × 2 vector containing
the lowest and highest normalized frequency.
C=tfplot(...) returns the processed image data used in the plotting. Inputting this data directly to
imagesc or similar functions will create the plot. This is usefull for custom post-processing of the image
data.
tfplot is not meant to be called directly. Instead, it is called by other plotting routines to give a
uniform display format.
tfplot (and all functions that call it) takes the following arguments.
’db’ Apply 20 · log10 to the coefficients. This makes it possible to see very
weak phenomena, but it might show too much noise. A logarithmic
scale is more adapted to perception of sound. This is the default.
’dbsq’ Apply 10 · log10 to the coefficients. Same as the ’db’ option, but
assume that the input is already squared.
’lin’ Show the coefficients on a linear scale. This will display the raw input
without any modifications. Only works for real-valued input.
’tc’ Time centering. Move the beginning of the signal to the middle of the
plot.
’clim’,clim Use a colormap ranging from clim(1) to clim(2). These values are
passed to imagesc. See the help on imagesc.
’nodisplay’ Do not display figure. This is usefull if you only want to obtain the
output for further processing.
If both ’clim’ and ’dynrange’ are specified, then ’clim’ takes precedence.
It is possible to customize the text by setting the following values:
’time’, t The word denoting time. Default is ’Time’
Description
plotdgt(coef,a) plots the Gabor coefficients coef. The coefficients must have been produced with a
time shift of a.
plotdgt(coef,a,fs) does the same assuming a sampling rate of fs Hz of the original signal.
plotdgt(coef,a,fs,dynrange) additionally limits the dynamic range.
The figure generated by this function places the zero-frequency in the center of the y-axis, with positive
frequencies above and negative frequencies below.
C=plotdgt(...) returns the processed image data used in the plotting. Inputting this data directly
to imagesc or similar functions will create the plot. This is useful for custom post-processing of the image
data.
plotdgt supports all the optional parameters of tfplot. Please see the help of tfplot for an exhaustive
list.
Description
plotdgtreal(coef,a,M) plots Gabor coefficient from dgtreal. The parameters a and M must match
those from the call to dgtreal.
plotdgtreal(coef,a,M,fs) does the same assuming a sampling rate of fs Hz of the original
signal.
plotdgtreal(coef,a,M,fs,dynrange) additionally limits the dynamic range.
C=plotdgtreal(...) returns the processed image data used in the plotting. Inputting this data
directly to imagesc or similar functions will create the plot. This is usefull for custom post-processing of
the image data.
plotdgtreal supports all the optional parameters of tfplot. Please see the help of tfplot for an
exhaustive list.
Description
plotdwilt(coef) will plot coefficients from dwilt.
plotdwilt(coef,fs) will do the same assuming a sampling rate of fs Hz of the original signal.
Since a Wilson representation does not contain coefficients for all positions on a rectangular TF-grid, there
will be visible ’holes’ among the lowest (DC) and highest (Nyquist rate) coefficients. See the help on
wil2rect.
78 CHAPTER 2. LTFAT - GABOR ANALYSIS
Description
plotwmdct(coef) plots coefficients from wmdct.
plotwmdct(coef,fs) does the same assuming a sampling rate of fs Hz of the original signal.
plotwmdct(coef,fs,dynrange) additionally limits the dynamic range.
C=plotwmdct(...) returns the processed image data used in the plotting. Inputting this data di-
rectly to imagesc or similar functions will create the plot. This is useful for custom post-processing of
the image data.
plotwmdct supports all the optional parameters of tfplot. Please see the help of tfplot for an exhaustive
list.
Description
sgram(f) plots a spectrogram of f using a Discrete Gabor Transform (DGT).
sgram(f,fs) does the same for a signal with sampling rate fs (sampled with fs samples per sec-
ond);
sgram(f,fs,dynrange) additionally limits the dynamic range of the plot. See the description of
the ’dynrange’ parameter below.
C=sgram(f, ... ) returns the image to be displayed as a matrix. Use this in conjunction with
imwrite etc. These coefficients are only intended to be used by post-processing image tools. Numer-
ical Gabor signal analysis and synthesis should always be done using the dgt, idgt, dgtreal and idgtreal
functions.
Additional arguments can be supplied like this:
sgram(f,fs,’dynrange’,50)
’wlen’,s Window length. Specifies the length of the window measured in sam-
ples. See help of pgauss on the exact details of the window length.
’posfreq’ Display only the positive frequencies. This is the default for real-
valued signals.
’tc’ Time centering. Move the beginning of the signal to the middle of
the plot. This is useful for visualizing the window functions of the
toolbox.
’clim’,clim Use a colormap ranging from clim(1) to clim(2). These values are
passed to imagesc. See the help on imagesc.
’thr’,r Keep only the largest fraction r of the coefficients, and set the rest to
zero.
’xres’,xres Approximate number of pixels along x-axis / time. The default value
is 800
In addition to these parameters, sgram accepts any of the flags from normalize. The window used to
calculate the spectrogram will be normalized as specified.
Examples:
The greasy signal is sampled using a sampling rate of 16 kHz. To display a spectrogram of greasy with a
dynamic range of 90 dB, use:
sgram(greasy,16000,90);
80 CHAPTER 2. LTFAT - GABOR ANALYSIS
To create a spectrogram with a window length of 20ms (which is typically used in speech analysis) use
fs=16000;
sgram(greasy,fs,90,’wlen’,round(20/1000*fs));
Description
[a,M,L,N,Ngood]=gabimagepars(Ls,x,y) will compute a reasonable set of parameters a, M
and L to produce a nice Gabor ’image’ of a signal of length Ls. The approximate number of pixels in the
time direction is given as x and the number of pixels in the frequency direction is given as y.
The output parameter Ngood contains the number of time steps (columns in the coefficients matrix)
that contains relevant information. The columns from Ngood until N only contains information from a
zero-extension of the signal.
If you use this function to calculate a grid size for analysis of a real-valued signal (using dgtreal), please
input twice of the desired size y. This is because dgtreal only returns half as many coefficients in the
frequency direction as dgt.
2.10. PLOTS 81
An example: We wish to compute a Gabor image of a real valued signal f of length 7500. The image
should have an approximate resolution of 600 × 800 pixels:
[f,fs]=linus; f=f(4001:4000+7500);
[a,M,L,N,Ngood] = gabimagepars(7500,800,2*600);
c = dgtreal(f,’gauss’,a,M);
plotdgtreal(c,a,M,fs,90);
Usage
resgram(f,op1,op2, ... );
resgram(f,fs,op1,op2, ... );
Description
resgram(greasy,16000,’dynrange’,70);
82 CHAPTER 2. LTFAT - GABOR ANALYSIS
This will produce a reassigned spectrogram of the greasy signal without drowning the interesting fea-
tures in noise.
C=resgram(f, ... ) returns the image to be displayed as a matrix. Use this in conjunction with
imwrite etc. These coefficients are only intended to be used by post-processing image tools. Reassign-
ment should be done using the gabreassign function instead.
resgram accepts the following additional arguments:
’sharp’,alpha Set the sharpness of the plot. If al pha = 0 the regular spectrogram is
obtained. al pha = 1 means full reassignment. Anything in between
will produce a partially sharpened picture. Default is al pha = 1.
’wlen’,s Window length. Specifies the length of the window measured in sam-
ples. See help of pgauss on the exact details of the window length.
’posfreq’ Display only the positive frequencies. This is the default for real-
valued signals.
’tc’ Time centering. Move the beginning of the signal to the middle of
the plot. This is useful for visualizing the window functions of the
toolbox.
’clim’,clim Use a colormap ranging from clim(1) to clim(2). These values are
passed to imagesc. See the help on imagesc.
’thr’,r Keep only the largest fraction r of the coefficients, and set the rest to
zero.
’fmax’,y Display y as the highest frequency. Default value of [] means to use
the Nyquist frequency.
’xres’,xres Approximate number of pixels along x-axis / time. The default value
is 800
’yres’,yres Approximate number of pixels along y-axis / frequency The default
value is 600
’contour’ Do a contour plot to display the spectrogram.
’surf’ Do a surf plot to display the spectrogram.
’mesh’ Do a mesh plot to display the spectrogram.
’colorbar’ Display the colorbar. This is the default.
’nocolorbar’ Do not display the colorbar.
In addition to these parameters, sgram accepts any of the flags from normalize. The window used to
calculate the spectrogram will be normalized as specified.
Description
instfreqplot(f) plots the instantaneous frequency of f using a dgt.
instfreqplot(f,fs) does the same for a signal with sampling rate fs Hz.
The instantaneous frequency contains extreme spikes in regions where the spectrogram is close to zero.
These points are usually uninteresting and destroy the visibility of the plot. Use the ’thr’ or ’clim’ or
’climsym’ options (see below) to remove these points.
An example:
instfreqplot(greasy,16000,’thr’,.03,’climsym’,100);
84 CHAPTER 2. LTFAT - GABOR ANALYSIS
’wlen’,s Window length. Specifies the length of the window measured in sam-
ples. See help of pgauss on the exact details of the window length.
’thr’,r Keep the coefficients with a magnitude larger than r times the largest
magnitude. Set the instantaneous frequency of the rest of the coeffi-
cients to zero
’tc’ Time centering. Move the beginning of the signal to the middle of
the plot. This is useful for visualizing the window functions of the
toolbox.
’dgt’ Use the ’dgt method to compute the instantaneous frequency. This is
the default.
’clim’,clim Use a colormap ranging from clim(1) to clim(2). These values are
passed to imagesc. See the help on imagesc.
Description
phaseplot(f) plots the phase of f using a dgt.
phaseplot(f,fs) does the same for a signal with sampling rate fs Hz.
phaseplot should only be used for short signals (shorter than the resolution of the screen), as
there will otherwise be some visual aliasing, such that very fast changing areas will look very smooth.
phaseplot always calculates the phase of the full time/frequency plane (as opposed to sgram), and you
therefore risk running out of memory for long signals.
phaseplot takes the following flags at the end of the line of input arguments:
’wlen’,s Window length. Specifies the length of the window measured in sam-
ples. See help of pgauss on the exact details of the window length.
2.10. PLOTS 85
’tc’ Time centering. Move the beginning of the signal to the middle of
the plot. This is usefull for visualizing the window functions of the
toolbox.
’thr’,r Keep the coefficients with a magnitude larger than r times the largest
magnitude. Set the phase of the rest of the coefficients to zero. This is
useful, because for small amplitude the phase values can be meaning-
less.
For the best result when using phaseplot, use a circulant color map, for instance hsv.
Examples:
The following code shows the phaseplot of a periodic, hyperbolic secant visualized using the hsv colormap:
phaseplot(psech(200),’tc’,’nf’);
colormap(hsv);
phaseplot(randn(200,1));
colormap(hsv);
86 CHAPTER 2. LTFAT - GABOR ANALYSIS
References: [20]
Chapter 3
Description
fftindex(N) returns the index of the frequencies of the standard FFT of length N as they are ordered in
the output from the fft routine. The numbers returned are in the range -ceil(N/2)+1:floor(N/2)
fftindex(N,0) does as above, but sets the Nyquist frequency to zero.
Description
modcent(x,r) computes the modulo of x in the range [−r/2, r/2[.
As an example, to compute the modulo of x in the range [−π, π[ use the call:
y = modcent(x,2*pi);
Description
floor23(n) returns the first number less than or equal to n, which can be written as a product of powers
of 2 and 3.
The algorithm will look up the best size in a table, which is computed the first time the function is run.
If the input size is larger than the largest value in the table, the input size will be reduced by factors of 2,
until it is in range.
[nceil,table]=floor23(n) additionally returns the table used for lookup.
87
88 CHAPTER 3. LTFAT - BASIC FOURIER AND DCT ANALYSIS.
Examples:
Return the first number smaller or equal to 26 that can be written solely as products of powers of 2 and 3:
floor23(26)
This code produces the following output:
ans =
24
This plot shows the behaviour of floor23 and ceil23 for numbers up to 100:
x=1:100;
plot(x,floor23(x),x,ceil23(x));
legend(’floor23’,’ceil23’,’Location’,’Northwest’);
Description
floor235(n) returns the next number greater than or equal to n, which can be written as a product of
powers of 2, 3 and 5.
The algorithm will look up the best size in a table, which is computed the first time the function is run.
If the input size is larger than the largest value in the table, the input size will be reduced by factors of 2,
until it is in range.
[nfloor,table]=floor235(n) additionally returns the table used for lookup.
Examples:
Return the first number smaller or equal to 26 that can be written solely as products of powers of 2, 3 and 5:
floor235(26)
This code produces the following output:
ans =
25
3.1. SUPPORT ROUTINES 89
This plot shows the behaviour of floor235 and ceil235 for numbers up to 100:
x=1:100;
plot(x,floor235(x),x,ceil235(x));
legend(’floor235’,’ceil235’,’Location’,’Northwest’);
nceil=ceil23(n);
Description
ceil23(n) returns the next number greater than or equal to n, which can be written as a product of powers
of 2 and 3.
The algorithm will look up the best size in a table, which is computed the first time the function is run.
If the input size is larger than the largest value in the table, the input size will be reduced by factors of 2,
until it is in range.
[nceil,table]=ceil23(n) additionally returns the table used for lookup.
Examples:
Return the first number larger or equal to 19 that can be written solely as products of powers of 2 and 3:
ceil23(19)
ans =
24
nceil=ceil235(n);
90 CHAPTER 3. LTFAT - BASIC FOURIER AND DCT ANALYSIS.
Description
ceil235(n) returns the next number greater than or equal to n, which can be written as a product of
powers of 2, 3 and 5.
The algorithm will look up the best size in a table, which is computed the first time the function is run.
If the input size is larger than the largest value in the table, the input size will be reduced by factors of 2,
until it is in range.
[nceil,table]=ceil235(n) additionally returns the table used for lookup.
Examples:
Return the first number larger or equal to 19 that can be written solely as products of powers of 2, 3 and 5:
ceil235(19)
This code produces the following output:
ans =
20
Description
nextfastfft(n) returns the next number greater than or equal to n, for which the computation of a
FFT is fast. Such a number is solely comprised of small prime-factors of 2, 3, 5 and 7.
nextfastfft is intended as a replacement of nextpow2, which is often used for the same purpose.
However, a modern FFT implementation (like FFTW) usually performs well for sizes which are powers or
2,3,5 and 7, and not only just for powers of 2.
The algorithm will look up the best size in a table, which is computed the first time the function is run.
If the input size is larger than the largest value in the table, the input size will be reduced by factors of 2,
until it is in range.
[n,nfft]=nextfastfft(n) additionally returns the table used for lookup.
References: [35], [23], [88]
Description
dft computes a normalized or unitary discrete Fourier transform. The unitary discrete Fourier transform
is computed by
1 L−1
c (k + 1) = √ ∑ f (l + 1) e−2πikl/L
L l=0
for k = 0, . . . , L − 1.
The output of dft is a scaled version of the output from fft. The function takes exactly the same
arguments as fft. See the help on fft for a thorough description.
3.2. BASIC FOURIER ANALYSIS 91
Description
idft computes a normalized or unitary inverse discrete Fourier transform. The unitary discrete Fourier
transform is computed by
1 L−1
f (l + 1) = √ ∑ c (k + 1) e2πikl/L
L k=0
for l = 0, . . . , L − 1.
The output of idft is a scaled version of the output from ifft. The function takes exactly the same
arguments as ifft. See the help on ifft for a thorough description.
Description
fftreal(f) computes the coefficients corresponding to the positive frequencies of the FFT of the real
valued input signal f.
The function takes exactly the same arguments as fft. See the help on fft for a thorough description.
Description
ifftreal(c,N) computes an inverse FFT of the positive frequency Fourier coefficients c. The length N
must always be specified, because the correct transform length cannot be determined from the size of c.
ifftreal(c,N,dim) does the same along dimension dim.
Input parameters
x Input data.
fs Sampling frequency.
92 CHAPTER 3. LTFAT - BASIC FOURIER AND DCT ANALYSIS.
Output parameters
c Coefficient vector.
Description
c=gga(f,fvec) computes the discrete-time fourier transform DTFT of f at frequencies in fvec as
c(k) = F(2π fvec (k)) where F = DT FT ( f ), k = 1, . . . K and K=length(fvec) using the generalized
second-order Goertzel algorithm. Thanks to the generalization, values in fvec can be arbitrary numbers
in range 0 − 1 and not restricted to l/Ls, l = 0, . . . Ls − 1 (usual DFT samples) as the original Goertzel
algorithm is. Ls is the length of the first non-singleton dimension of f. If fvec is empty or ommited, fvec
is assumed to be (0:Ls-1)/Ls and results in the same output as fft.
c=gga(f,fvec,fs) computes the same with fvec in Hz relative to fs.
The input f is processed along the first non-singleton dimension or along dimension dim if specified.
Remark: Besides the generalization the algorithm is also shortened by one iteration compared to the
conventional Goertzel.
Examples:
Calculating DTFT samples of interest:
xlabel(’f[Hz]’);
ylabel(’angle(c(k))’);
hold off;
This code produces the following output:
ans =
1.604964106526122e-09
References: [90]
Input parameters
f Input data.
K Number of values.
94 CHAPTER 3. LTFAT - BASIC FOURIER AND DCT ANALYSIS.
fs Sampling frequency.
Output parameters
c Coefficient vector.
Description
c = chirpzt(f,K,fdiff,foff) computes K samples of the discrete-time fourier transform DTFT
c of f at values c(k + 1) = F(2π( fo f f + k fdi f f )) for k = 0, . . . , K − 1 where F = DT FT ( f ). Values foff
and fdiff should be in range of 0 − 1. If foff is ommited or empty, it is considered to be 0. If fdiff
is ommited or empty, K equidistant values c(k + 1) = F(2πk/K) are computed. If even K is ommited or
empty, input length is used instead resulting in the same values as fft does.
c = chirpzt(f,K,fdiff,foff,fs) computes coefficients using frequency values relative to
fs c(k + 1) = F(2π( fo f f + k fdi f f )/ f s) for k = 0, . . . , K − 1.
The input f is processed along the first non-singleton dimension or along dimension dim if specified.
Examples:
Calculating DTFT samples of interest (aka zoom FFT):
% Frequency "resolution" in Hz
fdiff = 0.4;
% Frequency offset in Hz
foff = 803.9;
% Number of frequency values
K = 125;
% DTFT samples. The frequency range of interest is 803.9-853.5 Hz
ckchzt = chirpzt(f,K,fdiff,foff,fs);
5.944006695631077e-10
References: [78]
fftgram(f, fs)
Description
fftgram(f) plots the energy of the discrete Fourier transform computed from the function f. The func-
tion forms a Fourier pair with the periodic autocorrelation function.
fftgram(f,fs) does the same for a signal sampled with a sampling frequency of fs Hz. If fs is no
specified, the plot will display normalized frequencies.
fftgram(f,fs,dynrange) additionally specifies the dynamic range to display on the figure.
Additional arguments for fftgram:
In addition to these parameters, fftgram accepts any of the flags from normalize. The input signal
will be normalized as specified.
Description
plotfft(coef) plots the output from the fft function. The frequency axis will use normalized fre-
quencies between 0 and 1 (the Nyquist frequency).
plotfft(coef,fs) does the same for the FFT of a signal sampled at a sampling rate of fs Hz.
plotfft(coef,fs,dynrange) additionally limits the dynamic range of the plot. See the descrip-
tion of the ’dynrange’ parameter below.
plotfft accepts the following optional arguments:
’db’ Apply 20 · log10 to the coefficients. This makes it possible to see very
weak phenomena, but it might show too much noise. This is the de-
fault.
’dbsq’ Apply 10 · log10 to the coefficients. Same as the ’db’ option, but
assumes that the input is already squared.
’lin’ Show the coefficients on a linear scale. This will display the raw input
without any modifications. Only works for real-valued input.
’flog’ Use logarithmic scale for the frequency axis. This flag is only valid in
conjuction with the ’posfreq’ flag.
In addition to these parameters, plotfft accepts any of the flags from normalize. The coefficients
will be normalized as specified before plotting.
Description
plotfftreal(coef) plots the output from the fftreal function. The frequency axis will use normalized
frequencies between 0 and 1 (the Nyquist frequency). It is assumed that the length of the original transform
was even.
plotfftreal(coef,fs) does the same for the fftreal of a signal sampled at a sampling rate of fs
Hz.
plotfftreal(coef,fs,dynrange) additionally limits the dynamic range of the plot. See the
description of the ’dynrange’ parameter below.
plotfftreal accepts the following optional arguments:
’dynrange’,r Limit the dynamical range to r by using a colormap in the interval
[chigh-r,chigh], where chigh is the highest value in the plot.
The default value of [] means to not limit the dynamical range.
’db’ Apply 20 · log10 to the coefficients. This makes it possible to see very
weak phenomena, but it might show too much noise. This is the de-
fault.
’dbsq’ Apply 10 · log10 to the coefficients. Same as the ’db’ option, but
assumes that the input is already squared.
’lin’ Show the coefficients on a linear scale. This will display the raw input
without any modifications. Only works for real-valued input.
’linsq’ Show the square of the coefficients on a linear scale.
’linabs’ Show the absolute value of the coefficients on a linear scale.
’N’,N Specify the transform length N. Use this if you are unsure if the origi-
nal input signal was of even length.
’dim’,dim If coef is multidimensional, dim indicates the dimension along which
are the individual channels oriented. Value 1 indicates columns, value
2 rows.
’flog’ Use logarithmic scale for the frequency axis.
In addition to these parameters, plotfftreal accepts any of the flags from normalize. The coeffi-
cients will be normalized as specified before plotting.
Description
involute(f) will return the involution of f.
involute(f,dim) will return the involution of f along dimension dim. This can for instance be
used to calculate the 2D involution:
f=involute(f,1);
f=involute(f,2);
finv(l+1)=conj(f(mod(-l,L)+1));
for l = 0, . . . , L − 1.
The relation between conjugation, Fourier transformation and involution is expressed by:
conj(dft(f)) == dft(involute(f))
for all signals f. The inverse discrete Fourier transform can be expressed by:
idft(f) == conj(involute(dft(f)));
Description
peven(f) returns the even part of the periodic sequence f.
peven(f,dim) does the same along dimension dim.
Description
podd(f) returns the odd part of the periodic sequence f.
podd(f,dim) does the same along dimension dim.
Description
pconv(f,g) computes the periodic convolution of f and g. The convolution is given by
L−1
h (l + 1) = ∑ f (k + 1) g (l − k + 1)
k=0
L−1
h (l + 1) = ∑ f (k + 1) g (k − l + 1)
k=0
Description
pxcorr(f,g) computes the periodic cross correlation of the input signals f and g. The cross correlation
is defined by
L−1
h (l + 1) = ∑ f (k + 1) g (k − l + 1)
k=0
Description
lconv(f,g) computes the linear convolution of f and g. The linear convolution is given by
Lh −1
h (l + 1) = ∑ f (k + 1) g (l − k + 1)
k=0
lconv(f,g,’rr’) computes the alternative where both f and g are reversed given by
Lh −1
h (l + 1) = ∑ f (−k + 1) g (l − k + 1)
k=0
Description
lxcorr(f) computes the linear crosscorrelation of the input signal f and g. The linear cross-correlation
is computed by
L−1
h (l + 1) = ∑ f (k + 1) g (k − l + 1)
k=0
Description
isevenfunction(f) returns 1 if f is whole point even. Otherwise it returns 0.
isevenfunction(f,tol) does the same, using the tolerance tol to measure how large the error
between the two parts of the vector can be. Default is 1e-10.
Adding the flag ’hp’ as the last argument does the same for half point even functions.
Description
middlepad(f,L) cuts or zero-extends f to length L by inserting zeros in the middle of the vector, or by
cutting in the middle of the vector.
If f is whole-point even, middlepad(f,L) will also be whole-point even.
middlepad(f,L,dim) does the same along dimension dim.
If f has even length, then f will not be purely zero-extended, but the last element will be repeated once
and multiplied by 1/2. That is, the support of f will increase by one!
Adding the flag ’wp’ as the last argument will cut or extend whole point even functions. Adding ’hp’
will do the same for half point even functions.
Description
expwave(L,m) returns an exponential wave revolving m times around the origin. The collection of all
waves with wave number m = 0, . . . , L − 1 forms the basis of the discrete Fourier transform.
The wave 2
p has absolute value 1 everywhere. To get an exponential wave with unit l -norm, divide the
wave by (L). This is the normalization used in the dft function.
expwave(L,m,cent) makes it possible to shift the sampling points by the amount cent. Default is
cent = 0.
g=pchirp(L,n);
Description
pchirp(L,n) returns a periodic, discrete chirp of length L that revolves n times around the time-frequency
plane in frequency. n must be an integer number.
To get a chirp that revolves around the time-frequency plane in time, use
dft(pchirp(L,N));
2 (L+1)/L
g (l + 1) = eπin(l−⌈L/2⌉) , l = 0, . . . , L − 1
√
The chirp has absolute value 1 everywhere. To get a chirp with unit l 2 -norm, divide the chirp by L.
Examples:
sgram(pchirp(40,2),’lin’);
sgram(dft(pchirp(40,2)),’lin’);
102 CHAPTER 3. LTFAT - BASIC FOURIER AND DCT ANALYSIS.
An odd-length chirp. Notice that the chirp starts at a frequency between two sampling points:
sgram(pchirp(41,2),’lin’);
References: [31]
Input parameters
L Length of vector.
Output parameters
g The periodized Gaussian.
3.4. PERIODIC FUNCTIONS 103
Description
pgauss(L,tfr) computes samples of a periodized Gaussian. The function returns a regular sampling
of the periodization of the function exp(−pi * (x.2 /t f r)).
The l 2 norm of the returned Gaussian is equal to 1.
The parameter tfr determines the ratio between the effective support of g and the effective support of
the DFT of g. If t f r > 1 then g has a wider support than the DFT of g.
pgauss(L) does the same setting tfr=1.
[g,tfr] = pgauss( ... ) will additionally return the time-to-frequency support ratio. This
is useful if you did not specify it (i.e. used the ’width’ or ’bw’ flag).
The function is whole-point even. This implies that fft(pgauss(L,tfr)) is real for any L and tfr.
The DFT of g is equal to pgauss(L,1/tfr).
In addition to the ’width’ flag, pgauss understands the following flags at the end of the list of input
parameters:
’fs’,fs Use a sampling rate of fs Hz as unit for specifying the width, band-
width, centre frequency and delay of the Gaussian. Default is fs=[]
which indicates to measure everything in samples.
’width’,s Set the width of the Gaussian such that it has an effective support of
s samples. This means that approx. 96% of the energy or 79% of the
area under the graph is contained within s samples. This corresponds
to -6dB or to width at the half of the height. This is equivalent to
calling pgauss(L,pi*s^2/4L*log(2)).
’atheight’,ah Used only in conjuction with ’width’. Forces the Gaussian to width s
at the ah fraction of the height.
’bw’,bw As for the ’width’ argument, but specifies the width in the fre-
quency domain. The bandwidth is measured in normalized frequen-
cies, unless the ’fs’ value is given.
In addition to these parameteres, pgauss accepts any of the flags from normalize. The output will be
normalized as specified.
If this function is used to generate a window for a Gabor frame, then the window giving the smallest
frame bound ratio is generated by pgauss(L,a*M/L).
Examples:
This example creates a Gaussian function, and demonstrates that it is its own Discrete Fourier Transform:
g=pgauss(128);
ans =
2.481524897647706e-15
plot(fftshift(pgauss(128)));
The next plot shows the Gaussian in the frequency domain on a log scale:
magresp(pgauss(128),’dynrange’,100);
sgram(pgauss(128),’tc’,’nf’,’lin’);
3.4. PERIODIC FUNCTIONS 105
References: [62]
g=psech(L);
g=psech(L,tfr);
g=psech(L,s,’samples);
[g,tfr]=psech( ... );
Input parameters
L Length of vector.
Output parameters
Description
psech(L,tfr) computes samples of a periodized hyperbolic secant. The function returns a regular
sampling of the periodization of the function
The returned function has norm equal to 1.
The parameter tfr determines the ratio between the effective support of g and the effective support of
the DFT of g. If t f r > 1 then g has a wider support than the DFT of g.
psech(L) does the same setting t f r = 1.
psech(L,s,’samples’) returns a hyperbolic secant with an effective support of s samples. This
means that approx. 96% of the energy or 74% or the area under the graph is contained within s samples.
This is equivalent to psech(L,s^2/L).
[g,tfr] = psech( ... ) additionally returns the time-to-frequency support ratio. This is
useful if you did not specify it (i.e. used the ’samples’ input format).
The function is whole-point even. This implies that fft(psech(L,tfr)) is real for any L and tfr.
If this function is used to generate a window for a Gabor frame, then the window giving the smallest
frame bound ratio is generated by psech(L,a*M/L).
106 CHAPTER 3. LTFAT - BASIC FOURIER AND DCT ANALYSIS.
Examples:
This example creates a psech function, and demonstrates that it is its own Discrete Fourier Transform:
g=psech(128);
ans =
2.400287682482777e-15
The next plot shows the psech in the time domain compared to the Gaussian:
plot((1:128)’,fftshift(pgauss(128)),...
(1:128)’,fftshift(psech(128)));
legend(’pgauss’,’psech’);
The next plot shows the psech in the frequency domain on a log scale compared to the Gaussian:
hold all;
magresp(pgauss(128),’dynrange’,100);
magresp(psech(128),’dynrange’,100);
legend(’pgauss’,’psech’);
3.4. PERIODIC FUNCTIONS 107
References: [48]
Input parameters
L Length of window.
order Order of B-spline.
a Time-shift parameter for partition of unity.
Output parameters
g Fractional B-spline.
nlen Number of non-zero elements in out.
108 CHAPTER 3. LTFAT - BASIC FOURIER AND DCT ANALYSIS.
Description
The different types are accurately described in the referenced paper. Generally, the ’d’ types of splines
are very fast to compute, while the ’c’ types are samplings of the continuous splines. The ’e’ types coincides
with the regular B-splines for integer orders. The ’x’ types do not coincide, but generate Gabor frames with
favorable frame bounds. The default type is ’ed’ to guarantee fast computation and a familiar shape of the
splines.
[out,nlen]=pbspline(...) will additionally compute the number of non-zero elements in out.
If nlen = L, the function returned will be a periodization of a B-spline.
If nlen < L, you can choose to remove the additional zeros by calling g=middlepad(g,nlen).
Additionally, pbspline accepts flags to normalize the output. Please see the help of normalize. De-
fault is to use ’peak’ normalization.
References: [87]
f=shah(L,a);
Description
shah(L,a) computes the discrete, normalized Shah-distribution of length L with a distance of a between
the spikes.
The Shah distribution is defined by
1
f (n · a + 1) = p
(L/a)
for integer n, otherwise f is zero.
This is also known as an impulse train or as the comb function, because the shape of the function
resembles a comb. It is the sum of unit impulses (’diracs’) with the distance a.
If a divides L, then the dft of shah(L,a) is shah(L,L/a).
The Shah function has an extremely bad time-frequency localization. It does not generate a Gabor frame
for any L and a.
3.4. PERIODIC FUNCTIONS 109
Examples:
A simple spectrogram of the Shah function (includes the negative frequencies to display the whole TF-
plane):
sgram(shah(256,16),’dynrange’,80,’nf’)
Description
pheaviside(L) returns a periodic Heaviside function. The periodic Heaviside function takes on the
value 1 for indices corresponding to positive frequencies, 0 corresponding to negative frequencies and the
value .5 for the zero and Nyquist frequencies.
To get a function that weights the negative frequencies by 1 and the positive by 0, use involute(pheaviside(L))
As an example, the pheaviside function can be use to calculate the Hilbert transform for a column
vector f :
h=2*ifft(fft(f).*pheaviside(length(f)));
Description
psinc(L,n) computes the periodic rectangle (or square) function of length L supported on n samples.
The dft of the periodic rectangle function in the periodic sinc function, psinc.
∙ If n is odd, the output will be supported on exactly n samples centered around the first sample.
∙ If n is even, the output will be supported on exactly n+1 samples centered around the first sample.
The function value on the two samples on the edge of the function will have half the magnitude of
the other samples.
110 CHAPTER 3. LTFAT - BASIC FOURIER AND DCT ANALYSIS.
Examples:
This figure displays an odd length periodic rectangle:
stem(prect(30,11));
ylim([-.2 1.2]);
This figure displays an even length periodic rectangle. Notice the border points:
stem(prect(30,12));
ylim([-.2 1.2]);
Description
psinc(L,n) computes the periodic Sinc function of length L with n − 1 local extrema. The dft of the
periodic Sinc function is the periodic rectangle, prect, of length n.
3.5. HERMITE FUNCTIONS AND FRACTIONAL FOURIER TRANSFORMS 111
Examples:
This figure displays a the periodic sinc function with 6 local extremas:
plot(psinc(30,7));
Input parameters
L Length of vector.
Output parameters
g The periodized Hermite function
Description
pherm(L,order,tfr) computes samples of a periodized Hermite function of order order. order is
counted from 0, so the zero’th order Hermite function is the Gaussian.
The parameter tfr determines the ratio between the effective support of g and the effective support of
the DFT of g. If t f r > 1 then g has a wider support than the DFT of g.
pherm(L,order) does the same setting t f r = 1.
If order is a vector, pherm will return a matrix, where each column is a Hermite function with the
corresponding order.
[g,D]=pherm(...) also returns the eigenvalues D of the Discrete Fourier Transform corresponding
to the Hermite functions.
112 CHAPTER 3. LTFAT - BASIC FOURIER AND DCT ANALYSIS.
The returned functions are eigenvectors of the DFT. The Hermite functions are orthogonal to all other
Hermite functions with a different eigenvalue, but eigenvectors with the same eigenvalue are not orthogonal
(but see the flags below).
pherm takes the following flags at the end of the line of input arguments:
’accurate’ Use a numerically very accurate that computes each Hermite function
individually. This is the default.
’fast’ Use a less accurate algorithm that calculates all the Hermite up to a
given order at once.
If you just need to compute a single Hermite function, there is no speed difference between the ’accurate’
and ’fast’ algorithm.
Examples:
The following plot shows the spectrograms of 4 Hermite functions of length 200 with order 1, 10, 100, and
190:
subplot(2,2,1);
sgram(pherm(200,1),’nf’,’tc’,’lin’,’nocolorbar’); axis(’square’);
subplot(2,2,2);
sgram(pherm(200,10),’nf’,’tc’,’lin’,’nocolorbar’); axis(’square’);
subplot(2,2,3);
sgram(pherm(200,100),’nf’,’tc’,’lin’,’nocolorbar’); axis(’square’);
subplot(2,2,4);
sgram(pherm(200,190),’nf’,’tc’,’lin’,’nocolorbar’); axis(’square’);
3.5. HERMITE FUNCTIONS AND FRACTIONAL FOURIER TRANSFORMS 113
V=hermbasis(L,p);
V=hermbasis(L);
[V,D]=hermbasis(...);
Description
hermbasis(L,p) computes an orthonormal basis of discrete Hermite functions of length L. The vectors
are returned as columns in the output. p is the order of approximation used to construct the position and
difference operator.
All the vectors in the output are eigenvectors of the discrete Fourier transform, and resemble samplings
of the continuous Hermite functions to some degree (for low orders).
[V,D]=hermbasis(...) also returns the eigenvalues D of the Discrete Fourier Transform corre-
sponding to the Hermite functions.
Examples:
The following plot shows the spectrograms of 4 Hermite functions of length 200 with order 1, 10, 100, and
190:
H=hermbasis(200);
subplot(2,2,1);
sgram(H(:,1),’nf’,’tc’,’lin’,’nocolorbar’); axis(’square’);
subplot(2,2,2);
sgram(H(:,10),’nf’,’tc’,’lin’,’nocolorbar’); axis(’square’);
subplot(2,2,3);
sgram(H(:,100),’nf’,’tc’,’lin’,’nocolorbar’); axis(’square’);
subplot(2,2,4);
sgram(H(:,190),’nf’,’tc’,’lin’,’nocolorbar’); axis(’square’);
Description
dfracft(f,a) computes the discrete fractional Fourier Transform of the signal f to the power a. For
a=1 it corresponds to the ordinary discrete Fourier Transform. If f is multi-dimensional, the transformation
is applied along the first non-singleton dimension.
dfracft(f,a,dim) does the same along dimension dim.
dfracft(f,a,[],p) or dfracft(f,a,dim,p) allows to choose the order of approximation of
the second difference operator (default: p=2).
References: [70, 19]
Description
ffracft(f,a) computes an approximation of the fractional Fourier transform of the signal f to the
power a. If f is multi-dimensional, the transformation is applied along the first non-singleton dimension.
ffracft(f,a,dim) does the same along dimension dim.
ffracft takes the following flags at the end of the line of input arguments:
’origin’ Rotate around the origin of the signal. This is the same action as the
dft, but the signal will split in the middle, which may not be the correct
action for data signals. This is the default.
’middle’ Rotate around the middle of the signal. This will not break the signal
in the middle, but the dft cannot be obtained in this way.
Examples:
The following example shows a rotation of the ltfatlogo test signal:
sgram(ffracft(ltfatlogo,.3,’middle’),’lin’,’nf’);
3.6. APPROXIMATION OF CONTINUOUS FUNCTIONS 115
References: [19]
h=fftresample(f,L);
h=fftresample(f,L,dim);
Description
fftresample(f,L) returns a Fourier interpolation of the signal f to length L. If the function is applied
to a matrix, it will apply to each column.
fftresample(f,L,dim) does the same along dimension dim.
If the input signal is not a periodic signal (or close to), the dctresample method gives much better results
at the endpoints.
h=dctresample(f,L);
h=dctresample(f,L,dim);
Description
dctresample(f,L) returns a discrete cosine interpolation of the signal f to length L. If the function is
applied to a matrix, it will apply to each column.
dctresample(f,L,dim) does the same along dimension dim.
If the input signal is not a periodic signal (or close to), this method will give much better results than
fftresample at the endpoints, as this method assumes than the signal is even a the endpoints.
The algorithm uses a DCT type iii.
fd=pderiv(f);
fd=pderiv(f,dim);
fd=pderiv(f,dim,difforder);
Description
pderiv(f) will compute the derivative of f using a using a 4th order centered finite difference scheme.
f must have been obtained by a regular sampling. If f is a matrix, the derivative along the columns will be
found.
pderiv(f,dim) will do the same along dimension dim.
pderiv(f,dim,difforder) uses a centered finite difference scheme of order difforder instead of
the default.
pderiv(f,dim,Inf) will compute the spectral derivative using a DFT.
pderiv assumes that f is a regular sampling of a function on the torus [0, 1). The derivative of a
function on a general torus [0, T ) can be found by scaling the output by 1/T .
116 CHAPTER 3. LTFAT - BASIC FOURIER AND DCT ANALYSIS.
Input parameters
f Input data.
Output parameters
z Analytic signal.
Description
fftanalytic(f) computes the analytic representation of a real-valued signal f. The analytic representa-
tion is computed through the FFT of f. The computations are done along the first non-singleton dimension.
fftanalytic(f,L) acts as before but f is padded with zeros or truncated to length L.
fftanalytic(f,L,dim) in addition allows specifying the dimension along which the computation
should be done.
The real part of the analytic representation z equals the signal f and the imaginary part is the Hilbert
transform of f.
The instananeous amplitude (a Hilbert envelope) of the signal f can be computed as:
abs(fftanalytic(f));
angle(fftanalytic(f));
Description
dcti(f) computes the discrete cosine transform of type I of the input signal f. If f is a matrix then
the transformation is applied to each column. For N-D arrays, the transformation is applied to the first
non-singleton dimension.
dcti(f,L) zero-pads or truncates f to length L before doing the transformation.
dcti(f,[],dim) or dcti(f,L,dim) applies the transformation along dimension dim.
The transform is real (output is real if input is real) and it is orthonormal.
This transform is its own inverse.
Let f be a signal of length L, let c = dcti( f ) and define the vector w of length L by
3.7. COSINE AND SINE TRANSFORMS. 117
1
√2
if n = 0 or n = L − 1
w (n) =
1 otherwise
Then
r
2 L−1
πnm
c (n + 1) = ∑ w (n) w (m) f (m + 1) cos L − 1
L − 1 m=0
The implementation of this functions uses a simple algorithm that require an FFT of length 2L-2, which
might potentially be the product of a large prime number. This may cause the function to sometimes execute
slowly. If guaranteed high speed is a concern, please consider using one of the other DCT transforms.
Examples:
The following figures show the first 4 basis functions of the DCTI of length 20:
for ii=1:4
subplot(4,1,ii);
stem(F(:,ii));
end;
Description
dctii(f) computes the discrete cosine transform of type II of the input signal f. If f is multi-dimensional,
the transformation is applied along the first non-singleton dimension.
118 CHAPTER 3. LTFAT - BASIC FOURIER AND DCT ANALYSIS.
Then
r
2 L−1
π 1
c (n + 1) = ∑ w (n) f (m + 1) cos L n m + 2
L m=0
Examples:
The following figures show the first 4 basis functions of the DCTII of length 20:
for ii=1:4
subplot(4,1,ii);
stem(F(:,ii));
end;
c=dctiii(f);
c=dctiii(f,L);
c=dctiii(f,[],dim);
c=dctiii(f,L,dim);
3.7. COSINE AND SINE TRANSFORMS. 119
Description
dctiii(f) computes the discrete cosine transform of type III of the input signal f. If f is multi-
dimensional, the transformation is applied along the first non-singleton dimension.
dctiii(f,L) zero-pads or truncates f to length L before doing the transformation.
dctiii(f,[],dim) or dctiii(f,L,dim) applies the transformation along dimension dim.
The transform is real (output is real if input is real) and orthonormal.
This is the inverse of dctii.
Let f be a signal of length L, let c=dctiii(f) and define the vector w of length L by
1
√2
if n = 0
w (n) =
1 otherwise
Then
r
2 L−1
π 1
c (n + 1) = ∑ w (m) f (m + 1) cos L n + 2 m
L m=0
Examples:
The following figures show the first 4 basis functions of the DCTIII of length 20:
for ii=1:4
subplot(4,1,ii);
stem(F(:,ii));
end;
c=dctiv(f);
120 CHAPTER 3. LTFAT - BASIC FOURIER AND DCT ANALYSIS.
Description
dctiv(f) computes the discrete cosine transform of type IV of the input signal f. If f is multi-dimensional,
the transformation is applied along the first non-singleton dimension.
dctiv(f,L) zero-pads or truncates f to length L before doing the transformation.
dctiv(f,[],dim) or dctiv(f,L,dim) applies the transformation along dimension dim.
The transform is real (output is real if input is real) and orthonormal. It is its own inverse.
Let f be a signal of length L and let c=dctiv(f). Then
r
2 L−1
π 1 1
c (n + 1) = ∑ f (m + 1) cos n + m +
L m=0 L 2 2
Examples:
The following figures show the first 4 basis functions of the DCTIV of length 20:
for ii=1:4
subplot(4,1,ii);
stem(F(:,ii));
end;
Description
dsti(f) computes the discrete sine transform of type I of the input signal f. If f is multi-dimensional, the
transformation is applied along the first non-singleton dimension.
dsti(f,L) zero-pads or truncates f to length L before doing the transformation.
dsti(f,[],dim) or dsti(f,L,dim) applies the transformation along dimension dim.
3.7. COSINE AND SINE TRANSFORMS. 121
Examples:
The following figures show the first 4 basis functions of the DSTI of length 20:
for ii=1:4
subplot(4,1,ii);
stem(F(:,ii));
end;
Description
dstii(f) computes the discrete sine transform of type II of the input signal f. If f is multi-dimensional,
the transformation is applied along the first non-singleton dimension.
dstii(f,L) zero-pads or truncates f to length L before doing the transformation.
dstii(f,[],dim) or dstii(f,L,dim) applies the transformation along dimension dim.
The transform is real (output is real if input is real) and orthonormal.
122 CHAPTER 3. LTFAT - BASIC FOURIER AND DCT ANALYSIS.
Then
r
2 L−1
π 1
c (n + 1) = ∑ w (n) f (m + 1) sin n m +
L m=0 L 2
Examples:
The following figures show the first 4 basis functions of the DSTII of length 20:
% The dstiii is the adjoint of dstii.
F=dstiii(eye(20));
for ii=1:4
subplot(4,1,ii);
stem(F(:,ii));
end;
Description
dstiii(f) computes the discrete sine transform of type III of the input signal f. If f is multi-dimensional,
the transformation is applied along the first non-singleton dimension.
dstiii(f,L) zero-pads or truncates f to length L before doing the transformation.
dstiii(f,[],dim) or dstiii(f,L,dim) applies the transformation along dimension dim.
3.7. COSINE AND SINE TRANSFORMS. 123
Then
r
2 L−1
π 1
c (n + 1) = ∑ w (m) f (m + 1) sin n + m
L m=0 L 2
Examples:
The following figures show the first 4 basis functions of the DSTIII of length 20:
% The dstii is the adjoint of dstiii.
F=dstii(eye(20));
for ii=1:4
subplot(4,1,ii);
stem(F(:,ii));
end;
Description
dstiv(f) computes the discrete sine transform of type IV of the input signal f. If f is a matrix, then
the transformation is applied to each column. For N-D arrays, the transformation is applied to the first
non-singleton dimension.
124 CHAPTER 3. LTFAT - BASIC FOURIER AND DCT ANALYSIS.
Examples:
The following figures show the first 4 basis functions of the DSTIV of length 20:
% The dstiv is its own adjoint.
F=dstiv(eye(20));
for ii=1:4
subplot(4,1,ii);
stem(F(:,ii));
end;
LTFAT - Wavelets
Usage
c = fwt(f,w,J);
c = fwt(f,w,J,dim);
[c,info] = fwt(...);
Input parameters
f Input data.
w Wavelet definition.
Output parameters
c Coefficient vector.
Description
fwt(f,w,J) returns discrete wavelet coefficients of the input signal f using J iterations of the basic
wavelet filterbank defined by w using the fast wavelet transform algorithm (Mallat’s algorithm). The coef-
ficients are the Discrete Wavelet transform (DWT) of the input signal f, if w defines two-channel wavelet
filterbank. The following figure shows DWT with J=3.
125
126 CHAPTER 4. LTFAT - WAVELETS
The function can apply the Mallat’s algorithm using basic filterbanks with any number of the channels.
In such case, the transform have a different name.
Several formats of the basic filterbank definition w are recognized. One of them is a text string formed
by a concatenation of a function name with the wfilt_ prefix followed by a list of numerical arguments
delimited by :. For example ’db10’ will result in a call to wfilt_db(10) or ’spline4:4’ in call to
wfilt_spline(4,4) etc. All filter defining functions can be listed by running dir([ltfatbasepath,filesep,’wave
Please see help of the respective functions and follow references therein.
For other recognized formats of w please see fwtinit.
[c,info]=fwt(f,w,J) additionally returns struct. info containing transform parameters. It can
be conviniently used for the inverse transform ifwt e.g. as fhat = ifwt(c,info). It is also required
by the plotwavelets function.
If f is row/column vector, the subbands c are stored in a single row/column in a consecutive order with
respect to the inceasing central frequency. The lengths of subbands are stored in info.Lc so the subbands
can be easily extracted using wavpack2cell. Moreover, one can pass an additional flag ’cell’ to obtain
the coefficient directly in a cell array. The cell array can be again converted to a packed format using
wavcell2pack.
If the input f is a matrix, the transform is applied to each column if dim==1 (default) and [Ls,
W]=size(f). If dim==2 the transform is applied to each row [W, Ls]=size(f). The output is
then a matrix and the input orientation is preserved in the orientation of the output coefficients. The dim
paramerer has to be passed to the wavpack2cell and wavcell2pack when used.
Boundary handling:
fwt(f,w,J,’per’) (default) uses the periodic extension which considers the input signal as it was a
one period of some infinite periodic signal as is natural for transforms based on the FFT. The resulting
wavelet representation is non-expansive, that is if the input signal length is a multiple of a J-th power of the
subsampling factor and the filterbank is critically subsampled, the total number of coefficients is equal to
the input signal length. The input signal is padded with zeros to the next legal length L internally.
The default periodic extension can result in "false" high wavelet coefficients near the boundaries due to
the possible discontinuity introduced by the zero padding and periodic boundary treatment.
fwt(f,w,J,ext) with ext other than ’per’ computes a slightly redundant wavelet representation
4.1. BASIC ANALYSIS/SYNTHESIS 127
of the input signal f with the chosen boundary extension ext. The redundancy (expansivity) of the represe-
nation is the price to pay for using general filterbank and custom boundary treatment. The extensions are
done at each level of the transform internally rather than doing the prior explicit padding.
The supported possibilities are:
Note that the same flag has to be used in the call of the inverse transform function ifwt if the info
struct is not used.
Examples:
A simple example of calling the fwt function using ’db8’ wavelet filters.:
[f,fs] = greasy;
J = 10;
[c,info] = fwt(f,’db8’,J);
plotwavelets(c,info,fs,’dynrange’,90);
Frequency bands of the transform with x-axis in a log scale and band peaks normalized to 1. Only
positive frequency band is shown.
[g,a] = wfbt2filterbank({’db8’,10,’dwt’});
filterbankfreqz(g,a,20*1024,’linabs’,’posfreq’,’plot’,’inf’,’flog’);
128 CHAPTER 4. LTFAT - WAVELETS
References: [60]
f = ifwt(c,info)
f = ifwt(c,w,J,Ls)
f = ifwt(c,w,J,Ls,dim)
Input parameters
c Wavelet coefficients.
Output parameters
f Reconstructed data.
Description
f = ifwt(c,info) reconstructs signal f from the wavelet coefficients c using parameters from info
struct. both returned by fwt function.
f = ifwt(c,w,J,Ls) reconstructs signal f from the wavelet coefficients c using J-iteration syn-
thesis filterbank build from the basic filterbank defined by w. The Ls parameter is mandatory due to the
ambiguity of lengths introduced by the subsampling operation and by boundary treatment methods. Note
that the same flag as in the fwt function have to be used, otherwise perfect reconstruction cannot be obtained.
In both cases, the fast wavelet transform algorithm (Mallat’s algorithm) is employed. The format of c
can be either packed, as returned by the fwt function or cell-array as returned by wavpack2cell function.
Please see the help on fwt for a detailed description of the parameters.
4.1. BASIC ANALYSIS/SYNTHESIS 129
Examples:
A simple example showing perfect reconstruction:
f = gspi;
J = 8;
c = fwt(f,’db8’,J);
fhat = ifwt(c,’db8’,J,length(f));
% The following should give (almost) zero
norm(f-fhat)
ans =
3.542640048596510e-14
References: [60]
Input parameters
f Input data.
Output parameters
c Coefficients stored in a matrix.
Description
c=fwt2(f,w,J) returns wavelet coefficients c of the input matrix f using J iterations of the basic wavelet
filter bank defined by w. Please see fwt for description of w and J.
fwt2 supports just the non-expansive boundary condition ’per’ and critically subsampled filter banks
in order to be able to pack the coefficients in a matrix. Also the J is limited to some maximum value for the
same reason.
Additional flags make it possible to specify how the algorithm should subdivide the matrix:
’standard’ Standard behaviour of the JPEG 2000 standard. This is the default.
’tensor’ This corresponds to doing a full fwt along each dimension of the matrix.
Examples:
Some simple example of calling the fwt2 function, compare with the cameraman image. Only the 70 dB
largest coefficients are shown, to make the structures more visible.
The first example uses the standard layout:
c = fwt2(cameraman,’db8’,4);
imagesc(dynlimit(20*log10(abs(c)),70));
axis(’image’); colormap(gray);
130 CHAPTER 4. LTFAT - WAVELETS
c = fwt2(cameraman,’db8’,4,’tensor’);
imagesc(dynlimit(20*log10(abs(c)),70));
axis(’image’); colormap(gray);
References: [60]
Input parameters
c Coefficients stored in a matrix.
Output parameters
f Reconstructed data.
Description
f = ifwt2(c,w,J) reconstructs signal f from the wavelet coefficients c using a J-iteration synthesis
filterbank build from the basic synthesis filterbank defined by w. f is a matrix with size(f)==size(c).
f = ifwt2(c,w,J,Ls) works as above but the result f is cut or extended to size Ls if Ls is a
two-element vector or to [Ls,Ls] if Ls is a scalar.
This function takes the same optional parameters as fwt2. Please see the help on fwt2 for a description
of the parameters.
References: [60]
c = ufwt(f,w,J);
[c,info] = ufwt(...);
Input parameters
f Input data.
w Wavelet Filterbank.
Output parameters
Description
ufwt(f,w,J) computes redundant time (or shift) invariant wavelet representation of the input signal f
using wavelet filters defined by w in the "a-trous" algorithm.
For all accepted formats of the parameter w see the fwtinit function.
[c,info]=ufwt(f,w,J) additionally returns the info struct. containing the transform parame-
ters. It can be conviniently used for the inverse transform iufwt e.g. fhat = iufwt(c,info). It is
also required by the plotwavelets function.
The coefficents c are so called undecimated Discrete Wavelet transform of the input signal f, if w defines
two-channel wavelet filterbank. Other names for this version of the wavelet transform are: the time-invariant
wavelet transform, the stationary wavelet transform, maximal overlap discrete wavelet transform or even
the "continuous" wavelet transform (as the time step is one sample). However, the function accepts any
number filters (referred to as M) in the basic wavelet filterbank and the number of columns of c is then
J(M − 1) + 1.
For one-dimensional input f of length L, the coefficients c are stored as columns of a matrix. The
columns are ordered with inceasing central frequency of the respective subbands.
If the input f is L ×W matrix, the transform is applied to each column and the outputs are stacked along
third dimension in the L × J(M − 1) + 1 ×W data cube.
132 CHAPTER 4. LTFAT - WAVELETS
Filter scaling
When compared to fwt, ufwt subbands are gradually more and more redundant with increasing level of the
subband. If no scaling of the filters is introduced, the energy of subbands tends to grow with increasing
level. There are 3 flags defining filter scaling:
’sqrt’ Each filter is scaled by 1/sqrt(a), where 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’ has to be used in iufwt (and vice versa) in order to obtain a perfect recon-
struction.
Boundary handling:
c=ufwt(f,w,J) uses periodic boundary extension. The extensions are done internally at each level of
the transform, rather than doing the prior explicit padding.
Examples:
[f,fs] = greasy;
J = 8;
[c,info] = ufwt(f,’db8’,J);
plotwavelets(c,info,fs,’dynrange’,90);
References: [46]
f = iufwt(c,info)
f = iufwt(c,w,J);
4.1. BASIC ANALYSIS/SYNTHESIS 133
Input parameters
c Coefficients stored in L × J + 1 matrix.
Output parameters
f Reconstructed data.
Description
f = iufwt(c,info) reconstructs signal f from the wavelet coefficients c using parameters from info
struct. both returned by ufwt function.
f = iufwt(c,w,J) reconstructs signal f from the wavelet coefficients c using the wavelet filterbank
consisting of the J levels of the basic synthesis filterbank defined by w using the "a-trous" algorithm. Node
that the same flag as in the ufwt function have to be used.
Please see the help on ufwt for a description of the parameters.
Filter scaling
As in ufwt, 3 flags defining scaling of filters are recognized:
’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 ufwt (and vice versa) in order to obtain a perfect
reconstruction.
Examples:
A simple example showing perfect reconstruction:
f = gspi;
J = 8;
c = ufwt(f,’db8’,J);
fhat = iufwt(c,’db8’,J);
% The following should give (almost) zero
norm(f-fhat)
ans =
6.468488239052756e-14
References: [60]
Description
fwtlength(Ls,w,J) returns the length of a Wavelet system that is long enough to expand a signal of
length Ls. Please see the help on fwt for an explanation of the parameters w and J.
If the returned length is longer than the signal length, the signal will be zero-padded by fwt to length L.
In addition, the function accepts flags defining boundary extension technique as in fwt. The returned
length can be longer than the signal length only in case of ’per’ (periodic extension).
Description
Lc=fwtclength(Ls,w,J) returns the lengths of the wavelet coefficient subbands for a signal of length
Ls. Please see the help on fwt for an explanation of the parameters w and J.
[Lc,L]=fwtclength(...) additianally the function returns the next legal length of the input
signal for the given extension type.
The function support the same boundary-handling flags as the fwt does.
Input parameters
f Input data.
Output parameters
c Coefficients stored in a cell-array.
Description
wfbt(f,wt) returns coefficients c obtained by applying a wavelet filterbank tree defined by wt to the
input data f.
[c,info]=wfbt(f,wt) additionally returns struct. info containing transform parameters. It can
be conviniently used for the inverse transform iwfbt e.g. fhat = iwfbt(c,info). It is also required
by the plotwavelets function.
wt defines a tree shaped filterbank structure build from the elementary two (or more) channel wavelet
filters. The tree can have any shape and thus provide a flexible frequency covering. The outputs of the tree
leaves are stored in c.
The wt parameter can have two formats:
4.2. ADVANCED ANALYSIS/SYNTHESIS 135
1) Cell array containing 3 elements {w,J,treetype}, where w is the basic wavelet filterbank
definition as in fwt function, J stands for the depth of the tree and the flag treetype defines
the type of the tree to be used. Supported options are:
’dwt’ Plain DWT tree (default). This gives one band per octave freq. resolution when using
2 channel basic wavelet filterbank and produces coefficients identical to the ones in fwt.
’full’ Full filterbank tree. Both (all) basic filterbank outputs are decomposed further up to
depth J achieving linear frequency band division.
’doubleband’,‘’quadband’,’octaband’‘ The filterbank is designed such that it mimics
4-band, 8-band or 16-band complex wavelet transform provided the basic filterbank is 2
channel. In this case, J is treated such that it defines number of levels of 4-band, 8-band
or 16-band transform.
2) Structure returned by the wfbtinit function and possibly modified by wfbtput and wfbtremove.
Please see wfbtinit for a detailed description and more options.
If f is row/column vector, the coefficient vectors c{jj} are columns.
If f is a matrix, the transformation is by default applied to each of W columns [Ls, W]=size(f).
In addition, the following flag groups are supported:
’per’‘(default),’zero’,’odd’,’even’‘ Type of the boundary handling. Please see the help on fwt
for a description of the boundary condition flags.
’freq’‘(default),’nat’‘ Frequency or natural ordering of the coefficient subbands. The direct usage
of the wavelet tree (’nat’ option) does not produce coefficient subbans ordered according to the
frequency. To achieve that, some filter shuffling has to be done (’freq’ option).
Examples:
A simple example of calling the wfbt function using the "full decomposition" wavelet tree:
f = gspi;
J = 7;
[c,info] = wfbt(f,{’sym10’,J,’full’});
plotwavelets(c,info,44100,’dynrange’,90);
Input parameters
Output parameters
f Reconstructed data.
Description
f = iwfbt(c,info) reconstructs signal f from the coefficients c using parameters from info struct.
both returned by wfbt function.
f = iwfbt(c,wt,Ls) reconstructs signal f from the coefficients c using filterbank tree defined by
wt. Plese see wfbt function for possible formats of wt. The Ls parameter is mandatory due to the ambiguity
of reconstruction lengths introduced by the subsampling operation and by boundary treatment methods.
Note that the same flag as in the wfbt function have to be used, otherwise perfect reconstruction cannot be
obtained. Please see help for wfbt for description of the flags.
Examples:
f = gspi;
J = 7;
wt = {’db6’,J};
c = wfbt(f,wt);
fhat = iwfbt(c,wt,length(f));
% The following should give (almost) zero
norm(f-fhat)
ans =
1.392090799573605e-13
c=uwfbt(f,wt);
[c,info]=uwfbt(...);
Input parameters
f Input data.
Output parameters
Description
uwfbt(f,wt) computes redundant time (or shift) invariant representation of the input signal f using the
filterbank tree definition in wt and using the "a-trous" algorithm. Number of columns in c (M) is defined by
the total number of outputs of nodes of the tree.
[c,info]=uwfbt(f,wt) additionally returns struct. info containing the transform parameters.
It can be conviniently used for the inverse transform iuwfbt e.g. fhat = iuwfbt(c,info). It is also
required by the plotwavelets function.
If f is a matrix, the transformation is applied to each of W columns and the coefficients in c are stacked
along the third dimension.
Please see help for wfbt description of possible formats of wt and description of frequency and natural
ordering of the coefficient subbands.
Filter scaling
When compared to wfbt, the subbands produced by uwfbt are gradually more and more redundant with
increasing depth in the tree. This results in energy grow of the coefficients. There are 3 flags defining filter
scaling:
’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’ has to be used in iuwfbt (and vice versa) in order to obtain a perfect recon-
struction.
Examples:
A simple example of calling the uwfbt function using the "full decomposition" wavelet tree:
f = greasy;
J = 8;
[c,info] = uwfbt(f,{’sym10’,J,’full’});
plotwavelets(c,info,16000,’dynrange’,90);
138 CHAPTER 4. LTFAT - WAVELETS
Input parameters
c Coefficients stored in L × M matrix.
info, wt Transform parameters struct/Wavelet tree definition.
Output parameters
f Reconstructed data.
Description
f = iuwfbt(c,info) reconstructs signal f from the coefficients c using parameters from info struct.
both returned by the uwfbt function.
f = iuwfbt(c,wt) reconstructs signal f from the wavelet 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 uwfbt, the function recognizes three flags controlling scaling of the 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 uwfbt (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 = 6;
c = uwfbt(f,{’db8’,J,’full’});
fhat = iuwfbt(c,{’db8’,J,’full’});
% The following should give (almost) zero
norm(f-fhat)
This code produces the following output:
ans =
2.647294733053261e-14
Input parameters
f Input data.
Output parameters
Description
c=wpfbt(f,wt) returns wavelet packet coefficients c obtained by applying a wavelet filterbank tree
defined by wt to the input data f.
[c,info]=wpfbt(f,wt) additionally returns struct. info containing transform parameters. It
can be conviniently used for the inverse transform iwpfbt e.g. fhat = iwpfbt(c,info). It is also
required by the plotwavelets function.
In contrast to wfbt, the cell array c contain every intermediate output of each node in the tree. c{jj}
are ordered according to nodes taken in the breadth-first order.
If f is row/column vector, the coefficient vectors c{jj} are columns. If f is a matrix, the transformation
is applied to each of column of the matrix.
The following flags control scaling of intermediate outputs and therefore the energy relations between
coefficient subbands. An intermediate output is an output of a node which is further used as an input to a
descendant node.
’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. This is necessaty for the wpbest func-
tion to correctly work with the cost measures.
If ’intnoscale’ is used, ’intscale’ must be used in iwpfbt (and vice versa) in order to obtain a perfect
reconstruction.
Please see help for wfbt description of possible formats of wt and of the additional flags defining bound-
ary handling.
Examples:
A simple example of calling the wpfbt function using the "full decomposition" wavelet tree:
f = gspi;
J = 6;
[c,info] = wpfbt(f,{’sym10’,J,’full’});
plotwavelets(c,info,44100,’dynrange’,90);
140 CHAPTER 4. LTFAT - WAVELETS
Input parameters
c Coefficients stored in a cell-array.
info, wt Transform parameters struct/Wavelet Filterbank tree.
Ls Length of the reconstructed signal.
Output parameters
f Reconstructed data.
Description
f = iwpfbt(c,info) reconstructs signal f from the coefficients c using parameters from info struct.
both returned by wfbt function.
f = iwpfbt(c,wt,Ls) reconstructs signal f from the coefficients c using filter bank tree defined
by wt. Plese see wfbt function for possible formats of wt. The Ls parameter is mandatory due to the
ambiguity of reconstruction lengths introduced by the subsampling operation and by boundary treatment
methods.
Please see help for wfbt description of possible formats of wt and of the additional flags.
Examples:
A simple example showing perfect reconstruction using the "full decomposition" wavelet tree:
f = gspi;
J = 7;
wt = {’db10’,J,’full’};
c = wpfbt(f,wt);
fhat = iwpfbt(c,wt,length(f));
% The following should give (almost) zero
norm(f-fhat)
This code produces the following output:
ans =
8.015867730167378e-14
Input parameters
f Input data.
wt Wavelet Filterbank tree
Output parameters
c Coefficients in a L × M matrix.
Description
c=uwpfbt(f,wt) returns coefficients c obtained by applying the undecimated wavelet filterbank tree
defined by wt to the input data f using the "a-trous" algorithm. Number of columns in c (M) is defined by
the total number of outputs of each node. The outputs c(:,jj) are ordered in the breadth-first node order
manner.
[c,info]=uwpfbt(f,wt) additionally returns struct. info containing the transform parameters.
It can be conviniently used for the inverse transform iuwpfbt e.g. fhat = iuwpfbt(c,info). It is
also required by the plotwavelets function.
If f is a matrix, the transformation is applied to each of W columns and the coefficients in c are stacked
along the third dimension.
Please see help for wfbt description of possible formats of wt.
Scaling of filters:
When compared to wpfbt, the subbands produced by uwpfbt are gradually more and more redundant with
increasing depth in the tree. This results in energy grow of the coefficients. There are 3 flags defining filter
scaling:
’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 be used in iuwpfbt (and vice versa) in order to obtain a perfect recon-
struction.
Examples:
A simple example of calling the uwpfbt function using the "full decomposition" wavelet tree:
[f,fs] = greasy;
J = 6;
[c,info] = uwpfbt(f,{’db10’,J,’full’});
plotwavelets(c,info,fs,’dynrange’,90);
Input parameters
c Coefficients stored in L × M matrix.
Output parameters
f Reconstructed data.
4.2. ADVANCED ANALYSIS/SYNTHESIS 143
Description
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 undeci-
mated 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.
’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)
ans =
3.279270462493657e-14
Input parameters
f Input data.
w Wavelet Filterbank.
Output parameters
c Coefficients stored in a cell-array.
Description
[c,info]=wpbest(f,w,J,cost) selects the best sub-tree info.wt from the full tree with max.
depth J, which minimizes the cost function.
Only one-dimensional input f is accepted. The supported formats of the parameter w can be found in
help for fwt. The format of the coefficients c and the info struct is the same as in wfbt.
Please note that w should define orthonormal wavelet filters.
First, the depth J wavelet packet decomposition is performed using wpfbt. Then the nodes are traversed
in the breadth-first and bottom-up order and the value of the cost function of the node input and cost of
the combined node outputs is compared. If the node input cost function value is less than the combined
output cost, the current node and all possible descendant nodes are marked to be deleted, if not, the input
is assigned the combined output cost. At the end, the marked nodes are removed and the resulting tree is
considered to be a best basis (or near-best basis) in the chosen cost function sense.
The cost parameter can be a cell array or an user-defined function handle. accepting a single column
vector. The cell array should consist of a string, followed by a numerical arguments. The possible formats
are listed in the following text.
Additive costs:
The additive cost E of a vector x is a real valued cost function such that:
E(x) = ∑ E(x(k))
k
and E(0) = 0. Given a collection of vectors xi being coefficients in orthonormal bases Bi , the best basis
relative to E is the one for which the E(xi ) is minimal.
Additive cost functions allows using the fast best-basis search algorithm since the costs can be precom-
puted and combined cost of two vectors is just a sum of their costs.
Non-additive costs:
Cost function, which is not additive cost but which is used for the basis selection is called a non-additive
cost. The resulting basis for which the cost is minimal is called near-best, because the non-additive cost
cannot guarantee the selection of a best basis relative to the cost function.
where 0 < p ≤ 2 and vk (x) denotes the k-th largest absolute value of x.
where 0 < p ≤ 2, 0 < f < 1 and wk (u, p) denotes decreasingly sorted, powered, cumulateively
summed and renormalized vector:
p
∑kj=1 v j (x)
wk (x, p) = p
∑Nj=1 v j (x)
where v_k(x) denotes the k-th largest absolute value of x and N is the number of elements of x.
Examples:
f = gspi;
J = 8;
[c,info] = wpbest(f,’sym10’,J,’cost’,’shannon’);
% Use 2/3 of the space for the first plot, 1/3 for the second.
subplot(3,3,[1 2 4 5 7 8]);
plotwavelets(c,info,44100,90);
subplot(3,3,[3 6 9]);
N=cellfun(@numel,c); L=sum(N); a=L./N;
plot(a,’o’);
xlim([1,numel(N)]);
view(90,-90);
xlabel(’Channel no.’);
ylabel(’Subsampling rate / samples’);
146 CHAPTER 4. LTFAT - WAVELETS
L=wfbtlength(Ls,wt);
Description
wfbtlength(Ls,wt) returns the length of a Wavelet system that is long enough to expand a signal of
length Ls. Please see the help on wfbt for an explanation of the parameter wt.
If the returned length is longer than the signal length, the signal will be zero-padded by wfbt to length
L.
In addition, the function accepts flags defining boundary extension technique as in wfbt. The returned
length can be longer than the signal length only in case of ’per’ (periodic extension).
Lc=wfbtclength(Ls,wt);
[Lc,L]=wfbtclength(...);
Description
Lc=wfbtclength(Ls,wt) returns the lengths of coefficient subbands obtained from wfbt for a signal
of length Ls. Please see the help on wfbt for an explanation of the parameters wt.
[Lc,L]=wfbtclength(...) additionally returns the next legal length of the input signal for the
given extension type.
The function support the same boundary-handling flags as the fwt does.
Lc=wpfbtclength(Ls,wt);
[Lc,L]=wpfbtclength(Ls,wt);
4.3. DUAL-TREE COMPLEX WAVELET TRANSFORM 147
Description
Lc=wpfbtclength(Ls,wt) returns the lengths of coefficient subbands obtained from wpfbt for a sig-
nal of length Ls. Please see the help on wpfbt for an explanation of the parameter wt.
[Lc,L]=wpfbtclength(...) additionally returns the next legal length of the input signal for the
given extension type.
The function support the same boundary-handling flags as the fwt does.
Input parameters
f Input data.
Output parameters
c Coefficients stored in a cell-array.
Description
c=dtwfbt(f,dualwt) computes dual-tree complex wavelet coefficients of the signal f. The represen-
tation is approximately time-invariant and provides analytic behaviour. Due to these facts, the resulting
subbands are nearly aliasing free making them suitable for severe coefficient modifications. The represen-
tation is two times redundant, provided critical subsampling of all involved filter banks.
The shape of the filterbank tree and filters used is controlled by dualwt (for possible formats see
below). The output c is a cell-array with each element containing a single subband. The subbands are
ordered with the increasing subband centre frequency.
In addition, the function returns struct. info containing transform parameters. It can be conveniently
used for the inverse transform idtwfb e.g. fhat = idtwfb(c,info). It is also required by the plot-
wavelets function.
If f is a matrix, the transform is applied to each column.
Two formats of dualwt are accepted:
1) Cell array of parameters. First two elements of the array are mandatory {dualw,J}.
Possible formats of dualw are the same as in fwtinit except the wfiltdt_ prefix is used when
searching for function specifying the actual impulse responses. These filters were designed
specially for the dual-tree filter bank to achieve the half-sample shift ultimately resulting in
analytic (complex) behaviour of the transform.
The default shape of the filter bank tree is DWT i.e. only low-pass output is decomposed further
(J times in total).
Different filter bank tree shapes can be obtained by passing additional flag in the cell array.
Supported flags (mutually exclusive) are:
148 CHAPTER 4. LTFAT - WAVELETS
’dwt’ Plain DWT tree (default). This gives one band per octave freq. resolution when using
2 channel basic wavelet filter bank.
’full’ Full filter bank tree. Both (all) basic filter bank outputs are decomposed further up
to depth J achieving linear frequency band division.
’doubleband’,‘’quadband’,’octaband’‘ The filter bank is designed such that it mimics
4-band, 8-band or 16-band complex wavelet transform provided the basic filter bank is 2
channel. In this case, J is treated such that it defines number of levels of 4-band, 8-band
or 16-band transform.
The dual-tree wavelet filter bank can use any basic wavelet filter bank in the first stage of both
trees, provided they are shifted by 1 sample (done internally). A custom first stage filter bank
can be defined by passing the following key-value pair in the cell array:
’first’,‘w‘ w defines a regular basic filter bank. Accepted formats are the same as in fwtinit
assuming the wfilt_ prefix.
Similarly, when working with a filter bank tree containing decomposition of high-pass outputs,
some filters in both trees must be replaced by a regular basic filter bank in order to achieve the
approximately analytic behaviour. A custom filter bank can be specified by passing another
key-value pair in the cell array:
’leaf’,‘w‘ w defines a regular basic filter bank. Accepted formats are the same as in fwtinit
assuming the wfilt_ prefix.
2) Another possibility is to pass directly a struct. returned by dtwfbinit and possibly modified by
wfbtremove.
Optional args.:
’freq’,‘’nat’‘ Frequency or natural (Paley) ordering of coefficient subbands. By default, subbands are
ordered according to frequency. The natural ordering is how the subbands are obtained from the filter
bank tree without modifications. The ordering differs only in non-plain DWT case.
Boundary handling:
In contrast with fwt, wfbt and wpfbt, this function supports periodic boundary handling only.
Examples:
A simple example of calling the dtwfb function using the regular DWT iterated filter bank. The second
figure shows a magnitude frequency response of an identical filter bank.:
[f,fs] = greasy;
J = 6;
[c,info] = dtwfb(f,{’qshift3’,J});
figure(1);
plotwavelets(c,info,fs,’dynrange’,90);
figure(2);
[g,a] = dtwfb2filterbank({’qshift3’,J});
filterbankfreqz(g,a,1024,’plot’,’linabs’);
4.3. DUAL-TREE COMPLEX WAVELET TRANSFORM 149
The second example shows a decomposition using a full filter bank tree of depth J:
[f,fs] = greasy;
J = 5;
[c,info] = dtwfb(f,{’qshift4’,J,’full’});
figure(1);
plotwavelets(c,info,fs,’dynrange’,90);
figure(2);
[g,a] = dtwfb2filterbank({’qshift4’,J,’full’});
filterbankfreqz(g,a,1024,’plot’,’linabs’);
150 CHAPTER 4. LTFAT - WAVELETS
f=idtwfb(c,info);
f=idtwfb(c,dualwt,Ls);
Input parameters
c Input coefficients.
Output parameters
f Reconstructed data.
4.3. DUAL-TREE COMPLEX WAVELET TRANSFORM 151
Description
f = idtwfb(c,info) reconstructs signal f from the coefficients c using parameters from info struct.
both returned by dtwfb function.
f = idtwfb(c,dualwt,Ls) reconstructs signal f from the coefficients c using dual-tree filterbank
defined by dualwt. Plese see dtwfb for supported formats. The Ls parameter is mandatory due to the
ambiguity of reconstruction lengths introduced by the subsampling operation. Note that the same flag as in
the dtwfb function have to be used, otherwise perfect reconstruction cannot be obtained. Please see help for
dtwfb for description of the flags.
Examples:
A simple example showing perfect reconstruction using idtwfb:
f = gspi;
J = 7;
wtdef = {’qshift3’,J};
c = dtwfb(f,wtdef);
fhat = idtwfb(c,wtdef,length(f));
% The following should give (almost) zero
norm(f-fhat)
ans =
9.605850455567395e-14
Input parameters
f Input data.
Output parameters
c Coefficients stored in a cell-array.
Description
c=dtwfbtreal(f,dualwt) computes dual-tree complex wavelet coefficients of the real-valued signal
f. The representation is approximately time-invariant and provides analytic behavior. Due to these facts, the
resulting subbands are nearly aliasing free making them suitable for severe coefficient modifications. The
representation is two times redundant, provided critical subsampling of all involved filterbanks, but one half
of the coefficients is complex conjugate of the other.
The shape of the filterbank tree and filters used is controlled by dualwt (for possible formats see
below). The output c is a cell-array with each element containing a single subband. The subbands are
ordered with increasing subband center frequency.
152 CHAPTER 4. LTFAT - WAVELETS
In addition, the function returns struct. info containing transform parameters. It can be conviniently
used for the inverse transform idtwfbreal e.g. fhat = idtwfbreal(c,info). It is also required by
the plotwavelets function.
If f is a matrix, the transform is applied to each column.
Two formats of dualwt are accepted:
1) Cell array of parameters. First two elements of the array are mandatory {dualw,J}.
Possible formats of dualw are the same as in fwtinit except the wfiltdt_ prefix is used when
searching for function specifying the actual impulse responses. These filters were designed
specially for the dual-tree filterbank to achieve the half-sample shift ultimatelly resulting in
analytic (complex) behavior of the transform.
The default shape of the filterbank tree is DWT i.e. only low-pass output is decomposed further
(J times in total).
Different filterbank tree shapes can be obtained by passing additional flag in the cell array.
Supported flags (mutually exclusive) are:
’dwt’ Plain DWT tree (default). This gives one band per octave freq. resolution when using
2 channel basic wavelet filterbank.
’full’ Full filterbank tree. Both (all) basic filterbank outputs are decomposed further up to
depth J achieving linear frequency band division.
’doubleband’,‘’quadband’,’octaband’‘ The filterbank is designed such that it mimics
4-band, 8-band or 16-band complex wavelet transform provided the basic filterbank is 2
channel. In this case, J is treated such that it defines number of levels of 4-band, 8-band
or 16-band transform.
The dual-tree wavelet filterbank can use any basic wavelet filterbank in the first stage of both
trees, provided they are shifted by 1 sample (done internally). A custom first stage filterbank
can be defined by passing the following key-value pair in the cell array:
’first’,‘w‘ w defines a regular basic filterbank. Accepted formats are the same as in fwtinit
assuming the wfilt_ prefix.
Similarly, when working with a filterbank tree containing decomposition of high-pass outputs,
some filters in both trees must be replaced by a regular basic filterbank in order to achieve
the aproximatelly analytic behavior. A custom filterbank can be specified by passing another
key-value pair in the cell array:
’leaf’,‘w‘ w defines a regular basic filterbank. Accepted formats are the same as in fwtinit
assuming the wfilt_ prefix.
2) Another possibility is to pass directly a struct. returned by dtwfbinit and possibly modified by
wfbtremove.
Optional args.:
In addition, the following flag groups are supported:
’freq’,‘’nat’‘ Frequency or natural (Paley) ordering of coefficient subbands. By default, subbands are
ordered according to frequency. The natural ordering is how the subbands are obtained from the
filterbank tree without modifications. The ordering differ only in non-plain DWT case.
Boundary handling:
In contrast with fwt, wfbt and wpfbt, this function supports periodic boundary handling only.
4.3. DUAL-TREE COMPLEX WAVELET TRANSFORM 153
Examples:
A simple example of calling the dtwfbreal function using the regular DWT iterated filterbank. The second
figure shows a magnitude frequency response of an identical filterbank.:
[f,fs] = greasy;
J = 6;
[c,info] = dtwfbreal(f,{’qshift3’,J});
figure(1);
plotwavelets(c,info,fs,’dynrange’,90);
figure(2);
[g,a] = dtwfb2filterbank({’qshift3’,J},’real’);
filterbankfreqz(g,a,1024,’plot’,’linabs’);
The second example shows a decomposition using a full filterbank tree of depth J:
[f,fs] = greasy;
J = 5;
[c,info] = dtwfbreal(f,{’qshift4’,J,’full’});
figure(1);
plotwavelets(c,info,fs,’dynrange’,90);
figure(2);
[g,a] = dtwfb2filterbank({’qshift4’,J,’full’},’real’);
filterbankfreqz(g,a,1024,’plot’,’linabs’);
154 CHAPTER 4. LTFAT - WAVELETS
f=idtwfbreal(c,info);
f=idtwfbreal(c,dualwt,Ls);
Input parameters
c Input coefficients.
Output parameters
f Reconstructed data.
4.4. WAVELET FILTERBANK TREES MANIPULATION 155
Description
f = idtwfbreal(c,info) reconstructs real-valued signal f from the coefficients c using parameters
from info struct. both returned by dtwfbreal function.
f = idtwfbreal(c,dualwt,Ls) reconstructs real-valued signal f from the coefficients c using
dual-tree filterbank defined by dualwt. Plese see dtwfbreal for supported formats. The Ls parameter is
mandatory due to the ambiguity of reconstruction lengths introduced by the subsampling operation. Note
that the same flag as in the dtwfbreal function have to be used, otherwise perfect reconstruction cannot be
obtained. Please see help for dtwfbreal for description of the flags.
Examples:
A simple example showing perfect reconstruction using idtwfbreal:
f = gspi;
J = 7;
wtdef = {’qshift3’,J};
c = dtwfbreal(f,wtdef);
fhat = idtwfbreal(c,wtdef,length(f));
% The following should give (almost) zero
norm(f-fhat)
This code produces the following output:
ans =
9.605850455567395e-14
Input parameters
wtdef Filterbank tree definition.
Output parameters
wt Structure describing the filter tree.
Description
wfbtinit({w,J,flag}) creates a filterbank tree of depth J. The parameter w defines a basic wavelet
filterbank. For all possible formats see fwt. The following optional flags (still inside of the cell-array) are
recognized:
’dwt’,’full’,’doubleband’,’quadband’,’octaband’ Type of the tree to be created.
wfbtinit({w,J,flag,’mod’,mod}) creates a filterbank tree as before, but modified according
to the value of mod. Recognized options:
’powshiftable’ Changes subsampling factors of the root to 1. This results in redundant near-shift
invariant representation.
The returned structure wt has the following fields:
.nodes Cell-array of structures obtained from fwtinit. Each element define a basic wavelet filterbank.
156 CHAPTER 4. LTFAT - WAVELETS
Input parameters
dualwtdef Dual-tree filterbank definition.
Output parameters
dualwt Dual-tree filtarbank structure.
Description
dtwfinit() (a call without aguments) creates an empty structure. It has the same fields as the struct.
returned from wfbtinit plus a field to hold nodes from the second tree:
.nodes Filterbank nodes of the first tree
.dualnodes Filterbank nodes of the second tree
.children Indexes of children nodes
.parents Indexes of a parent node
.forder Frequency ordering of the resultant frequency bands.
dtwfinit({dualw,J,flag}) creates a structure representing a dual-tree wavelet filterbank of
depth J, using dual-tree wavelet filters specified by dualw. The shape of the tree is controlled by flag.
Please see help on dtwfb or dtwfbreal for description of the parameters.
[dualwt,info]=dtwfinit(...) additionally returns info struct which provides some infor-
mation about the computed window:
info.tight True if the overall tree construct a tight frame.
info.dw A structure containing basic dual-tree filters as returned from fwtinit(dualwtdef,’wfiltdt_’).
Input parameters
Output parameters
Description
wfbtput(d,k,w,wt) puts the basic filterbank w to the filter tree structure wt at level d and index(es) k.
The output is a modified tree structure. d and k have to specify unconnected output of the leaf node. Error
is issued if d and k points to already existing node. For possible formats of parameter w see help of fwt.
Parameter wt has to be a structure returned by wfbtinit.
wfbtput(d,k,w,wt,’force’) does the same but replaces node at d and k if it already exists. If
the node to be replaced has any children, the number of outputs of the replacing node have to be equal to
number of outputs of the node beeing replaced.
Examples:
This example shows magnitude frequency responses of a tree build from the root:
Input parameters
d Level in the tree (0 - root).
Output parameters
wt Modified filterbank structure.
Description
wfbtremove(d,kk,wt) removes existing node at level d and index kk from the filterbank tree structure
wt. The function fails if the node has any children (it is not a leaf node).
wfbtremove(d,k,wt,’force’) does the same, but any childern of the node are removed too.
Examples:
The following example shows magnitude frequency responses of filterbank tree before and after prunning.:
subplot(2,1,1);
filterbankfreqz(g1,a1,1024,’plot’,’posfreq’,’linabs’);
subplot(2,1,2);
filterbankfreqz(g2,a2,1024,’plot’,’posfreq’,’linabs’);
[g,a] = wfbt2filterbank(wt)
Input parameters
Output parameters
Description
’freq’‘(default),’nat’‘ The filters are ordered to produce subbands in the same order as wfbt with
the same flag.
Examples:
The following two examples create a multirate identity filterbank using a tree of depth 3. In the first example,
the filterbank is identical to the DWT tree:
[g,a] = wfbt2filterbank({’db10’,3,’dwt’});
filterbankfreqz(g,a,1024,’plot’,’linabs’,’posfreq’);
In the second example, the filterbank is identical to the full wavelet tree:
[g,a] = wfbt2filterbank({’db10’,3,’full’});
filterbankfreqz(g,a,1024,’plot’,’linabs’,’posfreq’);
Input parameters
wt Wavelet filter tree definition
4.4. WAVELET FILTERBANK TREES MANIPULATION 161
Output parameters
Description
wpfbt2filterbank(wt) calculates the impulse responses g and the subsampling factors a of non-
iterated filterbank, which is equivalent to the wavelet packet filterbank tree described by wt. The returned
parameters can be used directly in filterbank, ufilterbank or filterbank.
Please see help on wfbt for description of wt. The function additionally support the following flags:
’freq’‘(default),’nat’‘ The filters are ordered to produce subbands in the same order as wpfbt with
the same flag.
Examples:
The following two examples create a multirate identity filterbank using a tree of depth 3. In the first example,
the filterbank is identical to the DWT tree:
[g,a] = wpfbt2filterbank({’db10’,3,’dwt’});
filterbankfreqz(g,a,1024,’plot’,’linabs’,’posfreq’);
In the second example, the filterbank is identical to the full wavelet tree:
[g,a] = wpfbt2filterbank({’db10’,3,’full’});
filterbankfreqz(g,a,1024,’plot’,’linabs’,’posfreq’);
162 CHAPTER 4. LTFAT - WAVELETS
[g,a] = dtwfb2filterbank(dualwt)
[g,a,info] = dtwfb2filterbank(...)
Input parameters
Output parameters
Description
Additional parameters:
’real’ By default, the function returns a filtebank equivalent to dtwfb. The filters can be restricted to
cover only the positive frequencies and to be equivivalent to dtwfbreal by passing a ’real’ flag.
’freq’‘(default),’nat’‘ The filters are ordered to produce subbands in the same order as dtwfb or
dtwfbreal with the same flag.
4.4. WAVELET FILTERBANK TREES MANIPULATION 163
Examples:
The following two examples create a multirate identity filterbank using a duel-tree of depth 3:
[g,a] = dtwfb2filterbank({’qshift3’,3},’real’);
filterbankfreqz(g,a,1024,’plot’,’linabs’);
In the second example, the filterbank is identical to the full wavelet tree:
[g,a] = dtwfb2filterbank({’qshift3’,3,’full’},’real’);
filterbankfreqz(g,a,1024,’plot’,’linabs’);
Input parameters
wdef Wavelet filters specification.
prefix Function name prefix
164 CHAPTER 4. LTFAT - WAVELETS
Output parameters
w Structure defining the filterbank.
Description
fwtinit(wdef) produces a structure describing the analysis (field w.h) and synthesis (field w.g) fil-
terbanks and a hop factors (field w.a) of a basic wavelet-type filterbank defined by wdef.
The analysis filterbank w.h is by default used in fwt and the synthesis filterbank w.g in ifwt.
Both w.h and w.g are cell arrays of structs defining FIR filters compatible with filterbank, ifilterbank
and related functions. More preciselly, each elemement of either cell array is a struct with fields .h and
.offset defining impulse response and the initial shift respectivelly.
[w,info]=fwtinit(...) additionally returns a info struct which provides some information
about the wavelet filterbank:
info.istight Wavelet filterbank forms a tight frame. In such case, w.h and w.g are
identical.
The function is a wrapper for calling all the functions with the wfilt_ prefix defined in the LTFAT
wavelets directory.
The possible formats of the wdef are the following:
1) Cell array with first element being the name of the function defining the basic wavelet filters
(wfilt_ prefix) and the other elements are the parameters of the function.
2) Character string as concatenation of the name of the wavelet filters defining function (as above)
and the numeric parameters delimited by ’:’ character. Examples:
{’db’,10} or ’db10’ Daubechies with 10 vanishing moments. It calls wfilt_db(10)
internally.
{’spline’,4,4} or ’spline4:4’ Biorthogonal spline wavelet filters with 4 vanishing
moments. Calls wfilt_spline(4,4) internally.
{’dden’,1} or ’dden1’ Double density wavelet filters. Calls wfilt_dden(1) where
the filters are stored as numerical vectors.
3) Cell array of one dimensional numerical vectors directly defining the wavelet filter impulse
responses. By default, outputs of the filters are subsampled by a factor equal to the number
of the filters. Pass additional key-value pair ’a’,a (still inside of the cell array) to define the
custom subsampling factors, e.g.: {h1,h2,’a’,[2,2]}.
4) The fourth option is to pass again the structure obtained from the fwtinit function. The structure
is checked whether it has a valid format.
5) Two element cell array. First element is the string ’dual’ and the second one is in format 1),
2) or 4). This returns a dual of whatever is passed as the second argument.
6) Two element cell array. First element is the string ’strict’ and the second one is in format
1), 2), 4) or 5). This in the non tight case the filters has to be defined explicitly using ’ana’
and ’syn’ identifiers. See below.
7) Two element cell array. First element is a cell array of structures defining FIR filterbank (.h and
.offset fields) as in filterbankwin and the second element is a numeric vector of subsampling
factors.
One can interchange the filter in w.h and w.g and use the filterbank indended for synthesis in fwt and
vice versa by re-using the items 1) and 2) in the following way:
1) Add ’ana’ or ’syn’ as the first element in the cell array e.g. {’ana’,’spline’,4,4}
or {’syn’,’spline’,4,4}.
2) Add ’ana:’ or ’syn:’ to the beginning of the string e.g. ’ana:spline4:4’ or ’syn:spline4:4’.
4.5. FRAME PROPERTIES OF WAVELET FILTER BANKS: 165
This only makes difference if the filterbanks are biorthogonal (e.g. wfilt_spline) or a general
frame (e.g. ’symds2’), in other cases, the analysis and synthesis filters are identical.
Please note that using e.g. c=fwt(f,’ana:spline4:4’,J) and fhat=ifwt(c,’ana:spline4:4’,J,size(f,
will not give a perfect reconstruction.
The output structure has the following additional field:
w.origArgs Original parameters in format 1).
References: [61]
Description
wfbtbounds(wt,L) calculates the ratio B/A of the frame bounds of the filterbank tree specified by wt
for a system of length L. The ratio is a measure of the stability of the system.
wfbtbounds({w,J,’dwt’},L) calculates the ratio B/A of the frame bounds of the DWT (fwt)
filterbank specified by w and J for a system of length L.
wfbtbounds(wt) does the same thing, but L is assumed to be the next compatible length bigger than
the longest filter in the identical filterbank.
[A,B]=wfbtbounds(...) returns the lower and upper frame bounds explicitly.
See wfbt for explanation of parameter wt and fwt for explanation of parameters w and J.
The function supports the following flag groups:
’scaling_notset’‘(default),’noscale’,’scale’,’sqrt’‘ Support for scaling flags as described
in uwfbt. By default, the bounds are computed for wfbt, passing any of the non-default flags results
in framebounds for uwfbt.
Description
wpfbtbounds(wt,L) calculates the ratio B/A of the frame bounds of the wavelet packet filterbank
specified by wt for a system of length L. The ratio is a measure of the stability of the system.
wpfbtbounds(wt) does the same, except L is chosen to be the next compatible length bigger than
the longest filter from the identical filterbank.
[A,B]=wpfbtbounds(...) returns the lower and upper frame bounds explicitly.
See wfbt for explanation of parameter wt.
Additionally, the function accepts the following flags:
’intsqrt’‘(default),’intnoscale’, ‘’intscale’ The filters in the filterbank tree are scaled to
reflect the behavior of wpfbt and iwpfbt with the same flags.
’scaling_notset’‘(default),’noscale’,’scale’,’sqrt’‘ Support for scaling flags as described
in uwpfbt. By default, the bounds are caltulated for wpfbt, passing any of the non-default flags
results in bounds for uwpfbt.
166 CHAPTER 4. LTFAT - WAVELETS
Description
dtwfbbounds(dualwt,L) calculates the ratio B/A of the frame bounds of the dual-tree filterbank
specified by dualwt for a system of length L. The ratio is a measure of the stability of the system.
dtwfbbounds(dualwt) does the same thing, but L is the next compatible length bigger than the
longest filter in the identical filterbank.
[A,B]=dtwfbbounds(...) returns the lower and upper frame bounds explicitly.
See dtwfb for explanation of parameter dualwt.
4.6 Plots
4.6.1 PLOTWAVELETS - Plot wavelet coefficients
Usage
plotwavelets(c,info,fs)
plotwavelets(c,info,fs,’dynrange’,dynrange,...)
Description
plotwavelets(c,info) plots the wavelet coefficients c using additional parameters from struct. info.
Both parameters are returned by any forward transform function in the wavelets directory.
plotwavelets(c,info,fs) does the same plot assuming a sampling rate fs Hz of the original
signal.
plowavelets(c,info,fs,’dynrange’,dynrange) additionally limits the dynamic range.
C=plotwavelets(...) returns the processed image data used in the plotting. Inputting this data
directly to imagesc or similar functions will create the plot. This is usefull for custom post-processing of
the image data.
plotwavelets supports optional parameters of tfplot. Please see the help of tfplot for an exhaustive
list.
Input parameters
w Basic wavelet filterbank.
Description
wfiltinfo(w) plots impulse responses, frequency responses and approximation of the scaling and of
the wavelet function(s) associated with the wavelet filters defined by w in a single figure. Format of w is the
same as in fwt.
Optionally it is possible to define scaling of the y axis of the frequency seponses. Supported are:
Examples:
Details of the ’syn:spline8:8’ wavelet filters (see wfilt_spline):
wfiltinfo(’syn:spline8:8’);
Input parameters
dw Wavelet dual-tree filterbank
Description
wfiltdtinfo(w) plots impulse responses, frequency responses and approximation of the scaling and of
the wavelet function(s) associated with the dual-tree wavelet filters defined by w in a single figure. Format
of dw is the same as in dtwfb.
168 CHAPTER 4. LTFAT - WAVELETS
Examples:
wfiltdtinfo(’qshift4’);
4.7 Auxilary
4.7.1 WAVFUN - Wavelet Function
Usage
[w,s,xvals] = wavfun(g)
[w,s,xvals] = wavfun(g,N)
Input parameters
w Wavelet filterbank
N Number of iterations
Output parameters
Description
Iteratively generate (N iterations) a discrete approximation of wavelet and scaling functions using filters
obtained from w. The possible formats of w are the same as for the fwt function. The algorithm is equal to
the DWT reconstruction of a single coefficient at level N + 1 set to 1. xvals contains correct x-axis values.
All but last columns belong to the wfunc, last one to the sfunc.
The following flags are supported (first is default):
’fft’, ’conv’ How to do the computations. Whatever is faster depends on the speed of the conv2
function.
aN − 1
L= (m − 1) + 1
a−1
where a is subsamling factor after the lowpass filter in the wavelet filterbank and m is length of the filters.
Expect issues for high N e.g. ’db10’ (m = 20) and N = 20 yields a ~150MB array.
Examples:
Approximation of a Daubechies wavelet and scaling functions from the 12 tap filters:
[wfn,sfn,xvals] = wavfun(’db6’);
plot(xvals,[wfn,sfn]);
legend(’wavelet function’,’scaling function’);
[cvec,Lc] = wavcell2pack(ccell);
[cvec,Lc] = wavcell2pack(ccell,dim);
Input parameters
Output parameters
cvec Coefficients in packed format.
Lc Vector containing coefficients lengths.
Description
[cvec,Lc] = wavcell2pack(ccell) assembles a column vector or a matrix cvec using elements
of the cell-array ccell in the following manner:
cvec(1+sum(Lc(1:j-1)):sum(Lc(1:j),:)=ccell{j};
where Lc is a vector of length numel(ccell) containing number of rows of each element of ccell.
[cvec,Lc] = wavcell2pack(ccell,dim) with dim==2 returns a transposition of the previ-
ous.
Input parameters
cvec Coefficients in packed format.
Lc Vector containing coefficients lengths.
dim Dimension along which the data were transformed.
Output parameters
ccell Coefficients stored in a cell-array. Each element is a column vector or
a matrix.
dim Return used dim. Usefull as an input of the complementary function
wavcell2pack.
Description
ccell = wavpack2cell(cvec,Lc) copies coefficients from a single column vector or columns of
a matrix cvec of size [sum(Lc), W] to the cell array ccell of length length(Lc). Size of j-th element
of ccell is [Lc(j), W] and it is obtained by:
ccell{j}=cvec(1+sum(Lc(1:j-1)):sum(Lc(1:j),:);
ccell = wavpack2cell(cvec,Lc,dim) allows specifying along which dimension the coef-
ficients are stored in cvec. dim==1 (default) considers columns (as above) and dim==2 rows to be co-
efficients belonging to separate channels. Other values are not supported. For dim=2, cvec size is [W,
sum(Lc)], Size of j-th element of ccell is [Lc(j), W] and it is obtained by:
ccell{j}=cvec(:,1+sum(Lc(1:j-1)):sum(Lc(1:j)).’;
Description
[h,g,a]=wfilt_algmband(K) with K ∈ 1, 2 returns wavelet filters from the reference paper. The
filters are 3-band (K == 1) and 4-band (K == 2) with critical subsampling.
Examples:
wfiltinfo(’algmband1’);
wfiltinfo(’algmband2’);
References: [57]
Input parameters
M Number of channels.
172 CHAPTER 4. LTFAT - WAVELETS
Description
Examples:
wfiltinfo(’cmband3’);
wfiltinfo(’cmband4’);
wfiltinfo(’cmband5’);
4.8. WAVELET FILTERS DEFINED IN THE TIME-DOMAIN 173
References: [38]
[h,g,a] = wfilt_coif(K);
Description
Examples:
wfiltinfo(’coif2’);
wfiltinfo(’coif5’);
174 CHAPTER 4. LTFAT - WAVELETS
References: [24]
Input parameters
N Order of Daubechies filters.
Output parameters
H cell array of analysing filters impulse reponses
Description
[H,G] = dbfilt(N) computes a two-channel Daubechies FIR filterbank from prototype maximum-
phase analysing lowpass filter obtained by spectral factorization of the Lagrange interpolator filter. N also
denotes the number of zeros at z = −1 of the lowpass filters of length 2N. The prototype lowpass filter has
the following form (all roots of R(z) are outside of the unit circle):
N
Hl (z) = 1 + z−1 R(z),
where R(z) is a spectral factor of the Lagrange interpolator P(z) = 2R(z) * R(z−1 ) All subsequent filters of
the two-channel filterbank are derived as follows:
Hh (z) = Hl ((−z)−1 )
Gl (z) = Hl (z−1 )
Examples:
wfiltinfo(’db8’);
References: [24]
Description
[h,g,a]=wfilt_dden(N) computes oversampled dyadic double-density DWT filters. The redun-
dancy of the basic filterbank is equal to 1.5.
Examples:
wfiltinfo(’dden5’);
References: [72]
176 CHAPTER 4. LTFAT - WAVELETS
Usage
[h,g,a] = wfilt_dgrid(N);
Description
Examples:
wfiltinfo(’dgrid3’);
References: [1]
Usage
[h,g,a] = wfilt_hden(K);
Description
[h,g,a]=wfilt_hden(K) with K ∈ 1, 2, 3, 4 returns Higher DENsity dwt filters (tight frame, frame)
from the reference. The filterbanks have 3 channels and unusual non-uniform subsamplig factors [2,2,1].
Examples:
wfiltinfo(’hden3’);
4.8. WAVELET FILTERS DEFINED IN THE TIME-DOMAIN 177
wfiltinfo(’ana:hden4’);
References: [83]
[h,g,a]=wfilt_lemarie(N)
Input parameters
Description
Examples:
wfiltinfo(’lemarie50’);
References: [63]
[h,g,a] = wfilt_matlabwrapper(wname);
Description
[h,g,a] = wfilt_mband(N);
Description
Examples:
wfiltinfo(’mband1’);
4.8. WAVELET FILTERS DEFINED IN THE TIME-DOMAIN 179
References: [7]
Usage
[h,g,a]=wfilt_remez(L,K,B)
Input parameters
Description
Examples:
wfiltinfo(’remez50:2:0.1’);
180 CHAPTER 4. LTFAT - WAVELETS
References: [80]
[h,g,a] = wfilt_symds(K);
Description
Examples:
wfiltinfo(’ana:symds3’);
wfiltinfo(’syn:symds3’);
4.8. WAVELET FILTERS DEFINED IN THE TIME-DOMAIN 181
References: [3]
Input parameters
m Number of zeros at z = −1 of the lowpass filter in g{1}
Description
[h,g,a]=wfilt_spline(m,n) with m + n being even returns biorthogonal spline wavelet filters.
Examples:
wfiltinfo(’ana:spline4:2’);
wfiltinfo(’syn:spline4:2’);
182 CHAPTER 4. LTFAT - WAVELETS
[h,g,a]=wfilt_sym(N);
Description
Examples:
wfiltinfo(’sym8’);
References: [24]
4.8. WAVELET FILTERS DEFINED IN THE TIME-DOMAIN 183
[h,g,a] = wfilt_symdden(K);
Description
Examples:
wfiltinfo(’symdden1’);
wfiltinfo(’symdden2’);
References: [85]
184 CHAPTER 4. LTFAT - WAVELETS
[h,g,a] = wfilt_symorth(N);
Description
Examples:
wfiltinfo(’ana:symorth2’);
wfiltinfo(’syn:symorth2’);
References: [4]
4.8. WAVELET FILTERS DEFINED IN THE TIME-DOMAIN 185
Description
[h,g,a]=wfilt_symtight(K) with K ∈ 1, 2 returns 4-band symmetric nearly shift-invariant tight
framelets.
Examples:
wfiltinfo(’symtight1’);
wfiltinfo(’symtight2’);
References: [2]
Description
Examples:
figure(1);
wfiltinfo(’qshifta3’);
Usage
[h,g,a] = wfilt_qshiftb(N);
Description
Examples:
figure(1);
wfiltinfo(’qshiftb3’);
4.8. WAVELET FILTERS DEFINED IN THE TIME-DOMAIN 187
[h,g,a] = wfilt_oddevena(N);
Description
Examples:
figure(1);
wfiltinfo(’ana:oddevena1’);
figure(2);
wfiltinfo(’syn:oddevena1’);
188 CHAPTER 4. LTFAT - WAVELETS
References: [50]
[h,g,a] = wfilt_oddevenb(N);
Description
Examples:
figure(1);
wfiltinfo(’ana:oddevenb1’);
figure(2);
wfiltinfo(’syn:oddevenb1’);
4.8. WAVELET FILTERS DEFINED IN THE TIME-DOMAIN 189
References: [50]
Description
[h,g,a]=wfiltdt_optsyma(N) with N ∈ 1, 2, 3 returns filters suitable with optimized symmetry
suitable for for dual-tree complex wavelet transform tree A.
Examples:
wfiltinfo(’optsyma3’);
References: [29]
Description
Examples:
wfiltinfo(’optsymb3’);
References: [29]
Usage
[h,g,a] = wfilt_ddena(N);
Description
[h,g,a]=wfil_ddena(N) with N ∈ 1, 2 returns filters suitable for dual-tree double density complex
wavelet transform tree A.
Examples:
wfiltinfo(’ddena1’);
4.8. WAVELET FILTERS DEFINED IN THE TIME-DOMAIN 191
References: [82]
[h,g,a] = wfilt_ddenb(N);
Description
[h,g,a]=wfilt_ddenb(N) with N ∈ 1, 2 returns filters suitable for dual-tree double density complex
wavelet transform tree A.
Examples:
wfiltinfo(’ddena1’);
References: [82]
192 CHAPTER 4. LTFAT - WAVELETS
[h,g,a] = wfiltdt_qshift(N);
Description
Examples:
wfiltdtinfo(’qshift3’);
[h,g,a] = wfiltdt_optsym(N);
Description
Examples:
wfiltdtinfo(’optsym3’);
4.9. DUAL-TREE FILTERS 193
References: [29]
Description
[h,g,a]=wfilt_oddeven(N) with N ∈ 1 returns the original odd and even symmetric filters suitable
for dual-tree complex wavelet transform. The filters in individual trees are biorthogonal.
Examples:
wfiltdtinfo(’ana:oddeven1’);
References: [50]
Description
[h,g,a]=wfiltdt_dden(N) with N ∈ 1, 2 returns filters suitable for dual-tree double density complex
wavelet transform.
Examples:
wfiltdtinfo(’dden1’);
wfiltdtinfo(’dden2’);
References: [82]
Chapter 5
LTFAT - Filterbanks
Description
filterbank(f,g,a) applies the filters given in g to the signal f. Each subband will be subsampled by
a factor of a (the hop-size). In contrast to ufilterbank, a can be a vector so the hop-size can be channel-
dependant. If f is a matrix, the transformation is applied to each column.
The filters g must be a cell-array, where each entry in the cell array corresponds to an FIR filter.
The output coefficients are stored a cell array. More precisely, the n’th cell of c, c{m}, is a 2D matrix
of size M(n) ×W and containing the output from the m’th channel subsampled at a rate of a(m). c{m}(n,l)
is thus the value of the coefficient for time index n, frequency index m and signal channel l.
The coefficients c computed from the signal f and the filterbank with windows g_m are defined by
L−1
cm (n + 1) = ∑ f (l + 1) g (am n − l + 1)
l=0
Description
ufilterbank(f,g,a) applies the filter given in g to the signal f. Each subband will be subsampled by
a factor of a (the hop-size). If f is a matrix, the transformation is applied to each column.
The filters g must be a cell-array, where each entry in the cell array corresponds to a filter.
If f is a single vector, then the output will be a matrix, where each column in f is filtered by the
corresponding filter in g. If f is a matrix, the output will be 3-dimensional, and the third dimension will
correspond to the columns of the input signal.
The coefficients c computed from the signal f and the filterbank with windows g_m are defined by
L−1
c (n + 1, m + 1) = ∑ f (l + 1) g (an − l + 1)
l=0
195
196 CHAPTER 5. LTFAT - FILTERBANKS
Description
ifilterbank(c,g,a) synthesizes a signal f from the coefficients c using the filters stored in g for a
channel subsampling rate of a (the hop-size). The coefficients has to be in the format returned by either
filterbank or ufilterbank.
The filter format for g is the same as for filterbank.
If perfect reconstruction is desired, the filters must be the duals of the filters used to generate the coeffi-
cients. See the help on filterbankdual.
References: [17]
5.1.4 FILTERBANKWIN - Compute set of filter bank windows from text or cell
array
Usage
[g,info] = filterbankwin(g,a,L);
Description
[g,info]=filterbankwin(g,a,L) computes a window that fits well with time shift a and trans-
form length L. The window itself is as a cell array containing additional parameters.
The window can be specified directly as a cell array of vectors of numerical values. In this case,
filterbankwin only checks assumptions about transform sizes etc.
[g,info]=filterbankwin(g,a) does the same, but the windows must be FIR windows, as the
transform length is unspecified.
filterbankwin(...,’normal’) computes a window for regular filterbanks, while filterbankwin(...,’real’
does the same for the positive-frequency only filterbanks.
The window can also be specified as cell array. The possibilities are:
{’dual’,...} Canonical dual window of whatever follows. See the examples below.
{’realdual’,...} Canonical dual window for a positive-frequency filterbank of what-
ever follows. See the examples below.
{’tight’,...} Canonical tight window of whatever follows. See the examples below.
{’realtight’,...} Canonical tight window for a real-valued for a positive frequency
filterbank of whatever follows.
The structure info provides some information about the computed window:
L=filterbanklength(Ls,a);
Description
filterbanklength(Ls,a) returns the length of a filterbank with time shifts a, such that it is long
enough to expand a signal of length Ls.
If the filterbank length is longer than the signal length, the signal will be zero-padded by filterbank or
ufilterbank.
If instead a set of coefficients are given, call filterbanklengthcoef.
L=filterbanklengthcoef(coef,a);
Description
filterbanklengthcoef(coef,a) returns the length of a filterbank with time-shifts a, such that the
filterbank is long enough to expand the coefficients coef.
If instead a signal is given, call filterbanklength.
[c,Ls,g,shift,M] = cqt(f,fmin,fmax,bins,fs,M)
[c,Ls,g,shift,M] = cqt(f,fmin,fmax,bins,fs)
[c,Ls,g,shift] = cqt(...)
[c,Ls] = cqt(...)
c = cqt(...)
Input parameters
Output parameters
Description
This function computes a constant-Q transform via non-stationary Gabor filterbanks. Given the signal f, the
constant-Q parameters fmin, fmax and bins, as well as the sampling rate fs of f, the corresponding constant-
Q coefficients c are given as output. For reconstruction, the length of f and the filterbank parameters can be
returned also.
The transform produces phase-locked coefficients in the sense that each filter is considered to be cen-
tered at 0 and the signal itself is modulated accordingly.
Optional input arguments arguments can be supplied like this:
cqt(f,fmin,fmax,bins,fs,’min_win’,min_win)
Example:
The following example shows analysis and synthesis with cqt and icqt:
[f,fs] = gspi;
fmin = 200;
fmax = fs/2;
[c,Ls,g,shift,M] = cqt(f,fmin,fmax,48,fs);
fr = icqt(c,g,shift,Ls);
rel_err = norm(f-fr)/norm(f);
plotfilterbank(c,Ls./M,[],fs,’dynrange’,60);
5.2. AUDITORY INSPIRED FILTER BANKS 199
Input parameters
c Transform coefficients (matrix or cell array)
g Cell array of Fourier transforms of the analysis windows
shift Vector of frequency shifts
Ls Original signal length (in samples)
dual Synthesize with the dual frame
Output parameters
fr Synthesized signal (Channels are stored in the columns)
Description
Given the cell array c of non-stationary Gabor coefficients, and a set of filters g and frequency shifts shift
this function computes the corresponding constant-Q synthesis.
If dual is set to 1 (default), an attempt is made to compute the canonical dual frame for the system given
by g, shift and the size of the vectors in c. This provides perfect reconstruction in the painless case, see the
references for more information.
References: [93], [43]
Input parameters
f The signal to be analyzed (For multichannel signals, input should be a
matrix which each column storing a channel of the signal)
Output parameters
c Transform coefficients (matrix or cell array)
Description
This function computes an ERBlet constant-Q transform via non-stationary Gabor filterbanks. Given the
signal f, the ERBlet parameter bins, as well as the sampling rate fs of f, the corresponding ERBlet coeffi-
cients c are given as output. For reconstruction, the length of f and the filterbank parameters can be returned
also.
The transform produces phase-locked coefficients in the sense that each filter is considered to be cen-
tered at 0 and the signal itself is modulated accordingly.
Optional input arguments arguments can be supplied like this:
erblett(f,bins,fs,’Qvar’,Qvar)
Examples:
The following example shows analysis and synthesis with erblett and ierblett:
[f,fs] = gspi;
binsPerERB = 4;
[c,Ls,g,shift,M] = erblett(f,binsPerERB,fs);
fr = ierblett(c,g,shift,Ls);
rel_err = norm(f-fr)/norm(f)
plotfilterbank(c,Ls./M,[],fs,’dynrange’,60);
rel_err =
5.133913799759292e-16
5.3. FILTER GENERATORS 201
References: [66]
Input parameters
c Transform coefficients (matrix or cell array)
g Cell array of Fourier transforms of the analysis windows
shift Vector of frequency shifts
Ls Original signal length (in samples)
dual Synthesize with the dual frame
Output parameters
fr Synthesized signal (Channels are stored in the columns)
Description
Given the cell array c of non-stationary Gabor coefficients, and a set of filters g and frequency shifts shift
this function computes the corresponding ERBlet synthesis.
If dual is set to 1 (default), an attempt is made to compute the canonical dual frame for the system given
by g, shift and the size of the vectors in c. This provides perfect reconstruction in the painless case, see the
references for more information.
References: [66]
Input parameters
fs Sampling rate (in Hz).
fmin Minimum frequency (in Hz)
fmax Maximum frequency (in Hz)
bins Vector consisting of the number of bins per octave.
Ls Signal length.
Output parameters
g Cell array of filters.
a Downsampling rate for each channel.
fc Center frequency of each channel.
L Next admissible length suitable for the generated filters.
Description
[g,a,fc]=cqtfilters(fs,fmin,fmax,bins,Ls) constructs a set of band-limited filters g which
cover the required frequency range fmin-fmax with bins filters per octave starting at fmin. All filters
have (approximately) equal Q = fc / fb , hence constant-Q. The remaining frequency intervals not covered by
these filters are captured by two additional filters (low-pass, high-pass). The signal length Ls is mandatory,
since we need to avoid too narrow frequency windows.
By default, a Hann window on the frequency side is chosen, but the window can be changed by passing
any of the window types from firwin as an optional parameter. Run getfield(getfield(arg_firwin,’flags’),’win
to get a cell array of window types available.
Because the downsampling rates of the channels must all divide the signal length, filterbank will only
work for multiples of the least common multiple of the downsampling rates. See the help of filterbanklength.
[g,a]=cqtfilters(...,’regsampling’) constructs a non-uniform filter bank. The down-
sampling rates are constant in the octaves but can differ among octaves. This approach was chosen in order
to minimize the least common multiple of a, which determines a granularity of admissible input signal
lengths.
[g,a]=cqtfilters(...,’uniform’) constructs a uniform filter bank where the downsam-
pling rate is the same for all the channels. This results in most redundant representation, which produces
nice plots.
[g,a]=cqtfilters(...,’fractional’) constructs a filter bank with fractional downsam-
pling rates a. The rates are constructed such that the filter bank can handle signal lengths that are multiples
of L, so the benefit of the fractional downsampling is that you get to choose the value returned by filterban-
klength. This results in the least redundant system.
[g,a]=cqtfilters(...,’fractionaluniform’) constructs a filter bank with fractional down-
sampling rates a, which are uniform for all filters except the "filling" low-pass and high-pass filters can have
different fractional downsampling rates. This is useful when uniform subsampling and low redundancy at
the same time are desirable.
The filters are intended to work with signals with a sampling rate of fs.
cqtfilters accepts the following optional parameters:
’Qvar’,Qvar Bandwidth variation factor. Multiplies the calculated bandwidth. De-
fault value is 1. If the value is less than one, the system may no longer
be painless.
’subprec’ Allow subsample window positions and bandwidths to better approxi-
mate the constant-Q property.
’complex’ Construct a filter bank that covers the entire frequency range. When
missing, only positive frequencies are covered.
5.3. FILTER GENERATORS 203
Examples:
In the first example, we construct a highly redundant uniform filter bank and visualize the result:
[f,fs]=greasy; % Get the test signal
[g,a,fc]=cqtfilters(fs,100,fs,32,length(f),’uniform’);
c=filterbank(f,g,a);
plotfilterbank(c,a,fc,fs,90,’audtick’);
In the second example, we construct a non-uniform filter bank with fractional sampling that works for
this particular signal length, and test the reconstruction. The plot displays the response of the filter bank to
verify that the filters are well-behaved both on a normal and an log scale. The second plot shows frequency
responses of filters used for analysis (top) and synthesis (bottom).
[f,fs]=greasy; % Get the test signal
L=length(f);
[g,a,fc]=cqtfilters(fs,100,fs,8,L,’fractional’);
c=filterbank(f,{’realdual’,g},a);
r=2*real(ifilterbank(c,g,a));
norm(f-r)
subplot(2,1,2);
semiaudplot(linspace(0,fs/2,L/2+1),R(1:L/2+1));
ylabel(’Magnitude’);
gd=filterbankrealdual(g,a,L);
figure(2);
subplot(2,1,1);
filterbankfreqz(gd,a,L,fs,’plot’,’linabs’,’posfreq’);
subplot(2,1,2);
filterbankfreqz(g,a,L,fs,’plot’,’linabs’,’posfreq’);
ans =
8.299315044804507e-15
[g,a,fc]=erbfilters(fs,Ls);
[g,a,fc]=erbfilters(fs,Ls,...);
5.3. FILTER GENERATORS 205
Input parameters
fs Sampling rate (in Hz).
Ls Signal length.
Output parameters
g Cell array of filters.
a Downsampling rate for each channel.
fc Center frequency of each channel.
L Next admissible length suitable for the generated filters.
Description
[g,a,fc]=erbfilters(fs,Ls) constructs a set of filters g that are equidistantly spaced on the ERB-
scale (see freqtoerb) with bandwidths that are proportional to the width of the auditory filters audfiltbw. The
filters are intended to work with signals with a sampling rate of fs. The signal length Ls is mandatory, since
we need to avoid too narrow frequency windows.
By default, a Hann window on the frequency side is choosen, but the window can be changed by passing
any of the window types from firwin as an optional parameter. Run getfield(getfield(arg_firwin,’flags’),’win
to get a cell array of window types available.
The integer downsampling rates of the channels must all divide the signal length, filterbank will only
work for input signal lengths being multiples of the least common multiple of the downsampling rates. See
the help of filterbanklength. The fractional downsampling rates restrict the filterbank to a single length
L=Ls.
[g,a]=erbfilters(...,’regsampling’) constructs a non-uniform filterbank with integer
subsampling factors.
[g,a]=erbfilters(...,’uniform’) constructs a uniform filterbank where the integer down-
sampling rate is the same for all the channels. This results in most redundant representation which produces
nice plots.
[g,a]=erbfilters(...,’fractional’) constructs a filterbank with fractional downsampling
rates a. This results in the least redundant system.
[g,a]=erbfilters(...,’fractionaluniform’) constructs a filterbank with fractional down-
sampling rates a, which are uniform for all filters except the "filling" low-pass and high-pass filters can have
different fractional downsampling rates. This is usefull when uniform subsampling and low redundancy at
the same time are desirable.
erbfilters accepts the following optional parameters:
’spacing’,b Specify the spacing in ERBS between the filters. Default value is b=1.
’M’,M Specify the number of filters, M. If this parameter is specified, it over-
writes the ’spacing’ parameter.
’redmul’,redmul Redundancy multiplier. Increasing the value of this will make the sys-
tem more redundant by lowering the channel downsampling rates. It is
only used if the filterbank is a non-uniform filterbank. Default value is
1. If the value is less than one, the system may no longer be painless.
’symmetric’ Create filters that are symmetric around their centre frequency. This is
the default.’sqrtsquare’,’sqrtrect’
’warped’ Create asymmetric filters that are symmetric on the Erb-scale.
’complex’ Construct a filterbank that covers the entire frequency range.
’bwmul’,bwmul Bandwidth of the filters relative to the bandwidth returned by aud-
filtbw. Default is bwmul = 1.
206 CHAPTER 5. LTFAT - FILTERBANKS
Examples:
In the first example, we construct a highly redudant uniform filterbank and visualize the result:
[f,fs]=greasy; % Get the test signal
[g,a,fc]=erbfilters(fs,length(f),’uniform’,’M’,100);
c=filterbank(f,g,a);
plotfilterbank(c,a,fc,fs,90,’audtick’);
In the second example, we construct a non-uniform filterbank with fractional sampling that works for
this particular signal length, and test the reconstruction. The plot displays the response of the filterbank
to verify that the filters are well-behaved both on a normal and an ERB-scale. The second plot shows
frequency responses of filters used for analysis (top) and synthesis (bottom).
[f,fs]=greasy; % Get the test signal
L=length(f);
[g,a,fc]=erbfilters(fs,L,’fractional’);
c=filterbank(f,{’realdual’,g},a);
r=2*real(ifilterbank(c,g,a));
norm(f-r)
subplot(2,1,2);
semiaudplot(linspace(0,fs/2,L/2+1),R(1:L/2+1));
ylabel(’Magnitude’);
subplot(2,1,2);
filterbankfreqz(g,a,L,fs,’plot’,’linabs’,’posfreq’);
5.3. FILTER GENERATORS 207
ans =
8.470876921240907e-15
References: [66]
Input parameters
freqtoscale Function converting frequency (Hz) to scale units
Ls Signal length.
Output parameters
g Cell array of filters.
Description
[g,a,fc]=warpedfilters(freqtoscale,scaletofreq,fs,fmin,fmax,bins,Ls) con-
structs a set of band-limited filters g which cover the required frequency range fmin-fmax with bins
filters per scale unit. The filters are always centered at full (fractional k/bins) scale units, where the first
filter is selected such that its center is lower than fmin.
By default, a Hann window on the frequency side is choosen, but the window can be changed by passing
any of the window types from firwin as an optional parameter. Run getfield(getfield(arg_firwin,’flags’),’win
to get a cell array of window types available.
With respect to the selected scale, all filters have equal bandwidth and are uniformly spaced on the
scale axis, e.g. if freqtoscale is log(x), then we obtain constant-Q filters with geometric spacing.
The remaining frequency intervals not covered by these filters are captured one or two additional filters
(high-pass always, low-pass if necessary). The signal length Ls is required in order to obtain the optimal
normalization factors.
Attention: When using this function, the user needs to be aware of a number of things:
If any of these guidelines are broken, this function is likely to break or give undesireable results.
By default, a Hann window is chosen as the transfer function prototype, but the window can be changed
by passing any of the window types from firwin as an optional parameter.
The integer downsampling rates of the channels must all divide the signal length, filterbank will only
work for input signal lengths being multiples of the least common multiple of the downsampling rates. See
the help of filterbanklength. The fractional downsampling rates restrict the filterbank to a single length
L=Ls.
[g,a]=warpedfilters(...,’regsampling’) constructs a non-uniform filterbank with inte-
ger subsampling factors.
5.3. FILTER GENERATORS 209
Examples:
In the first example, we use the ERB scale functions freqtoerb and erbtofreq to construct a filter
bank and visualize the result:
In the second example, we look at the same test signal using a constant-Q filter bank with 4 bins per
scale unit and the standard (semi-regular) sampling scheme:
[s,fs] = gspi; % Get a test signal
Ls = numel(gspi);
References: [45]
Input parameters
fs Sampling rate (in Hz).
Ls Signal length.
Output parameters
g Cell array of filters.
Description
[g,a,fc,L]=audfilters(fs,Ls) constructs a set of filters g that are equidistantly spaced on a
perceptual frequency scale (see freqtoaud) between 0 and the Nyquist frequency and with bandwidths that
are proportional to the critical bandwidth of the auditory filters audfiltbw. The filters are intended to work
with signals with a sampling rate of fs. The signal length Ls is mandatory, since we need to avoid too narrow
frequency windows.
By default the ERB scale is chosen but other frequency scales are possible. See ’freqtoaud’ for all
available options. The most scales are ’erb’, ’bark’, and ’mel’.
By default, a Hann window on the frequency side is chosen, but the window can be changed by passing
any of the window types from firwin as an optional parameter. Run getfield(getfield(arg_firwin,’flags’),’win
to get a cell array of window types available.
The integer downsampling rates of the channels must all divide the signal length, filterbank will only
work for input signal lengths being multiples of the least common multiple of the downsampling rates. See
the help of filterbanklength. The fractional downsampling rates restrict the filterbank to a single length
L=Ls.
[g,a,fc,L]=audfilters(fs,Ls,flow,figh) constructs a set of filters that are equidistantly
spaced between flow and fhigh. In that case two additional filters will be positioned at the 0 and Nyquist
frequencies so as to cover the full spectrum. The values of flow and fhigh can be instead specified using a
key/value pair as:
[g,a,fc,L]=audfilters(fs,Ls,...,’flow’,flow,’fhigh’,figh)
’M’,M Specify the total number of filters between ’flow’ and ’fhigh’, M. If
this parameter is specified, it overwrites the ’spacing’ parameter.
5.3. FILTER GENERATORS 213
’redmul’,redmul Redundancy multiplier. Increasing the value of this will make the sys-
tem more redundant by lowering the channel downsampling rates. It is
only used if the filterbank is a non-uniform filterbank. Default value is
1. If the value is less than one, the system may no longer be painless.
’symmetric’ Create filters that are symmetric around their centre frequency. This is
the default.’sqrtsquare’,’sqrtrect’
’warped’ Create asymmetric filters that are asymmetric on the ERB scale. The
warping does not work with other scales yet.
Examples:
In the first example, we construct a highly redudant uniform filterbank on the ERB scale and visualize the
result:
In the second example, we construct a non-uniform filterbank with fractional sampling that works for
this particular signal length, and test the reconstruction. The plot displays the response of the filterbank
to verify that the filters are well-behaved both on a normal and an ERB-scale. The second plot shows
frequency responses of filters used for analysis (top) and synthesis (bottom).
figure(1);
subplot(2,1,1);
R=filterbankresponse(g,a,L,fs,’real’,’plot’);
subplot(2,1,2);
semiaudplot(linspace(0,fs/2,L/2+1),R(1:L/2+1));
ylabel(’Magnitude’);
subplot(2,1,2);
filterbankfreqz(g,a,L,fs,’plot’,’linabs’,’posfreq’);
This code produces the following output:
ans =
8.470876921240907e-15
References: [66]
5.4. WINDOW CONSTRUCTION AND BOUNDS 215
Description
filterbankdual(g,a,L) computes the canonical dual filters of g for a channel subsampling rate of a
(hop-size) and system length L. L must be compatible with subsampling rate a as L==filterbanklength(L,a).
This will create a dual frame valid for signals of length L.
filterabankrealdual(g,a) does the same, but the filters must be FIR filters, as the transform
length is unspecified. L will be set to next suitable length equal or bigger than the longest impulse response
such that L=filterbanklength(gl_longest,a).
The input and output format of the filters g are described in the help of filterbank.
In addition, the funtion recognizes a ’forcepainless’ flag which forces treating the filterbank g and a as
a painless case filterbank.
To actually invert the output of a filterbank, use the dual filters together with the ifilterbank function.
REMARK: In general, perfect reconstruction can be obtained for signals of length L. In some cases,
using dual system calculated for shorter L might work but check the reconstruction error.
Description
filterbanktight(g,a,L) computes the canonical tight filters of g for a channel subsampling rate of
a (hop-size) and a system length L. L must be compatible with subsampling rate a as L==filterbanklength(L,a).
filterbanktight(g,a,L) does the same, but the filters must be FIR filters, as the transform
length is unspecified. L will be set to next suitable length equal or bigger than the longest impulse response.
The input and output format of the filters g are described in the help of filterbank.
REMARK: The resulting system is tight for length L. In some cases, using tight system calculated for
shorter L might work but check the reconstruction error.
Description
filterbankrealdual(g,a,L) computes the canonical dual filters of g for a channel subsampling
rate of a (hop-size) and a system length L. L must be compatible with subsampling rate a as L==filterbanklength(L,a).
The dual filters work only for real-valued signals. Use this function on the common construction where the
filters in g only covers the positive frequencies.
filterabankrealdual(g,a) does the same, but the filters must be FIR filters, as the transform
length is unspecified. L will be set to next suitable length equal or bigger than the longest impulse response.
The format of the filters g are described in the help of filterbank.
216 CHAPTER 5. LTFAT - FILTERBANKS
In addition, the function recognizes a ’forcepainless’ flag which forces treating the filterbank g and a as
a painless case filterbank.
To actually invert the output of a filterbank, use the dual filters together with 2*real(ifilterbank(...)).
REMARK: Perfect reconstruction can be obtained for signals of length L. In some cases, using dual
system calculated for shorter L might work but check the reconstruction error.
Description
filterabankrealtight(g,a,L) computes the canonical tight filters of g for a channel subsampling
rate of a (hop-size) and a system length L. L must be compatible with subsampling rate a as L==filterbanklength(L,a).
The tight filters work only for real-valued signals. Use this function on the common construction where the
filters in g only covers the positive frequencies.
filterabankrealtight(g,a) does the same, but the filters must be FIR filters, as the transform
length is unspecified. L will be set to next suitable length equal or bigger than the longest impulse response.
The format of the filters g are described in the help of filterbank.
REMARK: The resulting system is tight for length L. In some cases, using tight system calculated for
shorter L might work but check the reconstruction error.
Description
filterbankbounds(g,a,L) calculates the ratio B/A of the frame bounds of the filterbank specified
by g and a for a system of length L. The ratio is a measure of the stability of the system.
filterbankbounds(g,a) does the same, but the filters must be FIR filters, as the transform length
is unspecified. L will be set to next suitable length equal or bigger than the longest impulse response such
that L=filterbanklength(gl_longest,a).
[A,B]=filterbankbounds(...) returns the lower and upper frame bounds explicitly.
Description
filterbankrealbounds(g,a,L) calculates the ratio B/A of the frame bounds of the filterbank spec-
ified by g and a for a system of length L. The ratio is a measure of the stability of the system. Use this
function on the common construction where the filters in g only covers the positive frequencies.
5.5. AUXILARY 217
filterbankrealbounds(g,a) does the same, but the filters must be FIR filters, as the transform
length is unspecified. L will be set to next suitable length equal or bigger than the longest impulse response
such that L=filterbanklength(gl_longest,a).
[A,B]=filterbankrealbounds(g,a) returns the lower and upper frame bounds explicitly.
Description
gf=filterbankresponse(g,a,L) computes the total response in frequency of a filterbank specified
by g and a for a signal length of L. This corresponds to summing up all channels. The output is a usefull
tool to investigate the behaviour of the windows, as peaks indicate that a frequency is overrepresented in
the filterbank, while a dip indicates that it is not well represented.
CAUTION: This function computes a sum of squares of modulus of the frequency responses, which
is also the diagonal of the Fourier transform of the frame operator. Use filterbankfreqz for evaluation or
plotting of frequency responses of filters.
filterbankresponse(g,a,L,’real’) does the same for a filterbank intended for positive-
only filterbank.
filterbankresponse(g,a,L,fs) specifies the sampling rate fs. This is only used for plotting
purposes.
gf=filterbankresponse(g,a,L,’individual’) returns responses in frequency of individ-
ual filters as columns of a matrix. The total response can be obtained by gf = sum(gf,2).
filterbankresponse takes the following optional parameters:
5.5 Auxilary
5.5.1 FILTERBANKFREQZ - Filterbank frequency responses
Usage
gf = filterbankfreqz(g,a,L)
Description
gf = filterbankfreqz(g,a,L) calculates length L frequency responses of filters in g and returns
them as columns of gf.
If an optional parameters ’plot’ is passed to filterbankfreqz, the frequency responses will be
plotted using plotfft. Any optional parameter undestood by plotfft can be passed in addition to ’plot’.
Input parameters
g Filters as a cell array of structs.
a Subsampling factors.
Output parameters
gu Filters as a cell array of structs.
Description
[gu,au]=nonu2ufilterbank(g,a) calculates uniform filterbank gu, au=lcm(a) which is iden-
tical to the (possibly non-uniform) filterbank g, a in terms of the equal output coefficients. Each filter g{k}
is replaced by p(k) = au/a(k) advanced versions of itself such that zma(k) Gk (z) for m = 0, . . . , p − 1.
This allows using the factorisation algorithm when determining filterbank frame bounds in filterbankbounds
and filterbankrealbounds and in the computation of the dual filterbank in filterbankdual and filterbankreal-
dual which do not work with non-uniform filterbanks.
One can change between the coefficient formats of gu, au and g, a using nonu2ucfmt and u2nonucfmt
in the reverse direction.
References: [6]
Input parameters
cu Uniform filterbank coefficients.
Output parameters
c Non-uniform filterbank coefficients.
Description
c = u2nonucfmt(cu,pk) changes the coefficient format from uniform filterbank coefficients cu (M=sum(p)
channels) to non-uniform coefficients c (numel(p) channels) such that each channel of c consinst of p(m)
interleaved channels of cu.
The output c is a cell-array in any case.
References: [6]
Input parameters
c Non-uniform filterbank coefficients.
5.6. PLOTS 219
Output parameters
Description
5.6 Plots
5.6.1 PLOTFILTERBANK - Plot filterbank and ufilterbank coefficients
Usage
plotfilterbank(coef,a);
plotfilterbank(coef,a,fc);
plotfilterbank(coef,a,fc,fs);
plotfilterbank(coef,a,fc,fs,dynrange);
Description
plotfilterbank(coef,a) plots filterbank coefficients coef obtained from either the filterbank or
ufilterbank functions. The coefficients must have been produced with a time-shift of a. For more details on
the format of the variables coef and a, see the help of the filterbank or ufilterbank functions.
plotfilterbank(coef,a,fc) makes it possible to specify the center frequency for each channel
in the vector fc.
plotfilterbank(coef,a,fc,fs) does the same assuming a sampling rate of fs Hz of the orig-
inal signal.
plotfilterbank(coef,a,fc,fs,dynrange) makes it possible to specify the dynamic range
of the coefficients.
C=plotfilterbank(...) returns the processed image data used in the plotting. Inputting this data
directly to imagesc or similar functions will create the plot. This is usefull for custom post-processing of
the image data.
plotfilterbank supports all the optional parameters of tfplot. Please see the help of tfplot for an
exhaustive list.
In addition to the flags and key/values in tfplot, plotfilterbank supports the following optional
arguments:
’fc’,fc Centre frequencies of the channels. fc must be a vector with the length
equal to the number of channels. The default value of [] means to plot
the channel no. instead of its frequency.
’ntickpos’,n Number of tick positions along the y-axis. The position of the ticks
are determined automatically. Default value is 10.
’tick’,t Array of tick positions on the y-axis. Use this option to specify the
tick position manually.
’audtick’ Use ticks suitable for visualizing an auditory filterbank. Same as ’tick’,[0,100,250,500,10
220 CHAPTER 5. LTFAT - FILTERBANKS
Input parameters
f Signal to be analyzed.
Output parameters
tgrad Instantaneous frequency relative to original position.
cs Filterbank spectrogram.
c Filterbank coefficients.
Description
[tgrad,fgrad,s,c] = filterbankphasegrad(f,g,a,L) computes the group delay fgrad
and instantaneous frequency tgrad of the filterbank spectrogram s obtained from the signal f and filter-
bank parameters g and a. Both quantities are specified relative to the original coefficient position. tgrad is
given in samples, while fgrad is given as values on the unit circle, easily converted into relative frequencies
by log(tgrad)/(pi * i). This routine uses the equivalence of the filterbank coefficients in each channel with
coefficients obtained from an STFT obtained with a certain window (possibly different for every channel).
As a consequence of this equivalence, the formulas derived in the reference apply.
References: [10], [44]
Input parameters
s Spectrogram to be reassigned.
g Set of filters.
Output parameters
Lc Subband lengths.
Description
Examples:
f = sin(2*pi*(l/35+(l/300).^2)) + ...
sin(2*pi*(l/10+(l/300).^2)) + ...
sin(2*pi*(l/5-(l/450).^2));
f = 0.7*f’;
References: [44]
Input parameters
c Coefficients to be synchrosqueezed.
tgrad Instantaneous frequency relative to original position.
cfreq Vector of relative center frequencies in ]-1,1].
g Set of filters.
Output parameters
cr Synchrosqueezed filterbank coefficients.
repos Reassigned positions.
Lc Subband lengths.
Description
filterbanksynchrosqueeze(c,tgrad,cfreq) will reassign the values of the filterbank coeffi-
cients c according to instantaneous frequency tgrad. The frequency center frequencies of filters are given
by cfreq. The filterbank coefficients c are assumed to be obtained from a non-subsampled filterbank (a=1).
filterbanksynchrosqueeze(s,tgrad,g) will do the same thing except the center frequen-
cies are estimated from a set of filters g.
[sr,repos,Lc]=filterbanksynchrosqueeze(...) does the same thing, but in addition
returns a vector of subband lengths Lc (Lc = cellfun(@numel,s)) and cell array repos with sum(Lc)
elements. Each element corresponds to a single coefficient obtained by cell2mat(sr) and it is a vector
of indices identifying coefficients from cell2mat(s) assigned to the particular time-frequency position.
The arguments s, tgrad must be cell-arrays of vectors of the same lengths. Arguments cfreq or g must
have the same number of elements as the cell arrays with coefficients.
5.7. REASSIGNMENT AND PHASE GRADIENT 223
Examples:
This example shows how to synchrosqueeze a ERB filterbank spectrogram:
% Genrate 3 chirps half a second long
L = 22050; fs = 44100; l = 0:L-1;
f = sin(2*pi*(l/35+(l/300).^2)) + ...
sin(2*pi*(l/10+(l/300).^2)) + ...
sin(2*pi*(l/5-(l/450).^2));
f = 0.7*f’;
References: [44]
224 CHAPTER 5. LTFAT - FILTERBANKS
Chapter 6
6.1 Transforms
6.1.1 NSDGT - Non-stationary Discrete Gabor transform
Usage
c=nsdgt(f,g,a,M);
[c,Ls]=nsdgt(f,g,a,M);
Input parameters
f Input signal.
g Cell array of window functions.
a Vector of time shifts.
M Vector of numbers of frequency channels.
Output parameters
c Cell array of coefficients.
Ls Length of input signal.
Description
nsdgt(f,g,a,M) computes the non-stationary Gabor coefficients of the input signal f. The signal f can
be a multichannel signal, given in the form of a 2D matrix of size Ls ×W , with Ls the signal length and W
the number of signal channels.
The non-stationary Gabor theory extends standard Gabor theory by enabling the evolution of the window
over time. It is therefor necessary to specify a set of windows instead of a single window. This is done by
using a cell array for g. In this cell array, the n’th element g{n} is a row vector specifying the n’th window.
The resulting coefficients also require a storage in a cell array, as the number of frequency channels
is not constant over time. More precisely, the n’th cell of c, c{n}, is a 2D matrix of size M(n) × W and
containing the complex local spectra of the signal channels windowed by the n’th window g{n} shifted in
time at position a(n). c{n}(m,w) is thus the value of the coefficient for time index n, frequency index m
and signal channel w.
The variable a contains the distance in samples between two consequtive blocks of coefficients. The
variable M contains the number of channels for each block of coefficients. Both a and M are vectors of
integers.
The variables g, a and M must have the same length, and the result c will also have the same length.
The time positions of the coefficients blocks can be obtained by the following code. A value of 0
correspond to the first sample of the signal:
225
226 CHAPTER 6. LTFAT - NON-STATIONARY GABOR SYSTEMS
timepos = cumsum(a)-a(1);
[c,Ls]=nsdgt(f,g,a,M) additionally returns the length Ls of the input signal f. This is handy for
reconstruction:
[c,Ls]=nsdgt(f,g,a,M);
fr=insdgt(c,gd,a,Ls);
will reconstruct the signal f no matter what the length of f is, provided that gd are dual windows of g.
Notes:
nsdgt uses circular border conditions, that is to say that the signal is considered as periodic for windows
overlapping the beginning or the end of the signal.
The phaselocking convention used in nsdgt is different from the convention used in the dgt function.
nsdgt results are phaselocked (a phase reference moving with the window is used), whereas dgt results
are not phaselocked (a fixed phase reference corresponding to time 0 of the signal is used). See the help on
phaselock for more details on phaselocking conventions.
References: [11]
Input parameters
f Input signal.
Output parameters
c Cell array of coefficients.
Description
unsdgt(f,g,a,M) computes the uniform non-stationary Gabor coefficients of the input signal f. The
signal f can be a multichannel signal, given in the form of a 2D matrix of size Ls × W , with Ls being the
signal length and W the number of signal channels.
The non-stationary Gabor theory extends standard Gabor theory by enabling the evolution of the window
over time. It is therefore necessary to specify a set of windows instead of a single window. This is done by
using a cell array for g. In this cell array, the n’th element g{n} is a row vector specifying the n’th window.
However, the uniformity means that the number of channels is fixed.
The resulting coefficients is stored as a M × N ×W array. c(m,n,w) is thus the value of the coefficient
for time index n, frequency index m and signal channel w.
The variable a contains the distance in samples between two consecutive blocks of coefficients. a is a
vectors of integers. The variables g and a must have the same length.
The time positions of the coefficients blocks can be obtained by the following code. A value of 0
correspond to the first sample of the signal:
timepos = cumsum(a)-a(1);
6.1. TRANSFORMS 227
[c,Ls]=nsdgt(f,g,a,M) additionally returns the length Ls of the input signal f. This is handy for
reconstruction:
[c,Ls]=unsdgt(f,g,a,M);
fr=iunsdgt(c,gd,a,Ls);
will reconstruct the signal f no matter what the length of f is, provided that gd are dual windows of g.
Notes:
unsdgt uses circular border conditions, that is to say that the signal is considered as periodic for windows
overlapping the beginning or the end of the signal.
The phaselocking convention used in unsdgt is different from the convention used in the dgt function.
unsdgt results are phaselocked (a phase reference moving with the window is used), whereas dgt results
are not phaselocked (a fixed phase reference corresponding to time 0 of the signal is used). See the help on
phaselock for more details on phaselocking conventions.
References: [11]
f=insdgt(c,g,a,Ls);
Input parameters
Output parameters
f Signal.
Description
insdgt(c,g,a,Ls) computes the inverse non-stationary Gabor transform of the input coefficients c.
insdgt is used to invert the functions nsdgt and unsdgt. Please read the help of these functions for
details of variables format and usage.
For perfect reconstruction, the windows used must be dual windows of the ones used to generate the
coefficients. The windows can be generated using nsgabdual or nsgabtight.
References: [11]
6.1.4 NSDGTREAL - Non-stationary Discrete Gabor transform for real valued sig-
nals
Usage
c=nsdgtreal(f,g,a,M);
[c,Ls]=nsdgtreal(f,g,a,M);
228 CHAPTER 6. LTFAT - NON-STATIONARY GABOR SYSTEMS
Input parameters
f Input signal.
Output parameters
c Cell array of coefficients.
Description
nsdgtreal(f,g,a,M) computes the non-stationary Gabor coefficients of the input signal f. The signal
f can be a multichannel signal, given in the form of a 2D matrix of size Ls × W , with Ls the signal length
and W the number of signal channels.
As opposed to nsdgt only the coefficients of the positive frequencies of the output are returned. nsdgtreal
will refuse to work for complex valued input signals.
The non-stationary Gabor theory extends standard Gabor theory by enabling the evolution of the window
over time. It is therefor necessary to specify a set of windows instead of a single window. This is done by
using a cell array for g. In this cell array, the n’th element g{n} is a row vector specifying the n’th window.
The resulting coefficients also require a storage in a cell array, as the number of frequency channels is
not constant over time. More precisely, the n’th cell of c, c{n}, is a 2D matrix of size M(n)/2 + 1 ×W and
containing the complex local spectra of the signal channels windowed by the n’th window g{n} shifted in
time at position a(n). c{n}(m,l) is thus the value of the coefficient for time index n, frequency index m
and signal channel l.
The variable a contains the distance in samples between two consequtive blocks of coefficients. The
variable M contains the number of channels for each block of coefficients. Both a and M are vectors of
integers.
The variables g, a and M must have the same length, and the result c will also have the same length.
The time positions of the coefficients blocks can be obtained by the following code. A value of 0
correspond to the first sample of the signal:
timepos = cumsum(a)-a(1);
[c,Ls]=nsdgtreal(f,g,a,M);
fr=insdgtreal(c,gd,a,Ls);
will reconstruct the signal f no matter what the length of f is, provided that gd are dual windows of g.
Notes:
nsdgtreal uses circular border conditions, that is to say that the signal is considered as periodic for
windows overlapping the beginning or the end of the signal.
The phaselocking convention used in nsdgtreal is different from the convention used in the dgt func-
tion. nsdgtreal results are phaselocked (a phase reference moving with the window is used), whereas
dgt results are not phaselocked (a fixed phase reference corresponding to time 0 of the signal is used). See
the help on phaselock for more details on phaselocking conventions.
References: [11]
6.1. TRANSFORMS 229
Input parameters
f Input signal.
g Cell array of window functions.
a Vector of time positions of windows.
M Vector of numbers of frequency channels.
Output parameters
c Cell array of coefficients.
Ls Length of input signal.
Description
unsdgtreal(f,g,a,M) computes the non-stationary Gabor coefficients of the input signal f. The signal
f can be a multichannel signal, given in the form of a 2D matrix of size Ls × W , with Ls the signal length
and W the number of signal channels.
As opposed to nsdgt only the coefficients of the positive frequencies of the output are returned. unsdgtreal
will refuse to work for complex valued input signals.
The non-stationary Gabor theory extends standard Gabor theory by enabling the evolution of the window
over time. It is therefore necessary to specify a set of windows instead of a single window. This is done by
using a cell array for g. In this cell array, the n’th element g{n} is a row vector specifying the n’th window.
The uniformity means that the number of channels is not allowed to vary over time.
The resulting coefficients is stored as a M/2 + 1 × N × W array. c(m,n,l) is thus the value of the
coefficient for time index n, frequency index m and signal channel l.
The variable a contains the distance in samples between two consecutive blocks of coefficients. The
variable M contains the number of channels for each block of coefficients. Both a and M are vectors of
integers.
The variables g, a and M must have the same length, and the result c will also have the same length.
The time positions of the coefficients blocks can be obtained by the following code. A value of 0
correspond to the first sample of the signal:
timepos = cumsum(a)-a(1);
[c,Ls]=unsdgtreal(f,g,a,M) additionally returns the length Ls of the input signal f. This is
handy for reconstruction:
[c,Ls]=unsdgtreal(f,g,a,M);
fr=insdgtreal(c,gd,a,Ls);
will reconstruct the signal f no matter what the length of f is, provided that gd are dual windows of g.
Notes:
unsdgtreal uses circular border conditions, that is to say that the signal is considered as periodic for
windows overlapping the beginning or the end of the signal.
The phaselocking convention used in unsdgtreal is different from the convention used in the dgt
function. unsdgtreal results are phaselocked (a phase reference moving with the window is used),
whereas dgt results are not phaselocked (a fixed phase reference corresponding to time 0 of the signal is
used). See the help on phaselock for more details on phaselocking conventions.
References: [11]
230 CHAPTER 6. LTFAT - NON-STATIONARY GABOR SYSTEMS
f=insdgt(c,g,a,M,Ls);
Input parameters
Output parameters
f Signal.
Description
insdgt(c,g,a,Ls) computes the inverse non-stationary Gabor transform of the input coefficients c.
insdgt is used to invert the functions nsdgt and unsdgt. Please read the help of these functions for
details of variables format and usage.
For perfect reconstruction, the windows used must be dual windows of the ones used to generate the
coefficients. The windows can be generated using nsgabdual or nsgabtight.
References: [11]
gd=nsgabdual(g,a,M);
gd=nsgabdual(g,a,M,L);
Input parameters
L Transform length.
Output parameters
Description
nsgabdual(g,a,M,L) computes the canonical dual windows of the non-stationary discrete Gabor
frame defined by windows given in g an time-shifts given by a.
nsgabdual is designed to be used with the functions nsdgt and insdgt. See the help on nsdgt for more
details about the variables structure.
The computed dual windows are only valid for the ’painless case’, that is to say that they ensure perfect
reconstruction only if for each window the number of frequency channels used for computation of nsdgt
is greater than or equal to the window length. This correspond to cases for which the frame operator is
diagonal.
References: [11]
Input parameters
g Cell array of windows
L Transform length.
Output parameters
gt Cell array of canonical tight windows
Description
nsgabtight(g,a,M) computes the canonical tight windows of the non-stationary discrete Gabor frame
defined by windows given in g and time-shifts given by a.
nsgabtight is designed to be used with functions nsdgt and insdgt. Read the help on nsdgt for more
details about the variables structure.
The computed tight windows are only valid for the ’painless case’, that is to say that they ensure perfect
reconstruction only if for each window the number of frequency channels used for computation of nsdgt
is greater than or equal to the window length. This correspond to cases for which the frame operator is
diagonal.
References: [11]
Input parameters
g Cell array of windows
Output parameters
fcond Frame condition number (B/A)
A, B Frame bounds.
Description
nsgabframebounds(g,a,Ls) calculates the ratio B/A of the frame bounds of the non-stationary dis-
crete Gabor frame defined by windows given in g at positions given by a. Please see the help on nsdgt for
a more thourough description of g and a.
[A,B]=nsgabframebounds(g,a,Ls) returns the actual frame bounds A and B instead of just the
their ratio.
The computed frame bounds are only valid for the ’painless case’ when the number of frequency chan-
nels used for computation of nsdgt is greater than or equal to the window length. This correspond to cases
for which the frame operator is diagonal.
References: [11]
Input parameters
g Window function.
M Number of channels.
Output parameters
d Diagonal stored as a column vector
Description
nsgabframediag(g,a,M) computes the diagonal of the non-stationary Gabor frame operator with
respect to the window g and parameters a and M. The diagonal is stored as a column vector of length
L=sum(a).
The diagonal of the frame operator can for instance be used as a preconditioner.
6.3 Plots
6.3.1 PLOTNSDGT - Plot non-stationary Gabor coefficients
Usage
plotnsdgt(c,a,fs,dynrange);
Input parameters
coef Cell array of coefficients.
Description
plotnsdgt(coef,a) plots coefficients computed using nsdgt or unsdgt. For more details on the format
of the variables coef and a, please read the function help for these functions.
plotnsdgt(coef,a,fs) does the same assuming a sampling rate of fs Hz of the original signal.
plotnsdgt(coef,a,fs,dynrange) additionally limits the dynamic range.
C=plotnsdgt(...) returns the processed image data used in the plotting. Inputting this data di-
rectly to imagesc or similar functions will create the plot. This is useful for custom post-processing of
the image data.
plotnsdgt supports all the optional parameters of tfplot. Please see the help of tfplot for an exhaustive
list. In addition, the following parameters may be specified:
’xres’,xres Approximate number of pixels along x-axis / time. The default value
is 800
’yres’,yres Approximate number of pixels along y-axis / frequency The default
value is 600
Input parameters
coef Cell array of coefficients.
a Vector of time positions of windows.
fs signal sample rate in Hz (optional).
dynrange Colorscale dynamic range in dB (optional).
Description
plotnsdgtreal(coef,a) plots coefficients computed using nsdgtreal or unsdgtreal. For more details
on the format of the variables coef and a, please read the function help for these functions.
plotnsdgtreal(coef,a,fs) does the same assuming a sampling rate of fs Hz of the original
signal.
plotnsdgtreal(coef,a,fs,dynrange) additionally limits the dynamic range.
C=plotnsdgtreal(...) returns the processed image data used in the plotting. Inputting this data
directly to imagesc or similar functions will create the plot. This is useful for custom post-processing of
the image data.
plotnsdgtreal supports all the optional parameters of tfplot. Please see the help of tfplot for an
exhaustive list. In addition, the following parameters may be specified:
’xres’,xres Approximate number of pixels along x-axis /time. Default value is 800
’yres’,yres Approximate number of pixels along y-axis / frequency Default value
is 600
234 CHAPTER 6. LTFAT - NON-STATIONARY GABOR SYSTEMS
Chapter 7
Input parameters
f, g Input vector(s).
Output parameters
A ambiguity function
Description
ambiguityfunction(f) computes the (symmetric) ambiguity function of f. The ambiguity function
is computed as the two-dimensional Fourier transform of the Wigner-Ville distribution wignervilledist.
WARNING: The quadratic time-frequency distributions are highly redundant. For an input vector of
length L, the quadratic time-frequency distribution will be a L × L matrix.
Input parameters
f, g Input vector(s)
Output parameters
w Wigner-Ville distribution
235
236 CHAPTER 7. LTFAT - QUADRATIC TIME-FREQUENCY DISTRIBUTIONS
Description
wignervilledist(f) computes the Wigner-Ville distribution of the vector f. The Wigner-Ville distri-
bution is computed by
L−1
W (n + 1, k + 1) = ∑ R (n + 1, m + 1) e−i2πmk/L ,
m=0
where R(n, m) is the instantaneous correlation matrix given by
R (n, m) = z (n + m) z (n − m),
where m ∈ −L/2, . . . , L/2 − 1, and where z is the analytical representation of f , when f is real-valued.
wignervilledist(f,g) computes the cross-Wigner-Ville distribution of f and g.
WARNING: The quadratic time-frequency distributions are highly redundant. For an input vector of
length L, the quadratic time-frequency distribution will be a L × L matrix.
Description
drihaczekdist(f) computes a discrete Rihaczek distribution of vector f. The discrete Rihaczek dis-
tribution is computed by
r (k + 1, l + 1) = f (l + 1) c (k + 1)e−2πikl/L
where k, l = 0, . . . , L − 1 and c is the Fourier transform of f .
WARNING: The quadratic time-frequency distributions are highly redundant. For an input vector of
length L, the quadratic time-frequency distribution will be a L × L matrix. If f is multichannel (L × W
matrix), the resulting distributions are stacked along the third dimension such that the result is L × L × W
cube.
Input parameters
f Input vector:w
q Kernel
Output parameters
p Quadratic time-frequency distribution
Description
For an input vector of length L, the kernel should be a L x L matrix. quadtfdist(f, q); computes a
discrete quadratic time-frequency distribution.
7.2 Plots
7.2.1 PLOTQUADTFDIST - Plot quadratic time-frequency distribution
Usage
plotquadtfdist(p);
7.2. PLOTS 237
Description
’plotquadtfdist(p)’ plots the quadratic time-frequency distribution on the time-frequency plane. The quadratic
time-frequency distribution should be a square matrix.
PLOTQUADTFDIST takes the following additional arguments:
LTFAT - Frames
Description
F=frame(ftype,...) constructs a new frame object F of type ftype. Arguments following ftype are
specific to the type of frame chosen.
Time-frequency frames
frame(’dgt’,g,a,M) constructs a Gabor frame with window g, time-shift a and M channels. See the
help on dgt for more information.
frame(’dgtreal’,g,a,M) constructs a Gabor frame for real-valued signals with window g, time-
shift a and M channels. See the help on dgtreal for more information.
frame(’dwilt’,g,M) constructs a Wilson basis with window g and M channels. See the help on
dwilt for more information.
frame(’wmdct’,g,M) constructs a windowed MDCT basis with window g and M channels. See
the help on wmdct for more information.
frame(’filterbank’,g,a,M) constructs a filterbank with filters g, time-shifts of a and M chan-
nels. For the ease of implementation, it is necessary to specify M, even though it strictly speaking could
be deduced from the size of the windows. See the help on filterbank for more information on the pa-
rameters. Similarly, you can construct a uniform filterbank by selecting ’ufilterbank’, a positive-
frequency filterbank by selecting ’filterbankreal’ or a uniform positive-frequency filterbank by
selecting ’ufilterbankreal’.
frame(’nsdgt’,g,a,M) constructs a non-stationary Gabor frame with filters g, time-shifts of a
and M channels. See the help on nsdgt for more information on the parameters. Similarly, you can con-
struct a uniform NSDGT by selecting ’unsdgt’, an NSDGT for real-valued signals only by selecting
’nsdgtreal’ or a uniform NSDGT for real-valued signals by selecting ’unsdgtreal’.
Wavelet frames
frame(’fwt’, w, J) constructs a wavelet frame with wavelet definition w and J number of filterbank
iterations. Similarly, a redundant time invariant wavelet representation can be constructed by selecting
’ufwt’. See the help on fwt and ufwt for more information.
frame(’wfbt’, wt) constructs a wavelet filterbank tree defined by the wavelet filterbank tree defi-
nition wt. Similarly, an undecimated wavelet filterbank tree can be constructed by selecting ’uwfbt’. See
the help on wfbt and uwfbt for more information.
239
240 CHAPTER 8. LTFAT - FRAMES
frame(’wpfbt’, wt) constructs a wavelet packet filterbank tree defined by the wavelet filterbank
tree definition wt. Similarly, an undecimated wavelet packet filterbank tree can be constructed by selecting
’uwpfbt’. See the help on wpfbt and uwpfbt for more information.
frame(’dft’) constructs a basis where the analysis operator is the dft, and the synthesis operator is its
inverse, idft. Completely similar to this, you can enter the name of any of the cosine or sine transforms dcti,
dctii, dctiii, dctiv, dsti, dstii, dstiii or dstiv.
frame(’dftreal’) constructs a normalized fftreal basis for real-valued signals of even length only.
The basis is normalized to ensure that is it orthonormal.
frame(’gen’,g) constructs an general frame with analysis matrix g. The frame atoms must be stored
as column vectors in the matrices.
frame(’identity’) constructs the canonical orthonormal basis, meaning that all operators return
their input as output, so it is the dummy operation.
Container frames
Wrapper frames
Frames types in this section are "virtual". They serve as a wrapper for a different type of frame.
frame(’erbletfb’,fs,Ls,...) constructs an Erb-let filterbank frame for a given samp. fre-
quency fs working with signals of length Ls. See erbfilters for a description of additional parameters as all
parameters other than the frame type string ’erbletfb’ are passed to it. NOTE: The resulting frame is de-
fined only for a single signal length Ls. Shorter signals will be zero-padded, signals longer than Ls cannot
be processed. The actual frame type is ’filterbank’ or ’filterbankreal’.
frame(’cqtfb’,fs,fmin,fmax,bins,Ls,...) constructs a CQT filterbank frame for a
given samp. frequency fs working with signals of length Ls. See cqtfilters for a description of other pa-
rameters. NOTE: The resulting frame is defined only for a single signal length Ls. Shorter signals will be
zero-padded, signals longer than Ls cannot be processed. The actual frame type is ’filterbank’ or ’filter-
bankreal’.
Examples
The following example creates a Modified Discrete Cosine Transform frame, analyses an input signal and
plots the frame coefficients:
F=frame(’wmdct’,’gauss’,40);
c=frana(F,greasy);
plotframe(F,c,’dynrange’,60);
8.1. CREATION OF A FRAME OBJECT 241
[F1,F2]=framepair(ftype,g1,g2,...);
Description
f=greasy;
[Fa,Fs]=framepair(’dgtreal’,’gauss’,’dual’,20,294);
c=frana(Fa,f);
r=frsyn(Fs,c);
norm(f-r)
ans =
5.644413339694357e-15
The following example creates a Wilson basis with a Gaussian synthesis window, and its canonical dual
frame as the analysis frame:
[Fa,Fs]=framepair(’dwilt’,’dual’,’gauss’,20);
Fd=framedual(F);
242 CHAPTER 8. LTFAT - FRAMES
Description
ans =
9.757245647085724e-15
Ft=frametight(F);
Description
ans =
1.067814285565954e-14
F=frameaccel(F,Ls);
8.2. LINEAR OPERATORS 243
Description
F=frameaccel(F,Ls) precomputes certain structures that makes the basic frame operations frana and
frsyn faster (like instantiating the window from a textual description). If you only need to call the routines
once, calling frameaccel first will not provide any total gain, but if you are repeatedly calling these
routines, for instance in an iterative algorithm, it will be a benefit.
Notice that you need to input the signal length Ls, so this routines will only be a benefit if Ls stays fixed.
If frameaccel is called twice for the same transform length, no additional computations will be done.
Description
c=frana(F,f) computes the frame coefficients c of the input signal f using the frame F. The frame
object F must have been created using frame or framepair.
If f is a matrix, the transform will be applied along the columns of f. If f is an N-D array, the transform
will be applied along the first non-singleton dimension.
The output coefficients are stored as columns. This is usually not the same format as the ’native’ format
of the frame. As an examples, the output from frana for a gabor frame cannot be passed to idgt without a
reshape.
Examples:
In the following example the signal bat is analyzed through a wavelet frame. The result are the frame
coefficients associated with the input signal bat and the analysis frame ’fwt’:
f = bat;
w = ’sym8’;
J = 7;
F = frame(’fwt’, w, J);
c = frana(F, f);
% A plot of the frame coefficients
plotframe(F, c, ’dynrange’, 100);
244 CHAPTER 8. LTFAT - FRAMES
Description
f=frsyn(F,c) constructs a signal f from the frame coefficients c using the frame F. The frame object F
must have been created using frame.
Examples:
In the following example a signal f is constructed through the frame synthesis operator using a Gabor frame.
The coefficients associated with this Gabor expansion are contained in an identity matrix. The identity
matrix corresponds to a diagonal in the time-frequency plane, that is, one atom at each time position with
increasing frequency.:
a = 10;
M = 40;
c = framenative2coef(F, eye(40));
f = frsyn(F, c);
Description
G=frsynmatrix(F,L) returns the matrix representation G of the frame synthesis operator for a frame
F of length L. The frame object F must have been created using frame.
The frame synthesis operator matrix contains all the frame atoms as column vectors. It has dimen-
sions L × Ncoe f , where Ncoe f is the number of coefficients. The number of coefficients can be found as
Ncoef=frameclength(L). This means that the frame matrix is usually very large, and this routine
should only be used for small values of L.
The action of the frame analysis operator frana is equal to multiplication with the Hermitean transpose
of the frame matrix. Consider the following simple example:
L=200;
F=frame(’dgt’,’gauss’,10,20);
G=frsynmatrix(F,L);
testsig = randn(L,1);
res = frana(F,testsig)-G’*testsig;
norm(res)
% Show the matrix (real and imaginary parts)
figure(1); imagesc(real(G));
figure(2); imagesc(imag(G));
ans =
7.106774012374892e-15
8.2. LINEAR OPERATORS 245
Input parameters
c Input coefficients
Fa Analysis frame
Fs Synthesis frame
Output parameters
o Output coefficients
Description
o=frgramian(c,F) applies the Gramian operator or Gram matrix of the frame F. The entries of the
Gram matrix are the inner products of the frame elements of F. The frame must have been created using
246 CHAPTER 8. LTFAT - FRAMES
frame. If the frame F is a Parseval frame, the Gramian operator is a projection onto the range of the frame
analysis operator.
o=frgramian(c, Fa, Fs) applies the (cross) Gramian operator with the frames Fa and Fs. Here
Fs is the frame associated with the frame synthesis operator and Fa the frame that is associated with the
frame analysis operator. The entries of the matrix that is constructed through the Gramian operator are the
inner products of the frame elements of Fa and Fs. If Fa and Fs are canonical dual frames, the Gramian
operator is a projection onto the range of the frame analysis operator.
Input parameters
F frame
f input vector
Description
Output parameter: h : output vector
h=frameoperator(F,f) applies the frame operator associated with the frame F to the input f.
If the frame F is a tight frame, then h equals f up to the constant A1 where A is the lower frame bound of
F. If the frame F is an orthonormal basis, or more general a Parseval frame, then h equals f.
Description
framediag(F,L) computes the diagonal of the frame operator for a frame of type F of length L.
The diagonal of the frame operator can for instance be used as a preconditioner.
Input parameters
F Frame.
f Signal.
Ls Length of signal.
Output parameters
c Array of coefficients.
relres Vector of residuals.
iter Number of iterations done.
8.2. LINEAR OPERATORS 247
Description
c=franaiter(F,f) computes the frame coefficients c of the signal f using an iterative method such that
perfect reconstruction can be obtained using frsyn. franaiter always works, even when frana cannot
generate perfect reconstruction coefficients.
[c,relres,iter]=franaiter(...) additionally returns the relative residuals in a vector relres
and the number of iteration steps iter.
Note: If it is possible to explicitly calculate the canonical dual frame then this is usually a much faster
method than invoking franaiter.
franaiter takes the following parameters at the end of the line of input arguments:
’tol’,t Stop if relative residual error is less than the specified tolerance. De-
fault is 1e-9 (1e-5 for single precision)
’pg’ Solve the problem using the Conjugate Gradient algorithm. This is the
default.
’pcg’ Solve the problem using the Preconditioned Conjugate Gradient algo-
rithm.
Examples
The following example shows how to rectruct a signal without ever using the dual frame:
f=greasy;
F=frame(’dgtreal’,’gauss’,40,60);
[c,relres,iter]=franaiter(F,f,’tol’,1e-14);
r=frsyn(F,c);
norm(f-r)/norm(f)
semilogy(relres);
title(’Conversion rate of the CG algorithm’);
xlabel(’No. of iterations’);
ylabel(’Relative residual’);
ans =
2.023584411446212e-15
248 CHAPTER 8. LTFAT - FRAMES
Input parameters
F Frame
c Array of coefficients.
Ls length of signal.
Output parameters
f Signal.
Description
f=frsyniter(F,c) iteratively inverts the analysis operator of F, so frsyniter always performs the
inverse operation of frana, even when a perfect reconstruction is not possible by using frsyn.
[f,relres,iter]=frsyniter(...) additionally returns the relative residuals in a vector relres
and the number of iteration steps iter.
Note: If it is possible to explicitly calculate the canonical dual frame then this is usually a much faster
method than invoking frsyniter.
frsyniter takes the following parameters at the end of the line of input arguments:
’tol’,t Stop if relative residual error is less than the specified tolerance. De-
fault is 1e-9 (1e-5 for single precision)
’cg’ Solve the problem using the Conjugate Gradient algorithm. This is the
default.
8.3. VISUALIZATION 249
’pcg’ Solve the problem using the Preconditioned Conjugate Gradient algo-
rithm.
Examples
The following example shows how to rectruct a signal without ever using the dual frame:
F=frame(’dgtreal’,’gauss’,10,20);
c=frana(F,bat);
[r,relres]=frsyniter(F,c,’tol’,1e-14);
norm(bat-r)/norm(bat)
semilogy(relres);
title(’Conversion rate of the CG algorithm’);
xlabel(’No. of iterations’);
ylabel(’Relative residual’);
ans =
1.591570805698530e-15
8.3 Visualization
8.3.1 PLOTFRAME - Plot frame coefficients
Usage
plotframe(F,c,...);
C = plotframe(...);
Description
plotframe(F,c) plots the frame coefficients c using the plot command associated to the frame F.
C=plotframe(...) for frames with time-frequency plots returns the processed image data used in
the plotting. The function produces an error for frames which does not have a time-frequency plot.
250 CHAPTER 8. LTFAT - FRAMES
plotframe(F,c,...) passes any additional parameters to the native plot routine. Please see the
help on the specific plot routine for a complete description.
The following common set of parameters are supported by all plotting routines:
’dynrange’,r Limit the dynamical range to r. The default value of [] means to not
limit the dynamical range.
’db’ Apply 20 · log10 to the coefficients. This makes it possible to see very
weak phenomena, but it might show too much noise. A logarithmic
scale is more adapted to perception of sound. This is the default.
’dbsq’ Apply 10 · log10 to the coefficients. Same as the ’db’ option, but
assume that the input is already squared.
’lin’ Show the coefficients on a linear scale. This will display the raw input
without any modifications. Only works for real-valued input.
’clim’,clim Only show values in between clim(1) and clim(2). This is usually
done by adjusting the colormap. See the help on imagesc.
Description
framegram(F,x) plots the energy of the frame coefficients computed from the input signal x using the
frame F for analysis. This is just a shorthand for:
plotframe(F,abs(frana(F,x)).^2);
Description
framebounds(F) calculates the ratio B/A of the frame bounds of the frame given by F. The length of
the system the frame bounds are calculated for is given by L=framelength(F,1).
framebounds(F,Ls) additionally specifies a signal length for which the frame should work. The
actual length used is L=framelength(F,Ls).
[A,B]=framebounds(F) returns the frame bounds A and B instead of just their ratio.
’framebounds‘ accepts the following optional parameters:
Description
framered(F) computes the redundancy of a given frame F. If the redundancy is larger than 1 (one), the
frame transform will produce more coefficients than it consumes. If the redundancy is exactly 1 (one), the
frame is a basis.
Examples:
The following simple example shows how to obtain the redundancy of a Gabor frame:
F=frame(’dgt’,’gauss’,30,40);
framered(F)
This code produces the following output:
ans =
1.333333333333333
The redundancy of a basis is always one:
F=frame(’wmdct’,’gauss’,40);
framered(F)
This code produces the following output:
ans =
1
252 CHAPTER 8. LTFAT - FRAMES
Description
framelength(F,Ls) returns the length of the frame F, such that F is long enough to expand a signal
of length Ls.
If the frame length is longer than the signal length, the signal will be zero-padded by frana.
If instead a set of coefficients are given, call framelengthcoef.
Description
framelengthcoef(F,Ncoef) returns the length of the frame F, such that F is long enough to expand
the coefficients of length Ncoef.
If instead a signal is given, call framelength.
Description
Ncoef=frameclength(F,Ls) returns the total number of coefficients obtained by applying the anal-
ysis operator of frame F to a signal of length Ls i.e. size(frana(F,f),1) for Ls=length(f).
[Ncoef,L]=frameclength(F,Ls) additionally returns L, which is the same as returned by frame-
length.
If the frame length L is longer than the signal length Ls, the signal will be zero-padded to L by frana.
Description
framecoef2native(F,coef) converts the frame coefficients coef into the native coefficient format
of the frame. The frame object F must have been created using frame.
Description
framenative2coef(F,coef) converts the frame coefficients from the native format of the transform
into the common column format.
Description
framecoef2tf(F,cin) converts the frame coefficients cin into the time-frequency plane layout. The
frame object F must have been created using frame.
The time-frequency plane layout is a matrix, where the first dimension indexes frequency and the second
dimension time. This is similar to the output format from dgt and wmdct.
Not all types of frames support this coefficient conversion. The supported types of frames are: ’dgt’,
’dgtreal’, ’dwilt’, ’wmdct’, ’ufilterbank’, ’ufwt’,‘’uwfbt’‘ and ’uwpfbt’.
Description
frametf2coef(F,cin) converts the frame coefficients from the time-frequency plane layout into the
common column format.
Not all types of frames support this coefficient conversion. The supported types of frames are: ’dgt’,
’dgtreal’, ’dwilt’, ’wmdct’, ’ufilterbank’, ’ufwt’,‘’uwfbt’‘ and ’uwpfbt’.
Description
framecoef2tfplot(F,coef) converts the frame coefficients coef into the time-frequency plane lay-
out matrix. The frame object F must have been created using frame. The function acts exactly as frame-
coef2tf for frames which admit regular (rectangular) sampling of a time-frequency plane and converts ir-
regularly sampled coefficients to a rectangular matrix. This is usefull for custom plotting.
Input parameters
F Frame definition
f Input signal
Output parameters
c Sparse coefficients.
Description
c = franabp(F,f) solves the basis pursuit problem
argmin ||c||1
c
subject to Fc = f
for a general frame F using SALSA (Split Augmented Lagrangian Srinkage algorithm) which is an appica-
tion of ADMM (Alternating Direction Method of Multipliers) to the basis pursuit problem.
The algorithm given F and f and parameters C > 0, lambda > 0 (see below) acts as follows:
Initialize c,d
repeat
v <- soft(c+d,lambda/C) - d
d <- F*(FF*)^(-1)(f - Fv)
c <- d + v
end
When compared to other algorithms, Fc = f holds exactly (up to a num. prec) in each iteration.
For a quick execution, the function requires analysis operator of the canonical dual frame F*(FF*)^(-
1). By default, the function attempts to call framedual to create the canonical dual frame explicitly. If it
is not available, the conjugate gradient method algorithm is used for inverting the frame operator in each
iteration of the algorithm. Optionally, the canonical dual frame object or an anonymous function acting as
the analysis operator of the canonical dual frame can be passed as a key-value pair ’Fd’,Fd see below.
subject to Fc = f
lambda can either be a scalar or a vector of the same length as c (in such case the product is carried
out elementwise). One can obtain length of c from length of f by frameclength. framecoef2native
and framenative2coef will help with defining weights specific to some regions of coefficients (e.g.
channel-specific weighting can be achieved this way). The default value of lambda is 1.
C A step parameter of the SALSA algorithm. The default value of C is the upper frame bound of F.
Depending on the structure of the frame, this can be an expensive operation.
tol Defines tolerance of relres which is a norm or a relative difference of coefficients obtained in two
consecutive iterations of the algorithm. The default value 1e-2.
maxit Maximum number of iterations to do. The default value is 100.
Returned arguments:
[c,relres,iter] = franabp(...) returns the residuals relres in a vector and the number of
iteration steps done iter.
[c,relres,iter,frec,cd] = franabp(...) returns the reconstructed signal from the co-
efficients, frec (this requires additional computations) and a coefficients cd minimising the ||c||_2 norm (this
is a byproduct of the algorithm).
The relationship between the output coefficients frec and c is given by
frec = frsyn(F,c);
And cd and f by
cd = frana(framedual(F),f);
Examples:
The following example shows how franabp produces a sparse representation of a test signal greasy still
maintaining a perfect reconstruction:
f = greasy;
% Gabor frame with redundancy 8
F = frame(’dgtreal’,’gauss’,64,512);
% Solve the basis pursuit problem
[c,~,~,frec,cd] = franabp(F,f);
% Plot sparse coefficients
256 CHAPTER 8. LTFAT - FRAMES
figure(1);
plotframe(F,c,’dynrange’,50);
ans =
2.334642657924850e-14
8.6. NON-LINEAR ANALYSIS AND SYNTHESIS 257
Input parameters
F Frame definition
f Input signal
Output parameters
tc Thresholded coefficients
Description
franalasso(F,f,lambda) solves the LASSO (or basis pursuit denoising) regression problem for a
general frame: minimize a functional of the synthesis coefficients defined as the sum of half the l 2 norm of
the approximation error and the l 1 norm of the coefficient sequence, with a penalization coefficient lambda
such that
1
argmin λ ||c||1 + ||Fc − f ||22
c 2
The solution is obtained via an iterative procedure, called Landweber iteration, involving iterative soft
thresholdings.
The following flags determining an algorithm to be used are recognized at the end of the argument list:
’ista’ The basic (Iterative Soft Thresholding) algorithm given F and f and parameters C> 0, lambda > 0
acts as follows:
Initialize c
repeat until stopping criterion is met
c <- soft(c + F*(f - Fc)/C,lambda/C)
end
’fista’ The fast version of the previous. This is the default option.
Initialize c(0),z,tau(0)=1,n=1
repeat until stopping criterion is met
c(n) <- soft(z + F*(f - Fz)/C,lambda/C)
tau(n) <- (1+sqrt(1+4*tau(n-1)^2))/2
z <- c(n) + (c(n)-c(n-1))(tau(n-1)-1)/tau(n)
n <- n + 1
end
[tc,relres,iter] = franalasso(...) returns the residuals relres in a vector and the num-
ber of iteration steps done iter.
[tc,relres,iter,frec,cd] = franalasso(...) returns the reconstructed signal from
the coefficients, frec and coefficients cd obtained by analysing using the canonical dual system. Note that
this requires additional computations.
The relationship between the output coefficients and frec is given by
frec = frsyn(F,tc);
The function takes the following optional parameters at the end of the line of input arguments:
’C’,cval Landweber iteration parameter: must be larger than square of upper frame bound. Default value
is the upper frame bound.
’tol’,tol Stopping criterion: minimum relative difference between norms in two consecutive iterations.
Default value is 1e-2.
’maxit’,maxit Stopping criterion: maximal number of iterations to do. Default value is 100.
8.6. NON-LINEAR ANALYSIS AND SYNTHESIS 259
’printstep’,p If ’print’ is specified, then print every p’th iteration. Default value is 10;
The parameters C, itermax and tol may also be specified on the command line in that order: franalasso(F,x,lambda,C,
Note: If you do not specify C, it will be obtained as the upper framebound. Depending on the structure
of the frame, this can be an expensive operation.
Examples:
The following example shows how franalasso produces a sparse representation of a test signal greasy:
f = greasy;
% Gabor frame with redundancy 8
F = frame(’dgtreal’,’gauss’,64,512);
% Choosing lambda (weight of the sparse regularization param.)
lambda = 0.1;
% Solve the basis pursuit problem
[c,~,~,frec,cd] = franalasso(F,f,lambda);
% Plot sparse coefficients
figure(1);
plotframe(F,c,’dynrange’,50);
ans =
3.163620955029133
260 CHAPTER 8. LTFAT - FRAMES
Input parameters
F Frame definition
f Input signal
lambda Regularisation parameter, controls sparsity of the solution
C Step size of the algorithm.
tol Reative error tolerance.
maxit Maximum number of iterations.
Output parameters
tc Thresholded coefficients
relres Vector of residuals.
iter Number of iterations done.
frec Reconstructed signal
Description
franagrouplasso(F,f,lambda) solves the group LASSO regression problem in the time-frequency
domain: minimize a functional of the synthesis coefficients defined as the sum of half the l 2 norm of the
approximation error and the mixed l 1 / l 2 norm of the coefficient sequence, with a penalization coefficient
lambda.
The matrix of time-frequency coefficients is labelled in terms of groups and members. By default, the
obtained expansion is sparse in terms of groups, no sparsity being imposed to the members of a given group.
This is achieved by a regularization term composed of l 2 norm within a group, and l 1 norm with respect to
groups. See the help on groupthresh for more information.
Note the involved frame F must support regular time-frequency layout of coefficients.
[tc,relres,iter] = franagrouplasso(...) returns the residuals relres in a vector and
the number of iteration steps done, maxit.
[tc,relres,iter,frec] = franagrouplasso(...) returns the reconstructed signal from
the coefficients, frec. Note that this requires additional computations.
The function takes the following optional parameters at the end of the line of input arguments:
’freq’ Group in frequency (search for tonal components). This is the default.
’time’ Group in time (search for transient components).
’C’,cval Landweber iteration parameter: must be larger than square of upper
frame bound. Default value is the upper frame bound.
’maxit’,maxit Stopping criterion: maximal number of iterations. Default value is
100.
’tol’,tol Stopping criterion: minimum relative difference between norms in two
consecutive iterations. Default value is 1e-2.
’print’ Display the progress.
262 CHAPTER 8. LTFAT - FRAMES
’printstep’,p If ’print’ is specified, then print every p’th iteration. Default value is
10;
In addition to these parameters, this function accepts all flags from the groupthresh and thresh functions.
This makes it possible to switch the grouping mechanism or inner thresholding type.
The parameters C, maxit and tol may also be specified on the command line in that order: franagrouplasso(F,x,lambd
The solution is obtained via an iterative procedure, called Landweber iteration, involving iterative group
thresholdings.
The relationship between the output coefficients is given by
frec = frsyn(F,tc);
Input parameters
F Frame
s Array of coefficients.
Ls length of signal.
Output parameters
f Signal.
Description
frsynabs(F,s) attempts to find a signal which has s as the absolute value of its frame coefficients
s = abs(frana(F,f));
‖|cn | − s‖ f ro
relres = ,
‖s‖ f ro
where cn is the Gabor coefficients of the signal in iteration n.
[f,relres,iter,c]=frsynabs(...,’griflim’|’fgriflim’) additionally returns co-
efficients c with the reconstructed phase prior to the final reconstruction. This is usefull for determining
the consistency (energy lost in the nullspace of F) of the reconstructed spectrogram. c will only be equal
8.6. NON-LINEAR ANALYSIS AND SYNTHESIS 263
to frana(F,f) if the spectrogram is already consistent (i.e. already in the range space of F*). This is
possible only for ’griflim’ and ’fgriflim’ methods.
Generally, if the absolute value of the frame coefficients has not been modified, the iterative algorithm
will converge slowly to the correct result. If the coefficients have been modified, the algorithm is not
guaranteed to converge at all.
frsynabs takes the following parameters at the end of the line of input arguments.
Initial phase guess:
’input’ Choose the starting phase as the phase of the input s. This is the default
’zero’ Choose a starting phase of zero.
’rand’ Choose a random starting phase.
The Griffin-Lim algorithm related parameters:
Other:
’tol’,t Stop if relative residual error is less than the specified tolerance.
’maxit’,n Do at most n iterations.
’print’ Display the progress.
9.1 General
9.1.1 RMS - RMS value of signal
Usage
y = rms(f);
y = rms(f,...);
Description
RMS(f) computes the RMS (Root Mean Square) value of a finite sampled signal sampled at a uniform
sampling rate. This is a vector norm equal to the l 2 averaged by the length of the signal.
If the input is a matrix or ND-array, the RMS is computed along the first (non-singleton) dimension,
and a vector of values is returned.
The RMS value of a signal x of length N is computed by
!1
N 2
1 2
rms( f ) = √ ∑ | f (n)|
N n=1
RMS takes the following flags at the end of the line of input parameters:
’ac’ Consider only the AC component of the signal (i.e. the mean is re-
moved).
Description
normalize(f,...) will normalize the signal f by the specified norm.
[f,fnorm]=normalize(f,...) does the same thing, but in addition returns norm fnorm of a
signal f.
The norm is specified as a string and may be one of:
265
266 CHAPTER 9. LTFAT - SIGNAL PROCESSING TOOLS
’area’ Normalize the area of the signal to be 1. This is exactly the same as
’1’.
’energy’ Normalize the energy of the signal to be 1. This is exactly the same as
’2’.
’peak’ Normalize the peak value of the signal to be 1. This is exactly the same
as ’inf’.
’rms’ Normalize the Root Mean Square (RMS) norm of the signal to be 1.
’wav’ Normalize to the l inf norm to be 0.99 to avoid possible clipping intro-
duced by the quantization procedure when saving as a wav file. This
only works with floating point data types.
’dim’,d Work along specified dimension. The default value of [] means to work along the
first non-singleton one.
Description
gaindb(insig,gn) increases the energy level of the signal by gn dB.
If gn is a scalar, the whole input signal is scaled.
If gn is a vector, each column is scaled by the entries in gn. The length of gn must match the number of
columns.
gaindb(insig,gn,dim) scales the signal along dimension dim.
Description
crestfactor(insig) computes the crest factor of the input signal insig. The output is measured in
dB.
Description
uquant(x,nbits,xmax) simulates the effect of uniform quantization of x using nbits bits. The output
is simply x rounded to 2nbits different values. The xmax parameters specify the maximal value that should
be quantifiable.
uquant(x,nbits) assumes a maximal quantifiable value of 1.
uquant(x) additionally assumes 8 bit quantization.
uquant takes the following flags at the end of the input arguments:
’s’ Use signed quantization. This assumes that the signal has a both posi-
tive and negative part. Useful for sound signals. This is the default.
If this function is applied to a complex signal, it will be applied to the real and imaginary part separately.
Description
firwin(name,M) will return an FIR window of length M of type name.
All windows are symmetric and generate zero delay and zero phase filters. They can be used for the
Wilson and WMDCT transform, except when noted otherwise.
firwin(name,x) where x is a vector will sample the window definition as the specified points. The
normal sampling interval for the windows is −.5 < x < .5.
In the following PSL means "Peak Sidelobe level", and the main lobe width is measured in normalized
frequencies.
If a window g forms a "partition of unity" (PU) it means specifically that:
g+fftshift(g)==ones(L,1);
A PU can only be formed if the window length is even, but some windows may work for odd lengths
anyway.
If a window is the square root of a window that forms a PU, the window will generate a tight Gabor
frame / orthonormal Wilson/WMDCT basis if the number of channels is less than M.
The windows available are:
’hann’ von Hann window. Forms a PU. The Hann window has a mainlobe
with of 8/M, a PSL of -31.5 dB and decay rate of 18 dB/Octave.
’sine’ Sine window. This is the square root of the Hanning window. The sine
window has a mainlobe width of 8/M, a PSL of -22.3 dB and decay
rate of 12 dB/Octave. Aliases: ’cosine’, ’sqrthann’
’nuttall’ Nuttall window. The Nuttall window has a mainlobe width of 16/M, a
PSL of -93.32 dB and decay rate of 18 dB/Octave.
’nuttall20’ 3-term Nuttall window with 3 continuous derivatives. The window has
a mainlobe width of 12/M, a PSL of -46.74 dB and decay rate of 30
dB/Octave.
’nuttall11’ 3-term Nuttall window with 1 continuous derivative. The window has
a mainlobe width of 12/M, a PSL of -64.19 dB and decay rate of 18
dB/Octave.
’nuttall30’ 4-term Nuttall window with 5 continuous derivatives. The window has
a mainlobe width of 16/M, a PSL of -60.95 dB and decay rate of 42
dB/Octave.
’nuttall21’ 4-term Nuttall window with 3 continuous derivatives. The window has
a mainlobe width of 16/M, a PSL of -82.60 dB and decay rate of 30
dB/Octave.
firwin understands the following flags at the end of the list of input parameters:
’shift’,s Shift the window by s samples. The value can be a fractional number.
’hp’ Output is half point even, as most Matlab filter routines. This corre-
sponds to a shift of s = −.5
’taper’,t Extend the window by a flat section in the middle. The argument t is
the ratio of the rising and falling parts as compared to the total length
of the window. The default value of 1 means no tapering. Accepted
values lie in the range from 0 to 1.
Additionally, firwin accepts flags to normalize the output. Please see the help of normalize. Default
is to use ’peak’ normalization, which is useful for using the output from firwin for windowing in the
time-domain. For filtering in the time-domain, a normalization of ’1’ or ’area’ is preferable.
Examples:
The following plot shows the magnitude response for some common windows:
hold all;
L=30;
dr=110;
magresp(firwin(’hanning’,L,’1’),’fir’,’dynrange’,dr);
magresp(firwin(’hamming’,L,’1’),’fir’,’dynrange’,dr);
magresp(firwin(’blackman’,L,’1’),’fir’,’dynrange’,dr);
magresp(firwin(’nuttall’,L,’1’),’fir’,’dynrange’,dr);
magresp(firwin(’itersine’,L,’1’),’fir’,’dynrange’,dr);
legend(’Hann’,’Hamming’,’Blackman’,’Nuttall’,’Itersine’);
Description
firkaiser(L,beta) computes the Kaiser-Bessel window of length L with parameter beta. The small-
est element of the window is set to zero when the window has an even length. This gives the window perfect
whole-point even symmetry, and makes it possible to use the window for a Wilson basis.
270 CHAPTER 9. LTFAT - SIGNAL PROCESSING TOOLS
firkaiser takes the following flags at the end of the input arguments:
’normal’ Normal Kaiser-Bessel window. This is the default.
’derived’ Derived Kaiser-Bessel window.
’wp’ Generate a whole point even window. This is the default.
’hp’ Generate half point even window.
Additionally, firkaiser accepts flags to normalize the output. Please see the help of normalize.
Default is to use ’peak’ normalization.
References: [69]
Description
fir2long(g,Llong) will extend the FIR window g to a length Llong window by inserting zeros. Note
that this is a slightly different behaviour than middlepad.
fir2long can also be used to extend a FIR window to a longer FIR window, for instance in order to
satisfy the usual requirement that the window length should be divisible by the number of channels.
If the input to fir2long is a cell, fir2long will recurse into the cell array.
Description
long2fir(g,L) will cut the LONG window g to a length L FIR window by cutting out the middle part.
Note that this is a slightly different behaviour than middlepad.
long2fir(g,L,’wp’) or long2fir(g,L,’hp’) does the same assuming the input window is
a whole-point even or half-point even window, respectively.
9.3 Filtering
9.3.1 FIRFILTER - Construct an FIR filter
Usage
g=firfilter(name,M);
g=firfilter(name,M,...);
Description
firfilter(name,M) creates an FIR filter of length M. This is exactly the same as calling firwin. The
name must be one of the accepted window types of firwin.
firfilter(name,M,fc) constructs a filter with a centre frequency of fc measured in normalized
frequencies.
If one of the inputs is a vector, the output will be a cell array with one entry in the cell array for each
element in the vector. If more input are vectors, they must have the same size and shape and the the filters
will be generated by stepping through the vectors. This is a quick way to create filters for filterbank and
ufilterbank.
firfilter accepts the following optional parameters:
9.3. FILTERING 271
Input parameters
winname Name of prototype
fsupp Support length of the prototype
Description
blfilter(winname,fsupp) constructs a band-limited filter. The parameter winname specifies the
shape of the frequency response. The name must be one of the shapes accepted by firwin. The support of
the frequency response measured in normalized frequencies is specified by fsupp.
blfilter(winname,fsupp,fc) constructs a filter with a centre frequency of fc measured in
normalized frequencies.
If one of the inputs is a vector, the output will be a cell array with one entry in the cell array for each
element in the vector. If more input are vectors, they must have the same size and shape and the the filters
will be generated by stepping through the vectors. This is a quick way to create filters for filterbank and
ufilterbank.
blfilter accepts the following optional parameters:
’fs’,fs If the sampling frequency fs is specified then the support fsupp and the
centre frequency fc is specified in Hz.
’complex’ Make the filter complex valued if the centre frequency is non-zero.necessary.
This is the default.
’real’ Make the filter real-valued if the centre frequency is non-zero.
’delay’,d Set the delay of the filter. Default value is zero.
’scal’,s Scale the filter by the constant s. This can be useful to equalize chan-
nels in a filter bank.
’pedantic’ Force window frequency offset (g.foff) to a subsample precision by a
subsample shift of the firwin output.
It is possible to normalize the transfer function of the filter by passing any of the flags from the normalize
function. The default normalization is ’energy’.
The filter can be used in the pfilt routine to filter a signal, or in can be placed in a cell-array for use with
filterbank or ufilterbank.
272 CHAPTER 9. LTFAT - SIGNAL PROCESSING TOOLS
Output format:
The output g from blfilter is a structure. This type of structure can be used to describe any bandlimited
filter defined in terms of its transfer function. The structure contains the following fields:
--Xg_DOT_H This is an anonymous function taking the transform length L as input
and producing the bandlimited transfer function in the form of a vector.
--Xg_DOT_foff This is an anonymous function taking the transform length L as input
and procing the frequency offset of H as an integer. The offset is the
value of the lowest frequency of H measured in frequency samples.
foff is used to position the bandlimited tranfer function stored in H
correctly when multiplying in the frequency domain.
--Xg_DOT_delay This is the desired delay of the filter measured in samples.
--Xg_DOT_realonly This is an integer with value 1 if the filter defined a real-valued filter.
In this case, the bandlimited transfer function H will be mirrored from
the positive frequencies to the negative frequencies. If the filter is a
natural lowpass filter correctly centered around 0, realonly does
not need to be 1.
--Xg_DOT_fs The intended sampling frequency. This is an optional parameter that
is only used for plotting and visualization.
Input parameters
winname Name of prototype.
fsupp Support length of the prototype (in scale units).
fc Centre frequency (in Hz).
fs Sampling rate
freqtoscale Function handle to convert Hz to scale units
scaletofreq Function to convert scale units into Hz.
Output parameters
g Filter definition, see blfilter.
Description
warpedblfilter(winname,fsupp,fc,fs,freqtoscale,scaletofreq) constructs a band-
limited filter that is warped on a given frequency scale. The parameter winname specifies the basic shape
of the frequency response. The name must be one of the shapes accepted by firwin. The support of the
frequency response measured on the selected frequency scale is specified by fsupp, the centre frequency by
fc and the scale by the function handle freqtoscale of a function that converts Hz into the choosen scale and
scaletofreq doing the inverse.
If one of the inputs is a vector, the output will be a cell array with one entry in the cell array for each
element in the vector. If more input are vectors, they must have the same size and shape and the the filters
will be generated by stepping through the vectors. This is a quick way to create filters for filterbank and
ufilterbank.
warpedblfilter accepts the following optional parameters:
9.3. FILTERING 273
’complex’ Make the filter complex valued if the centre frequency is non-zero.
This is the default.
’symmetric’ The filters with fc<0 (or fc>fs/2) will be created on the positive fre-
quencies and mirrored. This allows using freqtoscale defined only for
the positive numbers.
’scal’,s Scale the filter by the constant s. This can be useful to equalize chan-
nels in a filterbank.
It is possible to normalize the transfer function of the filter by passing any of the flags from the normalize
function. The default normalization is ’energy’.
The filter can be used in the pfilt routine to filter a signal, or in can be placed in a cell-array for use with
filterbank or ufilterbank.
The output format is the same as that of blfilter.
Description
pfilt(f,g) applies the filter g to the input f. If f is a matrix, the filter is applied along each column.
pfilt(f,g,a) does the same, but downsamples the output keeping only every a’th sample (starting
with the first one).
pfilt(f,g,a,dim) filters along dimension dim. The default value of [] means to filter along the
first non-singleton dimension.
The filter g can be a vector, in which case the vector is treated as a zero-delay FIR filter.
The filter g can be a cell array. The following options are possible:
∙ If the first element of the cell array is the name of one of the windows from firwin, the
whole cell array is passed onto firfilter.
∙ If the first element of the cell array is ’bl’, the rest of the cell array is passed onto
blfilter.
∙ If the first element of the cell array is ’pgauss’, ’psech’, the rest of the parameters
is passed onto the respective function. Note that you do not need to specify the length L.
L−1
c (n + 1) = ∑ f (l + 1) g (an − l + 1)
l=0
Description
magresp(g) will display the magnitude response of the window on a log scale (dB);
magresp(g,fs) does the same for windows that are intended to be used with signals with sampling
rate fs. The x-axis will display Hz.
magresp(g,fs,dynrange) will limit the dynamic range (see below).
magresp takes the following parameters at the end of the line of input arguments.
’fir’ Indicate that the input is an FIR window. magresp will zero-extend the
window to display a smooth magnitude response.
’autoposfreq’ Show positive frequencies for real-valued signals, otherwise show also
the negative frequencies. This is the default.
’opts’,op Pass options onto the plot command. The extra options op are specified
as a cell array
In addition to these flags, it is possible to speficy any of the normalization flags from normalize to
normalize the input before calculation of the magnitude response. Specifying ’1’ or ’area’ will display
a magnitude response which peaks at 0 dB.
Examples:
The following will display the magnitude response of a Hann window of length 20 normalized to a peak of
0 dB:
magresp({’hann’,20},’1’);
The following will display the magnitude response of a Gaussian window of length 100:
magresp(’gauss’,’L’,100)
9.3. FILTERING 275
The following passes additional options to the plot command to draw in red:
magresp({’nuttall11’,30},’opts’,{’r’});
H=transferfunction(g,L);
Description
ggd = pgrpdelay(g,L);
276 CHAPTER 9. LTFAT - SIGNAL PROCESSING TOOLS
Description
pgrpdelay(g,L) computes group delay of filter g as a negative derivative of the phase frequency re-
sponse of filter g assuming periodic (cyclic) boundaries i.e. the delay may be a negative number. The
derivative is calculated using the second order centered difference approximation. The resulting group
delay is in samples.
Example:
The following example shows a group delay of causal, moving average 6tap FIR filter and it’s magnitude
frequency response for comparison. The dips in the group delay correspond to places where modulus of the
frequency response falls to zero.:
g = struct(struct(’h’,ones(6,1),’offset’,0));
L = 512;
figure(1);
subplot(2,1,1);
plot(-L/2+1:L/2,fftshift(pgrpdelay(g,512)));
axis tight;ylim([0,4]);
subplot(2,1,2);
magresp(g,L,’nf’);
9.4 Ramping
9.4.1 RAMPUP - Rising ramp function
Usage
outsig=rampup(L);
Description
rampup(L) will return a rising ramp function of length L. The ramp is a sinusoide starting from zero and
ending at one. The ramp is centered such that the first element is always 0 and the last element is not quite
1, such that the ramp fits with following ones.
rampup(L,wintype) will use another window for ramping. This may be any of the window types
from firwin. Please see the help on firwin for more information. The default is to use a piece of the Hann
window.
9.5. THRESHOLDING METHODS 277
Description
rampdown(siglen) will return a falling ramp function of length siglen. The ramp is a sinusoid starting
from one and ending at zero. The ramp is centered such that the first element is always one and the last
element is not quite zero, such that the ramp fits with following zeros.
rampdown(L,wintype) will use another window for ramping. This may be any of the window
types from firwin. Please see the help on firwin for more information. The default is to use a piece of the
Hann window.
Description
rampsignal(insig,L) applies a ramp function of length L to the beginning and the end of the input
signal. The default ramp is a sinusoide starting from zero and ending at one (also known as a cosine squared
ramp).
If L is scalar, the starting and ending ramps will be of the same length. If L is a vector of length 2, the
first entry will be used for the rising ramp, and the second for the falling.
If the input is a matrix or an N-D array, the ramp will be applied along the first non-singleton dimension.
rampsignal(insig) will use a ramp length of half the signal.
rampsignal(insig,L,wintype) will use another window for ramping. This may be any of the
window types from firwin. Please see the help on firwin for more information. The default is to use a piece
of the Hann window.
rampsignal accepts the following optional parameters:
’dim’,d Apply the ramp along dimension d. The default value of [] means to
use the first non-singleton dimension.
Description
thresh(x,lambda) will perform hard thresholding on x, i.e. all elements with absolute value less than
scalar lambda will be set to zero.
thresh(x,lambda,’soft’) will perform soft thresholding on x, i.e. lambda will be subtracted
from the absolute value of every element of x.
The lambda parameter can also be a vector with number of elements equal to numel(xi) or it can be
a numeric array of the same shape as xi. lambda is then applied element-wise and in a column major order
if lambda is a vector.
[x,N]=thresh(x,lambda) additionally returns a number N specifying how many numbers where
kept.
thresh takes the following flags at the end of the line of input arguments:
278 CHAPTER 9. LTFAT - SIGNAL PROCESSING TOOLS
’wiener’ Perform empirical Wiener shrinkage. This is in between soft and hard
thresholding.
The function wthresh in the Matlab Wavelet toolbox implements some of the same functionality.
The following code produces a plot to demonstrate the difference between hard and soft thresholding
for a simple linear input:
t=linspace(-4,4,100);
plot(t,thresh(t,1,’soft’),’r’,...
t,thresh(t,1,’hard’),’.b’,...
t,thresh(t,1,’wiener’),’--g’);
legend(’Soft thresh.’,’Hard thresh.’,’Wiener thresh.’,’Location’,’NorthWest’);
Description
largestr(x,p) returns an array of the same size as x keeping the fraction p of the coefficients. The
coefficients with the largest magnitude are kept.
[xo,n]=largestr(xi,p) additionally returns the number of coefficients kept.
Note: If the function is used on coefficients coming from a redundant transform or from a transform
where the input signal was padded, the coefficient array will be larger than the original input signal. There-
fore, the number of coefficients kept might be higher than expected.
largestr takes the following flags at the end of the line of input arguments:
’wiener’ Perform empirical Wiener shrinkage. This is in between soft and hard
thresholding.
Note: If soft- or Wiener thresholding is selected, one less coefficient will actually be returned. This is
caused by that coefficient being set to zero.
References: [60]
Description
largestn(x,N) returns an array of the same size as x keeping the N largest coefficients.
largestn takes the following flags at the end of the line of input arguments:
’wiener’ Perform empirical Wiener shrinkage. This is in between soft and hard
thresholding.
If the coefficients represents a signal expanded in an orthonormal basis then this will be the best N-term
approximation.
Note: If soft- or Wiener thresholding is selected, only N − 1 coefficients will actually be returned. This
is caused by the N’th coefficient being set to zero.
References: [60]
Description
dynlimit(xi,dynrange) will threshold the input such that the difference between the maximum and
minumum value of xi is exactly dynrange.
Description
groupthresh(x,lambda) performs group thresholding on x, with threshold lambda. x must be a two-
dimensional array, the first dimension labelling groups, and the second one labelling members. This means
that the groups are the row vectors of the input (the vectors along the 2nd dimension).
Several types of grouping behaviour are available:
groupthresh(x,lambda,dim) chooses groups along dimension dim. The default value is dim =
2.
groupthresh accepts all the flags of thresh to choose the thresholding type within each group and
the output type (full / sparse matrix). Please see the help of thresh for the available options. Default is to
use soft thresholding and full matrix output.
References: [54], [53], [98]
Input parameters
RGB 3d data-cube, containing RGB information of the image
Output parameters
YCbCr 3d data-cube, containing the YCbCr information of the image
Description
’rgb2jpeg(RGB)’ performs a transformation of the 3d data-cube RGB with dimensions N × M × 3, which
contains information of the colours "red", "green" and "blue". The output variable YCbCr is a 3d data-cube
of the same size containing information about "luminance", "chrominance blue" and "chrominance red".
The output will be of the uint8 type.
See http://en.wikipedia.org/wiki/YCbCr and http://de.wikipedia.org/wiki/
JPEG.
Examples:
In the following example, the Lichtenstein test image is split into its three components. The very first
subplot is the original image:
f=lichtenstein;
f_jpeg=rgb2jpeg(f);
subplot(2,2,1);
image(f);axis(’image’);
Ymono=zeros(512,512,3,’uint8’);
Ymono(:,:,1)=f_jpeg(:,:,1);
9.6. IMAGE PROCESSING 281
Ymono(:,:,2:3)=128;
fmono=jpeg2rgb(Ymono);
subplot(2,2,2);
image(fmono);axis(’image’);
Cbmono=zeros(512,512,3,’uint8’);
Cbmono(:,:,2)=f_jpeg(:,:,2);
Cbmono(:,:,3)=128;
fmono=jpeg2rgb(Cbmono);
subplot(2,2,3);
image(fmono);axis(’image’);
Crmono=zeros(512,512,3,’uint8’);
Crmono(:,:,3)=f_jpeg(:,:,3);
Crmono(:,:,2)=128;
fmono=jpeg2rgb(Crmono);
subplot(2,2,4);
image(fmono);axis(’image’);
Input parameters
YCbCr 3d data-cube, containing the YCbCr information of the image
Output parameters
RGB 3d data-cube, containing RGB information of the image
Description
’jpeg2rgb(YCbCr)’ performs a transformation of the 3d data-cube YCbCr with dimensions N × M × 3,
which contains information of "luminance", "chrominance blue" and "chrominance red". The output vari-
able RGB is a 3d data-cube of the same size containing information about the colours "red", "green" and
"blue". The output will be of the uint8 type.
282 CHAPTER 9. LTFAT - SIGNAL PROCESSING TOOLS
Description
qam4(xi) converts a vector of 0’s and 1’s into the complex roots of unity (QAM4 modulation). Every 2
input coefficients are mapped into 1 output coefficient.
10.1 Plots
10.1.1 SEMIAUDPLOT - 2D plot on auditory scale
Usage
h=semiaudplot(x,y);
Description
semiaudplot(x,y) plots the data (x, y) on an auditory scale. By default the values of the x-axis will
be shown on the Erb-scale.
semiaudplot takes the following parameters at the end of the line of input arguments:
’x’ Make the x-axis use the auditory scale. This is the default.
’opts’,c Pass options stored in a cell array onto the plot function.
In addition to these parameters, the auditory scale can be specified. All scales supported by freqtoaud
are supported. The default is to use the erb-scale.
Description
audtofreq(aud,scale) converts values on the selected auditory scale to frequencies measured in Hz.
See the help on freqtoaud to get a list of the supported values of the scale parameter. If no scale is given,
the erb-scale will be selected by default.
283
284 CHAPTER 10. LTFAT - SIMPLE AUDITORY PROCESSING
Description
freqtoaud(freq,scale) converts values on the frequency scale (measured in Hz) to values on the
selected auditory scale. The value of the parameter scale determines the auditory scale:
’mel1000’ Alternative definition of the mel scale using a break frequency of 1000
Hz. This scale was reported in Fant (1968).
’erb83’ This is the original defintion of the erb scale given in Moore. et al.
(1983).
y=audspace(flow,fhigh,n,scale);
Description
y=audspacebw(flow,fhigh,bw,hitme);
y=audspacebw(flow,fhigh,bw);
y=audspacebw(flow,fhigh);
[y,n]=audspacebw(...);
10.2. AUDITORY SCALES 285
Description
audspacebw(flow,fhigh,bw,scale) computes a vector containing values equistantly scaled be-
tween frequencies flow and fhigh on the selected auditory scale. All frequencies are specified in Hz.The
distance between two consecutive values is bw on the selected scale, and the points will be centered on the
scale between flow and fhigh.
See the help on freqtoaud to get a list of the supported values of the scale parameter.
audspacebw(flow,fhigh,bw,hitme,scale) will do as above, but one of the points is quar-
anteed to be the frequency hitme.
[y,n]=audspacebw(...) additionally returns the number of points n in the output vector y.
Description
This is a wrapper around audtofreq that selects the erb-scale. Please see the help on audtofreq for more
information.
The following figure shows the corresponding frequencies for erb values up to 31:
erbs=0:31;
freqs=erbtofreq(erbs);
plot(erbs,freqs);
xlabel(’Frequency / erb’);
ylabel(’Frequency / Hz’);
Description
This is a wrapper around freqtoaud that selects the erb-scale. Please see the help on freqtoaud for more
information.
286 CHAPTER 10. LTFAT - SIMPLE AUDITORY PROCESSING
y=erbspace(flow,fhigh,n);
Description
This is a wrapper around audspace that selects the erb-scale. Please see the help on audspace for more
information.
y=erbspacebw(flow,fhigh,bw,hitme);
y=erbspacebw(flow,fhigh,bw);
y=erbspacebw(flow,fhigh);
Description
This is a wrapper around audspacebw that selects the erb-scale. Please see the help on audspacebw for more
information.
bw = audfiltbw(fc)
Description
audfiltbw(fc) returns the critical bandwidth of the auditory filter at center frequency fc defined in
equivalent rectangular bandwidth. The function uses the relation:
fc
bw = 24.7 +
9.265
as estimated in Glasberg and Moore (1990).
audfiltbw(fc,’bark’) returns the critical bandwidth at fc according to the Bark scale using the
relation:
Description
[outsig, sigweight]=rangecompress(insig,mu) range-compresss the input signal insig us-
ing µ-law range-compression with parameter mu.
rangecompress takes the following optional arguments:
The following plot shows how the output range is compressed for input values between 0 and 1:
x=linspace(0,1,100);
xc=rangecompress(x);
plot(x,xc);
xlabel(’input’);
ylabel(’output’);
title(’\mu-law compression’);
References: [49]
Description
rangeexpand(insig,mu,sigweight) inverts a previously applied µ-law companding to the signal
insig. The parameters mu and sigweight must match those from the call to rangecompress
rangeexpand takes the following optional arguments:
References: [49]
288 CHAPTER 10. LTFAT - SIMPLE AUDITORY PROCESSING
Input parameters
fc center frequency in Hz.
fs sampling rate in Hz.
n max. filter length.
Output parameters
b FIR filters as an cell-array of structs.
Description
gammatonefir(fc,fs,n,betamul) computes the filter coefficients of a digital FIR gammatone fil-
ter with length at most n, center frequency fc, 4th order rising slope, sampling rate fs and bandwith de-
termined by betamul. The bandwidth beta of each filter is determined as betamul times audfiltbw of the
center frequency of corresponding filter. The actual length of the inpulse response depends on fc (the filter
is longer for low center frequencies), fs and betamul but it is never bigger than n.
gammatonefir(fc,fs,n) will do the same but choose a filter bandwidth according to Glasberg
and Moore (1990). betamul is choosen to be 1.0183.
gammatonefir(fc,fs) will do as above and choose a sufficiently long filter to accurately represent
the lowest subband channel.
If fc is a vector, each entry of fc is considered as one center frequency, and the corresponding coefficients
are returned as column vectors in the output.
The inpulse response of the gammatone filter is given by
LTFAT - Signals
Description
ctestfun(L) returns a test signal consisting of a superposition of a chirp and an indicator function.
Input parameters
siglen Length of the noise (samples)
nsigs Number of signals (default is 1)
type type of noise. See below.
Output parameters
outsig siglen × nsigs signal vector
Description
noise(siglen,nsigs) generates nsigs channels containing white noise of the given type with the
length of siglen. The signals are arranged as columns in the output. If only siglen is given, a column vector
is returned.
noise takes the following optional parameters:
’white’ Generate white (gaussian) noise. This is the default.
’pink’ Generate pink noise.
’brown’ Generate brown noise.
’red’ This is the same as brown noise.
By default, the noise is normalized to have a unit energy, but this can be changed by passing a flag to
normalize.
289
290 CHAPTER 11. LTFAT - SIGNALS
Examples:
sgram(noise(5000,’white’),’dynrange’,70);
sgram(noise(5000,’pink’),’dynrange’,70);
sgram(noise(5000,’brown’),’dynrange’,70);
11.1. SIGNAL GENERATORS 291
Input parameters
siglen Length of the noise (samples)
Output parameters
outsig siglen × nsigs signal vector
Description
pinknoise(siglen,nsigs) generates nsigs channels containing pink noise (1/ f spectrum) with the
length of siglen. The signals are arranged as columns in the output.
pinknoise is just a wrapper around noise(...,’pink’);
Description
expchirp(L,fstart,fend) computes an exponential chirp of length L starting at frequency fstart
and ending at frequency fend. The freqencies are assumed to be normalized to the Nyquist frequency.
expchirp takes the following parameters at the end of the line of input arguments:
Usage
s=bat;
Description
bat loads the ’bat’ signal. It is a 400 samples long recording of a bat chirp sampled with a sampling period
of 7 microseconds. This gives a sampling rate of 143 kHz.
[sig,fs]=bat additionally returns the sampling frequency fs.
The signal can be obtained from http://dsp.rice.edu/software/bat-echolocation-chirp
Please acknowledge use of this data in publications as follows:
The author wishes to thank Curtis Condon, Ken White, and Al Feng of the Beckman Institute
of the University of Illinois for the bat data and for permission to use it in this paper.
Examples:
plot((1:400)/143000,bat);
xlabel(’Time (seconds)’);
ylabel(’Amplitude’);
plotfftreal(fftreal(bat),143000,90);
11.2. SOUND SIGNALS. 293
sgram(bat,143000,90);
11.2.2 BATMASK - Load a Gabor multiplier symbol for the ’bat’ test signal
Usage
c=batmask;
Description
batmask loads a Gabor multiplier with a 0/1 symbol that masks out the main contents of the ’bat’ signal.
The symbol fits a Gabor multiplier with lattice given by a = 10 and M = 40.
The mask was created manually using a image processing program. The mask is symmetric, such that
the result will be real valued if the multiplier is applied to a real valued signal using a real valued window.
Description
greasy loads the ’greasy’ signal. It is a recording of a woman pronouncing the word "greasy".
The signal is 5880 samples long and recorded at 16 kHz with around 11 bits of effective quantization.
[sig,fs]=greasy additionally returns the sampling frequency fs.
The signal has been scaled to not produce any clipping when played. To get integer values use round(greasy*2048).
The signal was obtained from Wavelab: http://www-stat.stanford.edu/~wavelab/, it is a
part of the first sentence of the TIMIT speech corpus "She had your dark suit in greasy wash water all year":
http://www.ldc.upenn.edu/Catalog/CatalogEntry.jsp?catalogId=LDC93S1.
Examples:
Plot of ’greasy’ in the time-domain:
plot((1:5880)/16000,greasy);
xlabel(’Time (seconds)’);
ylabel(’Amplitude’);
References: [62]
s=cocktailparty;
Description
cocktailparty loads the ’cocktailparty’ signal. It is a recording of a male native English speaker
pronouncing the sentence "The cocktail party effect refers to the ability to focus on a single talker among a
mixture of conversations in background noises".
[sig,fs]=cocktailparty additionally returns the sampling frequency fs.
The signal is 363200 samples long and recorded at 44.1 kHz in an anechoic environment.
s=linus;
Description
linus loads the ’linus’ signal. It is a recording of Linus Thorvalds pronouncing the words "Hello. My
name is Linus Thorvalds, and I pronounce Linux as Linux".
The signal is 41461 samples long and is sampled at 8 kHz.
[sig,fs]=linus additionally returns the sampling frequency fs.
See http://www.paul.sladen.org/pronunciation/.
296 CHAPTER 11. LTFAT - SIGNALS
Description
ltfatlogo loads the ’ltfatlogo’ signal. This is a sound synthezised from an artificial spectrogram of the
word ’LTFAT’. See the help of ltfattext.
[sig,fs]=ltfatlogo additionally returns the sampling frequency fs.
The signal is 7200 samples long and recorded at 8 kHz. It has been scaled to not produce any clipping.
Examples:
To produce a spectrogram of the logo, use:
sgram(ltfatlogo,8000,90);
Description
otoclick loads the ’otoclick’ signal. The signal is a click-evoked otoacoustic emission. It consists of
two clear clicks followed by a ringing. The ringing is the actual otoacoustic emission.
[sig,fs]=otoclick additionally returns the sampling frequency fs.
It was measured by Sarah Verhulst at CAHR (Centre of Applied Hearing Research) at Department of
Eletrical Engineering, Technical University of Denmark
The signal is 2210 samples long and sampled at 44.1 kHz.
Description
traindoppler loads the ’traindoppler’ signal. It is a recording of a train passing close by with a clearly
audible doppler shift of the train whistle sound.
[sig,fs]=traindoppler additionally returns the sampling frequency fs.
The signal is 157058 samples long and sampled at 8 kHz.
The signal was obtained from http://www.fourmilab.ch/cship/doppler.html
11.3 Images.
11.3.1 CAMERAMAN - Load the ’cameraman’ test image
Usage
s=cameraman;
Description
cameraman loads a 256 × 256 greyscale image of a cameraman.
The returned matrix s consists of integers between 0 and 255, which have been converted to double
precision.
To display the image, use imagesc with a gray colormap:
imagesc(cameraman); colormap(gray); axis(’image’);
Description
lichtenstein loads a 512 × 512 color image of a castle Lichtenstein, http://en.wikipedia.
org/wiki/Lichtenstein_Castle.
The returned matrix s consists of integers between 0 and 255.
To display the image, simply use image:
image(lichtenstein); axis(’image’);
298 CHAPTER 11. LTFAT - SIGNALS
See http://commons.wikimedia.org/wiki/File:Lichtenstein_img_processing_
test.png.
Description
ltfattext loads a 401 × 600 black and white image of the word ’LTFAT’.
The image is assumed to be used as a spectrogram with 800 channels as produced by dgtreal.
The returned matrix s consists of the integers 0 and 1, which have been converted to double precision.
To display the image, use imagesc with a gray colormap:
imagesc(ltfattext);
colormap(gray);
axis(’xy’);
Chapter 12
LTFAT - Demos
Output
Type "help demo_dgt" to see a description of how this demo works.
299
300 CHAPTER 12. LTFAT - DEMOS
a =
20
M =
40
12.1. BASIC DEMOS 301
Note that it must hold that L = M*b = N*a for some integers b, N and L,
and that a<M. L is the transform length, and the DGT will choose the
smallest possible value of L that is larger or equal to the length of the
signal. Choosing a<M makes the transform redundant, otherwise the
transform will be lossy, and reconstruction will not be possible.
Number of time shifts in transform:
Length of transform:
L =
400
The redundancy of the Gabor transform can be reduced without loosing information.
No. of coefficients in the signal: 400
No. of output coefficients from the DGT: 800
Redundacy of the DGT (in this case) 2.000000
reconstruction, because both the window and the dual window used for reconstruction must be FIR, and
this is hard to obtain, if the window is longer than the number of channels.
This demo demonstrates two methods:
1) Using a Gabor frame with a simple structure, for which dual/tight FIR windows are
easy to construct. This is a very common technique in traditional signal processing,
but it limits the choice of windows and lattice parameters.
2) Cutting a canonical dual/tight window. We compute the canonical dual window of
the analysis window, and cut away the parts that are close to zero. This will work
for any analysis window and any lattice constant, but the reconstruction obtained is
not perfect.
Output
ans =
0.500000000000000
ans =
6.401998278383549e-17
304 CHAPTER 12. LTFAT - DEMOS
recerr =
0.001762485642153
or expressed in dB:
ans =
-27.538744122424180
recerr =
9.858293436835774e-04
or expressed in dB:
ans =
-30.061982590052025
Output
12.2. COMPRESSION 305
12.2 Compression
12.2.1 DEMO_IMAGECOMPRESSION - Image compression using N-term ap-
proximation
This demo shows how to perform a simple imagecompression using either a Wilson basis or a Wavelet. The
compression step is done by retaining only 5% of the coefficients.
Output
306 CHAPTER 12. LTFAT - DEMOS
∙ Linear approximation: The N coefficients with lowest frequency index are kept.
Output
12.3 Denoising
12.3.1 DEMO_AUDIODENOISE - Audio denoising using thresholding
This demos shows how to do audio denoising using thresholding of WMDCT transform.
308 CHAPTER 12. LTFAT - DEMOS
The signal is transformed using an orthonormal WMDCT transform followed by a thresholding. Then
the signal is reconstructed and compared with the original.
Output
RESULTS:
Input SNR: 6.044694 dB.
Output SNR (hard): 9.091411 dB.
Output SNR (soft): 14.283694 dB.
Signals are stored in variables sig, nsig, hrec, srec
12.4. APPLICATIONS 309
12.4 Applications
12.4.1 DEMO_OFDM - Demo of Gabor systems used for OFDM
This demo shows how to use a Gabor Riesz basis for OFDM.
We want to transmit a signal consisting of 0’s and 1’s through a noisy communication channel. This is
accomplished in the following steps in the demo:
1) Convert this digital signal into complex valued coefficients by QAM modulation.
2) Construct the signal to be transmitted by an inverse Gabor transform of the complex
coefficients
3) "Transmit" the signal by applying a spreading operator to the signal and adding
white noise
4) Convert the received signal into noisy coefficients by a Gabor transform
5) Convert the noisy coefficients into bits by inverse QAM.
Output
Type "help demo_ofdm" to see a description of how this demo works.
faulty =
Error rate:
ans =
∙ select fixed frequency lines of large wmdct coefficients on the wide window wmdct trans-
form
∙ select fixed time lines of large wmdct coefficients on the narrow window wmdct transform
The corresponding approximated signals are computed with the corresponding inverse, iwmdct.
Corresponding reconstructed tonal and transient sounds may be listened from arrays rec1 and rec2
(sampling rate: 44.1 kHz)
Output
Percentage of retained coefficients: 10.156250 + 12.988281 = 23.144531
To play the original, type "soundsc(sig,fs)"
To play the tonal part, type "soundsc(rec1,fs)"
To play the transient part, type "soundsc(rec2,fs)"
12.4. APPLICATIONS 311
Output
Type "help demo_gabmulappr" to see a description of how this demo works.
Output
The original signal can be played by typing: sound(forig,44100);
The signal obtained by a direct filtering cen be played by (this is what is approximat
The signal obtained by applying the Gabor multiplier: sound(fmul,44100);
Output
312 CHAPTER 12. LTFAT - DEMOS
Figure 12.22: Spectroram obtained by re-analysis of the test signal after applying the multiplier
This figure shows a spectrogram of the test signal after applying the estimated Gabor multiplier.
Output
Direct reconstruction MSE:
From the coefficients: 2.176541e-03
From the synchrosqueezed coefficients: 2.176541e-03
12.5. ASPECTS OF PARTICULAR FUNCTIONS 313
Output
Type "help demo_nsdgt" to see a description of how this example works.
Relative error of reconstruction (should be close to zero.): 3.227678e-16
Output
Type "help demo_pgauss" to see a description of how this demo works.
Test of DFT invariance: Should be close to zero.
12.5. ASPECTS OF PARTICULAR FUNCTIONS 315
Figure 12.27: ERBlet spectrogram (top) and synchrosqueezed ERBlet spectrogram (bottom)
The signal used is the first second from gspi. Only the energy of the coefficients is show. Both representations are in
fact complex and invertible.
ans =
2.481524897647706e-15
ans =
ans =
1.501312721600895e-15
Output
Type "help demo_pbspline" to see a description of how this demo works.
12.5. ASPECTS OF PARTICULAR FUNCTIONS 317
ntaps =
19
ans =
4.035410778421974e-16
318 CHAPTER 12. LTFAT - DEMOS
ans =
ans =
19
ans =
6.204997459932044e-16
Output
Type "help demo_gabmixdual" to see a description of how this demo works.
Framebounds of initial Gabor system:
A1 =
0.605813442913889
B1 =
1.690164970019093
A2 =
2.024110119704336e-05
B2 =
4.898979421758012
Am =
0.004131003699532
Bm =
0.011463008168063
Output
Type "help demo_framemul" to see a description of how this demo works.
Output
Type "help demo_phaseplot" to see a description of how this demo works.
320 CHAPTER 12. LTFAT - DEMOS
Output
Output
ans =
1.007891912889226
322 CHAPTER 12. LTFAT - DEMOS
∙ The high redundancy representation uses ’uniform’ subsampling i.e. all channels are sub-
sampled with the same subsampling factor which is the lowest from the filters according
to the painless condition rounded towards zero.
12.5. ASPECTS OF PARTICULAR FUNCTIONS 323
∙ The low redundancy representation uses ’fractional’ subsampling which results in the
least redundant representation still satisfying the painless condition. Actual time positions
of atoms can be non-integer, hence the word fractional.
Output
Output
In this file we construct a uniform filterbank using a the impulse response of a 4th order gammatone for
each channel. The center frequencies are equidistantly spaced on an ERB-scale, and the width of the filter
are choosen to match the auditory filter bandwidth as determined by Moore.
Each channel is subsampled by a factor of 8 (a=8), and to generate a nice plot, 4 channels per Erb has
been used.
The filterbank covers only the positive frequencies, so we must use filterbankrealdual and filterbankre-
albounds.
References: [37]
326 CHAPTER 12. LTFAT - DEMOS
Output
Frame bound ratio for gammatone filterbank, should be close to 1 if the filters are ch
ans =
1.598850055103133
ans =
12.6. AUDITORY SCALES AND FILTERS 327
6.351688463338187e-05
ans =
1.883372347722060e-10
328 CHAPTER 12. LTFAT - DEMOS
1) Auditory filterbank, approximately dividing the frequency band into intervals remi-
nisent of the bask scale.
2) Musical filterbank, approximately dividing the freq. band into intervals reminicent
of the well-tempered musical scale.
Shapes of the trees were taken from fig. 8 and fig. 9 from the refernece. Sampling frequency of the test
signal is 48kHz as used in the article.
Figure 12.51: TF plot of the test signal using the auditory filterbank.
12.6. AUDITORY SCALES AND FILTERS 329
Figure 12.53: TF plot of the test signal using the musical filterbank.
References: [55]
Output
The reconstruction should be close to zero:
ans =
4.783697746283275e-14
ans =
8.871444670941919e-14
330 CHAPTER 12. LTFAT - DEMOS
Description
For additional help call demo_blockproc_basicloop without arguments.
The demo runs simple playback loop allowing to set gain in dB.
Output
DEMO_BLOCKPROC_BASICLOOP:
To run the demo, use one of the following:
Description
For additional help call demo_blockproc_paramequalizer without arguments.
This demonstration shows an example of a octave parametric equalizer. See chapter 5.2 in the book by
Zolzer.
References: [99]
Output
DEMO_BLOCKPROC_PARAMEQUALIZER:
To run the demo, use one of the following:
Output channels of the device cen be selected by additional key-value pair ’playch’,[c
Input channels of the device cen be selected by additional key-value pair ’recch’,[ch1
Description
For additional help call demo_blockproc_denoising without arguments.
The present demo allows you to set the coefficient threshold during the playback using the control panel.
Output
DEMO_BLOCKPROC_DENOISING:
To run the demo, use one of the following:
Description
For additional help call demo_blockproc_slidingsgram without arguments.
This demo shows a simple rolling spectrogram of whatever is specified in source.
Output
DEMO_BLOCKPROC_SLIDINGSGRAM:
To run the demo, use one of the following:
demo_blockproc_slidingcqt(’gspi.wav’)
Description
Output
DEMO_BLOCKPROC_SLIDINGCQT:
To run the demo, use one of the following:
demo_blockproc_slidingerblets(’gspi.wav’)
Description
Output
DEMO_BLOCKPROC_SLIDINGERBLETS:
To run the demo, use one of the following:
demo_blockproc_dgtequalizer(’gspi.wav’)
Description
Output
DEMO_BLOCKPROC_DGTEQUALIZER:
To run the demo, use one of the following:
demo_blockproc_effects(’gspi.wav’)
Description
For additional help call demo_blockproc_effects without arguments. This demo works correctly only with
the sampling rate equal to 44100 Hz.
This script demonstrates several real-time vocoder effects. Namely:
This demo was created for the Lange Nacht der Forschung 4.4.2014 event.
334 CHAPTER 12. LTFAT - DEMOS
Output
DEMO_BLOCKPROC_EFFECTS:
To run the demo, use one of the following:
[1] A. Abdelnour. Dense grid framelets with symmetric lowpass and bandpass filters. In Signal Pro-
cessing and Its Applications, 2007. ISSPA 2007. 9th International Symposium on, volume 172, pages
1–4, 2007.
[2] A. F. Abdelnour and I. W. Selesnick. Symmetric nearly shift-invariant tight frame wavelets. IEEE
Transactions on Signal Processing, 53(1):231–239, 2005.
[3] F. Abdelnour. Symmetric wavelets dyadic sibling and dual frames. Signal Processing, 92(5):1216 –
1229, 2012.
[4] F. Abdelnour and I. W. Selesnick. Symmetric nearly orthogonal and orthogonal nearly symmetric
wavelets. The Arabian Journal for Science and Engineering, 29(2C):3 – 16, 2004.
[5] A. Aertsen and P. Johannesma. Spectro-temporal receptive fields of auditory neurons in the grassfrog.
I. Characterization of tonal and natural stimuli. Biol. Cybern, 38:223–234, 1980.
[6] S. Akkarakaran and P. Vaidyanathan. Nonuniform filter banks: New results and open problems. In
P. M. C.K. Chui and L. Wuytack, editors, Studies in Computational Mathematics: Beyond Wavelets,
volume 10, pages 259 –301. Elsevier B.V., 2003.
[7] O. Alkin and H. Caglar. Design of efficient M-band coders with linear-phase and perfect-
reconstruction properties. Signal Processing, IEEE Transactions on, 43(7):1579 –1590, jul 1995.
[8] F. Auger, E. Chassande-Mottin, and P. Flandrin. Making reassignment adjustable: The Levenberg-
Marquardt approach. In Acoustics, Speech and Signal Processing (ICASSP), 2012 IEEE Interna-
tional Conference on, pages 3889–3892, March 2012.
[10] F. Auger and P. Flandrin. Improving the readability of time-frequency and time-scale representations
by the reassignment method. IEEE Trans. Signal Process., 43(5):1068–1089, 1995.
[11] P. Balazs, M. Dörfler, F. Jaillet, N. Holighaus, and G. A. Velasco. Theory, implementation and
applications of nonstationary Gabor frames. J. Comput. Appl. Math., 236(6):1481–1496, 2011.
[12] I. Bayram and I. Selesnick. On the dual-tree complex wavelet packet and m-band transforms. Signal
Processing, IEEE Transactions on, 56(6):2298–2310, June 2008.
[13] A. Beck and M. Teboulle. A fast iterative shrinkage-thresholding algorithm for linear inverse prob-
lems. SIAM J. Img. Sci., 2(1):183–202, Mar. 2009.
[15] H. Bölcskei and F. Hlawatsch. Oversampled Wilson-type cosine modulated filter banks with linear
phase. In Asilomar Conf. on Signals, Systems, and Computers, pages 998–1002, nov 1996.
[16] H. Bölcskei and F. Hlawatsch. Discrete Zak transforms, polyphase transforms, and applications.
IEEE Trans. Signal Process., 45(4):851–866, april 1997.
335
336 BIBLIOGRAPHY
[18] S. Boyd, N. Parikh, E. Chu, B. Peleato, and J. Eckstein. Distributed optimization and statistical
learning via the alternating direction method of multipliers. Found. Trends Mach. Learn., 3(1):1–
122, Jan. 2011.
[19] A. Bultheel and S. Martínez. Computation of the Fractional Fourier Transform. Appl. Comput.
Harmon. Anal., 16(3):182–202, 2004.
[20] R. Carmona, W. Hwang, and B. Torrésani. Practical Time-Frequency Analysis: continuous wavelet
and Gabor transforms, with an implementation in S, volume 9 of Wavelet Analysis and its Applica-
tions. Academic Press, San Diego, 1998.
[21] R. Carmona, W. Hwang, and B. Torrésani. Multiridge detection and time-frequency reconstruction.
IEEE Trans. Signal Process., 47:480–492, 1999.
[23] J. Cooley and J. Tukey. An algorithm for the machine calculation of complex Fourier series. Math.
Comput, 19(90):297–301, 1965.
[24] I. Daubechies. Ten Lectures on Wavelets. Society for Industrial and Applied Mathematics, Philadel-
phia, PA, USA, 1992.
[25] I. Daubechies, M. Defrise, and C. De Mol. An iterative thresholding algorithm for linear inverse
problems with a sparsity constraint. Communications in Pure and Applied Mathematics, 57:1413–
1457, 2004.
[26] I. Daubechies, S. Jaffard, and J. Journé. A simple Wilson orthonormal basis with exponential decay.
SIAM J. Math. Anal., 22:554–573, 1991.
[27] R. Decorsière and P. L. Søndergaard. Modulation filtering using an optimization approach to spec-
trogram reconstruction. In Proceedings of the Forum Acousticum, 2011.
[28] R. Decorsiere, P. Søndergaard, E. MacDonald, and T. Dau. Inversion of auditory spectrograms, tradi-
tional spectrograms, and other envelope representations. Audio, Speech, and Language Processing,
IEEE/ACM Transactions on, 23(1):46–56, Jan 2015.
[29] B. Dumitrescu, I. Bayram, and I. W. Selesnick. Optimization of symmetric self-hilbertian filters for
the dual-tree complex wavelet transform. IEEE Signal Process. Lett., 15:146–149, 2008.
[30] G. Fant. Analysis and synthesis of speech processes. In B. Malmberg, editor, Manual of phonetics.
North-Holland, 1968.
[32] H. G. Feichtinger and T. Strohmer, editors. Gabor Analysis and Algorithms. Birkhäuser, Boston,
1998.
[33] K. R. Fitz and S. A. Fulop. A unified theory of time-frequency reassignment. CoRR, abs/0903.3080,
2009.
[34] J. Flanagan, D. Meinhart, R. Golden, and M. Sondhi. Phase Vocoder. The Journal of the Acoustical
Society of America, 38:939, 1965.
[35] M. Frigo and S. G. Johnson. The design and implementation of FFTW3. Proceedings of the IEEE,
93(2):216–231, 2005. Special issue on "Program Generation, Optimization, and Platform Adapta-
tion".
BIBLIOGRAPHY 337
[36] S. Ghael, A. Sayeed, and R. Baraniuk. Improved wavelet denoising via empirical Wiener filtering.
In Proceedings of SPIE, volume 3169, pages 389–399. San Diego, CA, 1997.
[37] B. R. Glasberg and B. Moore. Derivation of auditory filter shapes from notched-noise data. Hearing
Research, 47(1-2):103, 1990.
[38] R. Gopinath and C. Burrus. On cosine-modulated wavelet orthonormal bases. Image Processing,
IEEE Transactions on, 4(2):162–176, Feb 1995.
[39] D. Griffin and J. Lim. Signal estimation from modified short-time Fourier transform. IEEE Trans.
Acoust. Speech Signal Process., 32(2):236–243, 1984.
[42] F. Harris. On the use of windows for harmonic analysis with the discrete Fourier transform. Pro-
ceedings of the IEEE, 66(1):51 – 83, jan 1978.
[43] N. Holighaus, M. Dörfler, G. A. Velasco, and T. Grill. A framework for invertible, real-time constant-
Q transforms. IEEE Transactions on Audio, Speech and Language Processing, 21(4):775 –785, 2013.
[44] N. Holighaus, Z. Průša, and P. L. Søndergaard. Reassignment and synchrosqueezing for general
time-frequency filter banks, subsampling and processing. Signal Processing, 125:1–8, 2016.
[45] N. Holighaus, Z. Průša, and C. Wiesmeyr. Designing tight filter bank frames for nonlinear frequency
scales. Sampling Theory and Applications 2015, submitted, 2015.
[47] A. J. E. M. Janssen. Duality and biorthogonality for discrete-time Weyl-Heisenberg frames. Unclas-
sified report, Philips Electronics, 002/94.
[48] A. J. E. M. Janssen and T. Strohmer. Hyperbolic secants yield Gabor frames. Appl. Comput. Harmon.
Anal., 12(2):259–267, 2002.
[49] S. Jayant and P. Noll. Digital Coding of Waveforms: Principles and Applications to Speech and
Video. Prentice Hall, 1990.
[50] N. Kingsbury. Complex wavelets for shift invariant analysis and filtering of signals. Applied and
Computational Harmonic Analysis, 10(3):234 – 253, 2001.
[51] N. Kingsbury. Design of q-shift complex wavelets for image processing using frequency domain
energy minimization. In Image Processing, 2003. ICIP 2003. Proceedings. 2003 International Con-
ference on, volume 1, pages I–1013–16 vol.1, Sept 2003.
[52] N. G. Kingsbury. A dual-tree complex wavelet transform with improved orthogonality and symmetry
properties. In ICIP, pages 375–378, 2000.
[53] M. Kowalski. Sparse regression using mixed norms. Appl. Comput. Harmon. Anal., 27(3):303–324,
2009.
[54] M. Kowalski and B. Torrésani. Sparsity and persistence: mixed norms provide simple signal models
with dependent coefficients. Signal, Image and Video Processing, 3(3):251–264, 2009.
[55] F. Kurth and M. Clausen. Filter bank tree and M-band wavelet packet algorithms in audio signal
processing. Signal Processing, IEEE Transactions on, 47(2):549–554, Feb 1999.
[56] J. Lim and A. Oppenheim. Enhancement and bandwidth compression of noisy speech. Proceedings
of the IEEE, 67(12):1586–1604, 1979.
338 BIBLIOGRAPHY
[57] T. Lin, S. Xu, Q. Shi, and P. Hao. An algebraic construction of orthonormal M-band wavelets with
perfect reconstruction. Applied mathematics and computation, 172(2):717–730, 2006.
[58] Y.-P. Lin and P. Vaidyanathan. Linear phase cosine modulated maximally decimated filter banks with
perfectreconstruction. IEEE Trans. Signal Process., 43(11):2525–2539, 1995.
[59] D. Liu and J. Nocedal. On the limited memory BFGS method for large scale optimization. Mathe-
matical programming, 45(1):503–528, 1989.
[60] S. Mallat. A wavelet tour of signal processing. Academic Press, San Diego, CA, 1998.
[61] S. Mallat. A Wavelet Tour of Signal Processing, Third Edition: The Sparse Way. Academic Press,
3rd edition, 2008.
[62] S. Mallat and Z. Zhang. Matching pursuits with time-frequency dictionaries. IEEE Trans. Signal
Process., 41(12):3397–3415, 1993.
[63] S. G. Mallat. A theory for multiresolution signal decomposition: The wavelet representation. IEEE
Trans. Pattern Anal. Mach. Intell., 11(7):674–693, July 1989.
[64] H. S. Malvar. Signal Processing with Lapped Transforms. Artech House Publishers, 1992.
[65] B. Moore and B. Glasberg. Suggested formulae for calculating auditory-filter bandwidths and exci-
tation patterns. J. Acoust. Soc. Am., 74:750, 1983.
[66] T. Necciari, P. Balazs, N. Holighaus, and P. L. Søndergaard. The ERBlet transform: An auditory-
based time-frequency representation with perfect reconstruction. In Proceedings of the 38th Inter-
national Conference on Acoustics, Speech, and Signal Processing (ICASSP 2013), pages 498–502,
Vancouver, Canada, May 2013. IEEE.
[67] D. J. Nelson. Instantaneous higher order phase derivatives. Digital Signal Processing, 12(2-3):416–
428, 2002.
[68] A. Nuttall. Some windows with very good sidelobe behavior. IEEE Trans. Acoust. Speech Signal
Process., 29(1):84–91, 1981.
[69] A. V. Oppenheim and R. W. Schafer. Discrete-time signal processing. Prentice Hall, Englewood
Cliffs, NJ, 1989.
[70] H. M. Ozaktas, Z. Zalevsky, and M. A. Kutay. The Fractional Fourier Transform. John Wiley and
Sons, 2001.
[71] N. Perraudin, P. Balazs, and P. L. Søndergaard. A fast Griffin-Lim algorithm. In Applications of
Signal Processing to Audio and Acoustics (WASPAA), 2013 IEEE Workshop on, pages 1–4, Oct
2013.
[72] A. A. Petrosian and F. G. Meyer, editors. Wavelets in Signal and Image Analysis: From Theory to
Practice, chapter The Double Density DWT, pages 39–66. Kluwer, 1 edition, 2001.
[73] J. P. Princen and A. B. Bradley. Analysis/synthesis filter bank design based on time domain aliasing
cancellation. IEEE Transactions on Acoustics, Speech, and Signal Processing, ASSP-34(5):1153–
1161, 1986.
[74] J. P. Princen, A. W. Johnson, and A. B. Bradley. Subband/transform coding using filter bank designs
based on time domain aliasing cancellation. Proceedings - ICASSP, IEEE International Conference
on Acoustics, Speech and Signal Processing, pages 2161–2164, 1987.
[75] Z. Průša. STFT and DGT phase conventions and phase derivatives interpretation. Technical report,
Acoustics Research Institute, Austrian Academy of Sciences, 2015.
[76] Z. Průša, P. Balazs, and P. L. Søndergaard. A Non-iterative Method for STFT Phase
(Re)Construction. IEEE/ACM Transactions on Audio, Speech, and Language Processing, 2016.
In preparation. Preprint will be available at http://ltfat.github.io/notes/ltfatnote040.pdf.
BIBLIOGRAPHY 339
[77] M. Puckette. Phase-locked vocoder. Applications of Signal Processing to Audio and Acoustics,
1995., IEEE ASSP Workshop on, pages 222 –225, 1995.
[78] L. Rabiner, R. Schafer, and C. Rader. The chirp Z-transform algorithm. Audio and Electroacoustics,
IEEE Transactions on, 17(2):86–92, 1969.
[79] K. Rao and P. Yip. Discrete Cosine Transform, Algorithms, Advantages, Applications. Academic
Press, 1990.
[80] O. Rioul and P. Duhamel. A remez exchange algorithm for orthonormal wavelets. Circuits and
Systems II: Analog and Digital Signal Processing, IEEE Transactions on, 41(8):550 –560, aug 1994.
[81] C. Schörkhuber, A. Klapuri, N. Holighaus, and M. Dörfler. A Matlab Toolbox for Efficient Perfect
Reconstruction Time-Frequency Transforms with Log-Frequency Resolution. In Audio Engineering
Society Conference: 53rd International Conference: Semantic Audio. Audio Engineering Society,
2014.
[82] I. Selesnick. The double-density dual-tree DWT. Signal Processing, IEEE Transactions on,
52(5):1304–1314, May 2004.
[83] I. Selesnick. A higher density discrete wavelet transform. IEEE Transactions on Signal Processing,
54(8):3039–3048, 2006.
[84] I. Selesnick. L1-Norm Penalized Least Squares with SALSA. OpenStax_CNX, Jan. 2014.
[85] I. Selesnick and A. Abdelnour. Symmetric wavelet tight frames with two generators. Appl. Comput.
Harmon. Anal., 17(2):211–225, 2004.
[86] I. Selesnick, R. Baraniuk, and N. Kingsbury. The dual-tree complex wavelet transform. Signal
Processing Magazine, IEEE, 22(6):123 – 151, nov. 2005.
[87] P. L. Søndergaard. Symmetric, discrete fractional splines and Gabor systems. preprint, 2008.
[88] P. L. Søndergaard. LTFAT-note 17: Next fast FFT size. Technical report, Technical University of
Denmark, 2011.
[89] S. Stevens, J. Volkmann, and E. Newman. A scale for the measurement of the psychological magni-
tude pitch. J. Acoust. Soc. Am., 8:185, 1937.
[90] P. Sysel and P. Rajmic. Goertzel algorithm generalized to non-integer multiples of fundamental
frequency. EURASIP Journal on Advances in Signal Processing, 2012(1):56, 2012.
[91] C. Taswell. Near-best basis selection algorithms with non-additive information cost functions. In
Proceedings of the IEEE International Symposium on Time-Frequency and Time-Scale Analysis,
pages 13–16. IEEE Press, 1994.
[92] H. Traunmüller. Analytical expressions for the tonotopic sensory scale. J. Acoust. Soc. Am., 88:97,
1990.
[93] G. A. Velasco, N. Holighaus, M. Dörfler, and T. Grill. Constructing an invertible constant-Q trans-
form with non-stationary Gabor frames. Proceedings of DAFX11, 2011.
[94] T. Werther, Y. Eldar, and N. Subbana. Dual Gabor Frames: Theory and Computational Aspects.
IEEE Trans. Signal Process., 53(11), 2005.
[95] E. Wesfreid and M. Wickerhauser. Adapted local trigonometric transforms and speech processing.
IEEE Trans. Signal Process., 41(12):3596–3600, 1993.
[96] M. V. Wickerhauser. Lectures on wavelet packet algorithms. In INRIA Lecture notes. Citeseer, 1991.
[97] M. V. Wickerhauser. Adapted wavelet analysis from theory to software. Wellesley-Cambridge Press,
Wellesley, MA, 1994.
340 BIBLIOGRAPHY
[98] G. Yu, S. Mallat, and E. Bacry. Audio Denoising by Time-Frequency Block Thresholding. IEEE
Trans. Signal Process., 56(5):1830–1839, 2008.
[99] U. Zolzer. Digital Audio Signal Processing. John Wiley and Sons Ltd, 2 edition, 2008.
[100] E. Zwicker. Subdivision of the audible frequency range into critical bands (frequenzgruppen). J.
Acoust. Soc. Am., 33(2):248–248, 1961.
[101] E. Zwicker and E. Terhardt. Analytical expressions for criticalband rate and critical bandwidth as a
function of frequency. The Journal of the Acoustical Society of America, 68(5):1523–1525, 1980.