0% found this document useful (0 votes)
132 views340 pages

Ltfat

This document is a reference manual for the LTFAT toolbox. It contains: 1. An overview of basic routines for initialization, parameter handling, and graphical user interfaces. 2. Documentation of routines for Gabor analysis including the discrete Gabor transform (DGT) and its inverse, Gabor systems, and Wilson bases/WMDCT transforms. 3. The routines are organized into sections and each routine is documented with its purpose and inputs/outputs.

Uploaded by

RTEFG DFGJU
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
132 views340 pages

Ltfat

This document is a reference manual for the LTFAT toolbox. It contains: 1. An overview of basic routines for initialization, parameter handling, and graphical user interfaces. 2. Documentation of routines for Gabor analysis including the discrete Gabor transform (DGT) and its inverse, Gabor systems, and Wilson bases/WMDCT transforms. 3. The routines are organized into sections and each routine is documented with its purpose and inputs/outputs.

Uploaded by

RTEFG DFGJU
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 340

LTFAT Reference manual

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

1 LTFAT - Base routines 5


1.1 Basic routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.1.1 ltfatstart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.1.2 ltfatstop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.1.3 ltfathelp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.1.4 ltfatmex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.1.5 ltfatbasepath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.1.6 isoctave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2 Parameter handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2.1 ltfatarghelper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2.2 ltfatgetdefaults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.2.3 ltfatsetdefaults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.2.4 scalardistribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.3 Graphical user interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.3.1 mulaclab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

2 LTFAT - Gabor analysis 11


2.1 Basic Time/Frequency analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.1.1 tconv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.1.2 dsft . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.1.3 zak . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.1.4 izak . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.1.5 col2diag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.1.6 s0norm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.2 Gabor systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.2.1 dgt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.2.2 idgt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.2.3 isgram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.2.4 isgramreal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.2.5 dgt2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.2.6 idgt2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.2.7 dgtreal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.2.8 idgtreal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.2.9 gabwin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.2.10 projkern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.2.11 dgtlength . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.3 Wilson bases and WMDCT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.3.1 dwilt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.3.2 idwilt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.3.3 dwilt2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.3.4 idwilt2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
2.3.5 wmdct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
2.3.6 iwmdct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.3.7 wmdct2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

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

3 LTFAT - Basic Fourier and DCT analysis. 79


3.1 Support routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
3.1.1 fftindex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
3.1.2 modcent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
3.1.3 floor23 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
3.1.4 floor235 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
3.1.5 ceil23 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
3.1.6 ceil235 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
3.1.7 nextfastfft . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
3.2 Basic Fourier analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
3.2.1 dft . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
3.2.2 idft . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
3.2.3 fftreal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
3.2.4 ifftreal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
3.2.5 gga . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
3.2.6 chirpzt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
3.2.7 fftgram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
3.2.8 plotfft . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
3.2.9 plotfftreal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
3.3 Simple operations on periodic functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
3.3.1 involute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
3.3.2 peven . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
3.3.3 podd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
3.3.4 pconv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
3.3.5 pxcorr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
3.3.6 lconv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
3.3.7 lxcorr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
3.3.8 isevenfunction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
3.3.9 middlepad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
3.4 Periodic functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
3.4.1 expwave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
3.4.2 pchirp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
3.4.3 pgauss . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
3.4.4 psech . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
3.4.5 pbspline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
3.4.6 shah . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
3.4.7 pheaviside . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
3.4.8 prect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
3.4.9 psinc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
3.5 Hermite functions and fractional Fourier transforms . . . . . . . . . . . . . . . . . . . . . 103
3.5.1 pherm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
3.5.2 hermbasis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
3.5.3 dfracft . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
3.5.4 ffracft . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
3.6 Approximation of continuous functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
3.6.1 fftresample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
3.6.2 dctresample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
3.6.3 pderiv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
3.6.4 fftanalytic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
3.7 Cosine and Sine transforms. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
3.7.1 dcti . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
3.7.2 dctii . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
3.7.3 dctiii . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
3.7.4 dctiv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
3.7.5 dsti . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
3.7.6 dstii . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
6 CONTENTS

3.7.7 dstiii . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114


3.7.8 dstiv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115

4 LTFAT - Wavelets 117


4.1 Basic analysis/synthesis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
4.1.1 fwt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
4.1.2 ifwt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
4.1.3 fwt2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
4.1.4 ifwt2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
4.1.5 ufwt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
4.1.6 iufwt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
4.1.7 fwtlength . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
4.1.8 fwtclength . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
4.2 Advanced analysis/synthesis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
4.2.1 wfbt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
4.2.2 iwfbt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
4.2.3 uwfbt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
4.2.4 iuwfbt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
4.2.5 wpfbt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
4.2.6 iwpfbt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
4.2.7 uwpfbt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
4.2.8 iuwpfbt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
4.2.9 wpbest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
4.2.10 wfbtlength . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
4.2.11 wfbtclength . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
4.2.12 wpfbtclength . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
4.3 Dual-tree complex wavelet transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
4.3.1 dtwfb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
4.3.2 idtwfb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
4.3.3 dtwfbreal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
4.3.4 idtwfbreal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
4.4 Wavelet Filterbank trees manipulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
4.4.1 wfbtinit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
4.4.2 dtwfbinit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
4.4.3 wfbtput . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
4.4.4 wfbtremove . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
4.4.5 wfbt2filterbank . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
4.4.6 wpfbt2filterbank . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
4.4.7 dtwfb2filterbank . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
4.4.8 fwtinit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
4.5 Frame properties of wavelet filter banks: . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
4.5.1 wfbtbounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
4.5.2 wpfbtbounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
4.5.3 dtwfbbounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
4.6 Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
4.6.1 plotwavelets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
4.6.2 wfiltinfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
4.6.3 wfiltdtinfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
4.7 Auxilary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
4.7.1 wavfun . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
4.7.2 wavcell2pack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
4.7.3 wavpack2cell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
4.8 Wavelet Filters defined in the time-domain . . . . . . . . . . . . . . . . . . . . . . . . . . 162
4.8.1 wfilt_algmband . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
4.8.2 wfilt_cmband . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
4.8.3 wfilt_coif . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
CONTENTS 7

4.8.4 wfilt_db . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166


4.8.5 wfilt_dden . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
4.8.6 wfilt_dgrid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
4.8.7 wfilt_hden . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
4.8.8 wfilt_lemarie . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
4.8.9 wfilt_matlabwrapper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
4.8.10 wfilt_mband . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
4.8.11 wfilt_remez . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
4.8.12 wfilt_symds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
4.8.13 wfilt_spline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
4.8.14 wfilt_sym . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
4.8.15 wfilt_symdden . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
4.8.16 wfilt_symorth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
4.8.17 wfilt_symtight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
4.8.18 wfilt_qshifta . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
4.8.19 wfilt_qshiftb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
4.8.20 wfilt_oddevena . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
4.8.21 wfilt_oddevenb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
4.8.22 wfilt_optsyma . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
4.8.23 wfilt_optsymb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
4.8.24 wfilt_ddena . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
4.8.25 wfilt_ddenb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
4.9 Dual-Tree Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
4.9.1 wfiltdt_qshift . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
4.9.2 wfiltdt_optsym . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
4.9.3 wfiltdt_oddeven . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
4.9.4 wfiltdt_dden . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185

5 LTFAT - Filterbanks 187


5.1 Transforms and basic routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
5.1.1 filterbank . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
5.1.2 ufilterbank . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
5.1.3 ifilterbank . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
5.1.4 filterbankwin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
5.1.5 filterbanklength . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
5.1.6 filterbanklengthcoef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
5.2 Auditory inspired filter banks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
5.2.1 cqt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
5.2.2 icqt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
5.2.3 erblett . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
5.2.4 ierblett . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
5.3 Filter generators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
5.3.1 cqtfilters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
5.3.2 erbfilters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
5.3.3 warpedfilters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
5.3.4 audfilters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
5.4 Window construction and bounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
5.4.1 filterbankdual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
5.4.2 filterbanktight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
5.4.3 filterbankrealdual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
5.4.4 filterbankrealtight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
5.4.5 filterbankbounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
5.4.6 filterbankrealbounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
5.4.7 filterbankresponse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
5.5 Auxilary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
5.5.1 filterbankfreqz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
8 CONTENTS

5.5.2 nonu2ufilterbank . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209


5.5.3 u2nonucfmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
5.5.4 nonu2ucfmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
5.6 Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
5.6.1 plotfilterbank . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
5.7 Reassignment and phase gradient . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
5.7.1 filterbankphasegrad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
5.7.2 filterbankreassign . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
5.7.3 filterbanksynchrosqueeze . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214

6 LTFAT - Non-stationary Gabor systems 217


6.1 Transforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
6.1.1 nsdgt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
6.1.2 unsdgt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
6.1.3 insdgt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
6.1.4 nsdgtreal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
6.1.5 unsdgtreal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
6.1.6 insdgtreal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
6.2 Window construction and bounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
6.2.1 nsgabdual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
6.2.2 nsgabtight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
6.2.3 nsgabframebounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
6.2.4 nsgabframediag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
6.3 Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
6.3.1 plotnsdgt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
6.3.2 plotnsdgtreal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225

7 LTFAT - Quadratic time-frequency distributions 227


7.1 Quadratic distributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
7.1.1 ambiguityfunction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
7.1.2 wignervilledist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
7.1.3 drihaczekdist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
7.1.4 quadtfdist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
7.2 Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
7.2.1 plotquadtfdist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228

8 LTFAT - Frames 231


8.1 Creation of a frame object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
8.1.1 frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
8.1.2 framepair . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
8.1.3 framedual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
8.1.4 frametight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
8.1.5 frameaccel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
8.2 Linear operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
8.2.1 frana . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
8.2.2 frsyn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
8.2.3 frsynmatrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
8.2.4 frgramian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
8.2.5 frameoperator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
8.2.6 framediag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
8.2.7 franaiter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
8.2.8 frsyniter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
8.3 Visualization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
8.3.1 plotframe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
8.3.2 framegram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
8.4 Information about a frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
CONTENTS 9

8.4.1 framebounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242


8.4.2 framered . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
8.4.3 framelength . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
8.4.4 framelengthcoef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
8.4.5 frameclength . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
8.5 Coefficients conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
8.5.1 framecoef2native . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
8.5.2 framenative2coef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
8.5.3 framecoef2tf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
8.5.4 frametf2coef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
8.5.5 framecoef2tfplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
8.6 Non-linear analysis and synthesis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
8.6.1 franabp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
8.6.2 franalasso . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
8.6.3 franagrouplasso . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
8.6.4 frsynabs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254

9 LTFAT - Signal processing tools 257


9.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
9.1.1 rms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
9.1.2 normalize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
9.1.3 gaindb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
9.1.4 crestfactor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
9.1.5 uquant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
9.2 Window functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
9.2.1 firwin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
9.2.2 firkaiser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
9.2.3 fir2long . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
9.2.4 long2fir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
9.3 Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
9.3.1 firfilter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
9.3.2 blfilter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
9.3.3 warpedblfilter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
9.3.4 pfilt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
9.3.5 magresp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
9.3.6 transferfunction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
9.3.7 pgrpdelay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
9.4 Ramping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
9.4.1 rampup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
9.4.2 rampdown . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
9.4.3 rampsignal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
9.5 Thresholding methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
9.5.1 thresh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
9.5.2 largestr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
9.5.3 largestn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
9.5.4 dynlimit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
9.5.5 groupthresh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
9.6 Image processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
9.6.1 rgb2jpeg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
9.6.2 jpeg2rgb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
9.7 Tools for OFDM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
9.7.1 qam4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
9.7.2 iqam4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
10 CONTENTS

10 LTFAT - Simple auditory processing 275


10.1 Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
10.1.1 semiaudplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
10.2 Auditory scales . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
10.2.1 audtofreq . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
10.2.2 freqtoaud . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
10.2.3 audspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276
10.2.4 audspacebw . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276
10.2.5 erbtofreq . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
10.2.6 freqtoerb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
10.2.7 erbspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
10.2.8 erbspacebw . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
10.2.9 audfiltbw . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
10.3 Range compression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
10.3.1 rangecompress . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
10.3.2 rangeexpand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
10.4 Auditory filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
10.4.1 gammatonefir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280

11 LTFAT - Signals 281


11.1 Signal generators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
11.1.1 ctestfun . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
11.1.2 noise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
11.1.3 pinknoise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
11.1.4 expchirp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
11.2 Sound signals. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
11.2.1 bat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
11.2.2 batmask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
11.2.3 greasy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
11.2.4 cocktailparty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
11.2.5 gspi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
11.2.6 linus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
11.2.7 ltfatlogo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
11.2.8 otoclick . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
11.2.9 traindoppler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
11.3 Images. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
11.3.1 cameraman . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
11.3.2 lichtenstein . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
11.3.3 ltfattext . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290

12 LTFAT - Demos 291


12.1 Basic demos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
12.1.1 demo_dgt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
12.1.2 demo_gabfir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
12.1.3 demo_wavelets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
12.2 Compression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
12.2.1 demo_imagecompression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
12.2.2 demo_audiocompression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
12.3 Denoising . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
12.3.1 demo_audiodenoise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
12.4 Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
12.4.1 demo_ofdm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
12.4.2 demo_audioshrink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
12.4.3 demo_gabmulappr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
12.4.4 demo_bpframemul . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
12.4.5 demo_frsynabs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
CONTENTS 11

12.4.6 demo_filterbanksynchrosqueeze . . . . . . . . . . . . . . . . . . . . . . . . . . . 304


12.5 Aspects of particular functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
12.5.1 demo_nsdgt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
12.5.2 demo_pgauss . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306
12.5.3 demo_pbspline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308
12.5.4 demo_gabmixdual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310
12.5.5 demo_framemul . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
12.5.6 demo_phaseplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
12.5.7 demo_phaseret . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312
12.5.8 demo_nextfastfft . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312
12.5.9 demo_filterbanks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
12.6 Auditory scales and filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
12.6.1 demo_audscales . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
12.6.2 demo_auditoryfilterbank . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
12.6.3 demo_wfbt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320
12.7 Block-processing demos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
12.7.1 demo_blockproc_basicloop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
12.7.2 demo_blockproc_paramequalizer . . . . . . . . . . . . . . . . . . . . . . . . . . 322
12.7.3 demo_blockproc_denoising . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323
12.7.4 demo_blockproc_slidingsgram . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323
12.7.5 demo_blockproc_slidingcqt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
12.7.6 demo_blockproc_slidingerblets . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
12.7.7 demo_blockproc_dgtequalizer . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
12.7.8 demo_blockproc_effects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
12 CONTENTS
Chapter 1

LTFAT - Base routines

1.1 Basic routines


1.1.1 LTFATSTART - Start the LTFAT toolbox
Usage

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.

!!WARNING for MATLAB users!!

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.

1.1.2 LTFATSTOP - Stops the LTFAT toolbox


Usage

ltfatstop;

Description

ltfatstop removes all LTFAT subdirectories from the path.

13
14 CHAPTER 1. LTFAT - BASE ROUTINES

1.1.3 LTFATHELP - Help on the LTFAT toolbox


Usage
ltfathelp;
v=ltfathelp(’version’);
mlist=ltfathelp(’modules’);

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.

1.1.4 LTFATMEX - Compile Mex/Oct interfaces


Usage
ltfatmex;
ltfatmex(...);

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:

’compile’ Compile stuff. This is the default.

’clean’ Removes the compiled functions.

’test’ Run some small tests that verify that the compiled functions work.

The target to work on is determined by on of the following flags.


General LTFAT:

’lib’ Perform action on the LTFAT C library.

’mex’ Perform action on the mex / oct interfaces.

’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.

Block-processing framework related:

’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:

’verbose’ Print action details.

’debug’ Build a debug version. This will disable compiler optimizations and include debug
symbols.
1.2. PARAMETER HANDLING 15

1.1.5 LTFATBASEPATH - The base path of the LTFAT installation


Usage
bp = ltfatbasepath;

Description
ltfatbasepath returns the top level directory in which the LTFAT files are installed.

1.1.6 ISOCTAVE - True if the operating environment is octave


Usage
t=isoctave();

Description
isoctave returns 1 if the operating environment is Octave, otherwise it returns 0 (Matlab)

1.2 Parameter handling


1.2.1 LTFATARGHELPER - Parse arguments for LTFAT
Usage
[flags,varargout] = ltfatarghelper(posdepnames,definput,arglist,callfun);

Input parameters
posdepnames Names of the position dependant parameters.

definput Struct to define the allowed input

arglist Commandline of the calling function (varargin)

callfun Name of calling function (optional)

Output parameters
flags Struct with information about flags.

keyvals Struct with key / values.

varargout The position dependant pars. properly initialized

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.

1.2.2 LTFATGETDEFAULTS - Get default parameters of function


ltfatgetdefaults(fname) returns the default parameters of the function fname as a cell array.
ltfatgetdefaults(’all’) returns all the set defaults.

1.2.3 LTFATSETDEFAULTS - Set default parameters of function


ltfatsetdefaults(fname,...) sets the default parameters to be the parameters specified at the
end of the list of input arguments.
ltfatsetdefaults(fname) clears any default parameters for the function fname.
ltfatsetdefaults(’clearall’) clears all defaults from all functions.

1.2.4 SCALARDISTRIBUTE - Copy scalar to array shape for parameter handling


Usage
[...] = scalardistribute(...);

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

This code produces the following output:


a =

1
1

b =

2
3

c =

4
5

1.3 Graphical user interfaces


1.3.1 MULACLAB - Graphical interface for audio processing using frame multi-
pliers
Usage
mulaclab;

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

LTFAT - Gabor analysis

2.1 Basic Time/Frequency analysis


2.1.1 TCONV - Twisted convolution
Usage
h=tconv(f,g);

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.

2.1.2 DSFT - Discrete Symplectic Fourier Transform


Usage
C=dsft(F);

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

2.1.3 ZAK - Zak transform


Usage

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

References: [47], [16]

2.1.4 IZAK - Inverse Zak transform


Usage
f=izak(c);

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]

2.1.5 COL2DIAG - Move columns of a matrix to diagonals


Usage
cout=col2diag(cin);

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.

2.1.6 S0NORM - S0-norm of signal


Usage
y = s0norm(f);
y = s0norm(f,...);

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.

2.2 Gabor systems


2.2.1 DGT - Discrete Gabor transform
Usage
c=dgt(f,g,a,M);
c=dgt(f,g,a,M,L);
c=dgt(f,g,a,M,’lt’,lt);
[c,Ls]=dgt(...);

Input parameters
f Input data.

g Window function.

a Length of time shift.

M Number of channels.

L Length of transform to do.

lt Lattice type (for non-separable lattices).

Output parameters
c M × N array of coefficients.

Ls Length of input signal.

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

where m = 0, . . . , M − 1 and n = 0, . . . , N − 1 and l − an is computed modulo L.

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

where m = 0, . . . , M − 1 and n = 0, . . . , N − 1 and l − an are computed modulo L. The additional offset w is


given by w(n) = mod (n · lt1 , lt2 )/lt2 in the formula above.

Additional parameters:

dgt takes the following flags at the end of the line of input arguments:

’freqinv’ Compute a DGT using a frequency-invariant phase. This is the default


convention described above.

’timeinv’ Compute a DGT using a time-invariant phase. This convention is typ-


ically used in FIR-filter algorithms.

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);

% Simple plot: The squared modulus of the coefficients on


% a linear scale
figure(1);
imagesc(abs(c).^2);

% Better plot: zero-frequency is displayed in the middle,


% and the coefficients are show on a logarithmic scale.
figure(2);
plotdgt(c,a,’dynrange’,50);
24 CHAPTER 2. LTFAT - GABOR ANALYSIS

References: [32], [40]

2.2.2 IDGT - Inverse discrete Gabor transform


Usage
f=idgt(c,g,a);
f=idgt(c,g,a,Ls);
f=idgt(c,g,a,Ls,lt);

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

% ... do interesting stuff to c at this point ...

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:

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);

% Analysis and synthesis window


gs=firwin(’blackman’,128);
ga=gabdual(gs,a,M,L);

c=dgt(f,ga,a,M); % analysis

% ... do interesting stuff to c at this point ...

r=idgt(c,gs,a,Ls); % synthesis

norm(f-r) % test

This code produces the following output:

ans =

6.028280895685831e-15

2.2.3 ISGRAM - Spectrogram inversion


Usage
f=isgram(c,g,a);
f=isgram(c,g,a,Ls);
[f,relres,iter]=isgram(...);

Input parameters
c Array of coefficients.

g Window function.

a Length of time shift.

Ls length of signal.

Output parameters
f Signal.

relres Vector of residuals.

iter Number of iterations done.


2.2. GABOR SYSTEMS 27

Description
isgram(s,g,a) attempts to invert a spectrogram computed by

s = abs(dgt(f,g,a,M)).^2;

using an iterative method.


isgram(c,g,a,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 idgt.
[f,relres,iter]=isgram(...) additionally return the residuals in a vector relres and the num-
ber of iteration steps iter.
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.
isgram takes the following parameters at the end of the line of input arguments:

’lt’,lt Specify the lattice type. See the help on matrix2latticetype.

’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.

Examples:
To reconstruct the phase of ’greasy’, use the following:

% Setup the problem and the coefficients


f=greasy;
g=’gauss’;
a=20; M=200;
c=dgt(f,g,a,M);
s=abs(c).^2;
theta=angle(c);

% Reconstruct and get spectrogram and angle


r=isgram(s,g,a);
c_r=dgt(r,g,a,M);
s_r=abs(c_r).^2;
theta_r=angle(c_r);

% Compute the angular difference


28 CHAPTER 2. LTFAT - GABOR ANALYSIS

d1=abs(theta-theta_r);
d2=2*pi-d1;
anglediff=min(d1,d2);

% Plot the difference in spectrogram and phase


figure(1);
plotdgt(s./s_r,a,16000,’clim’,[-10,10]);
colormap([bone;flipud(bone)])
title(’Relative difference in spectrogram’);

figure(2);
plotdgt(anglediff,a,16000,’lin’);
colormap(bone);
title(’Difference in angle’);

References: [39], [27], [59]

2.2.4 ISGRAMREAL - Spectrogram inversion (real signal)


Usage
f=isgramreal(s,g,a,M);
f=isgramreal(s,g,a,M,Ls);
2.2. GABOR SYSTEMS 29

[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

2.2.5 DGT2 - 2-D Discrete Gabor transform


Usage

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

f Input data, matrix.

g, g1, g2 Window functions.

a, a1, a2 Length of time shifts.

M, M1, M2 Number of modulations.

L1, L2 Length of transform to do

Output parameters

c array of coefficients.

Ls Original size of input matrix.

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:

1. Number of translation along 1st dimension of input.

2. Number of channel along 1st dimension of input

3. Number of translation along 2nd dimension of input.

4. Number of channel along 2nd dimension of input

5. Plane number, corresponds to 3rd dimension of input.


2.2. GABOR SYSTEMS 31

2.2.6 IDGT2 - 2D Inverse discrete Gabor transform


Usage
f=idgt2(c,g,a);
f=idgt2(c,g1,g2,a);
f=idgt2(c,g1,g2,[a1 a2]);
f=idgt2(c,g,a,Ls);
f=idgt2(c,g1,g2,a,Ls);
f=idgt2(c,g1,g2,[a1 a2],Ls);

Input parameters
c Array of coefficients.

g, g1, g2 Window function(s).

a, a1, a2 Length(s) of time shift.

Ls Length(s) of reconstructed signal (optional).

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.

2.2.7 DGTREAL - Discrete Gabor transform for real-valued signals


Usage
c=dgtreal(f,g,a,M);
c=dgtreal(f,g,a,M,L);
[c,Ls]=dgtreal(f,g,a,M);
[c,Ls]=dgtreal(f,g,a,M,L);

Input parameters
f Input data

g Window function.

a Length of time shift.

M Number of modulations.

L Length of transform to do.


32 CHAPTER 2. LTFAT - GABOR ANALYSIS

Output parameters

c M * N array of coefficients.

Ls Length of input signal.

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:

’freqinv’ Compute a dgtreal using a frequency-invariant phase. This is the


default convention described in the help for dgt.

’timeinv’ Compute a dgtreal using a time-invariant phase. This convention


is typically used in filter bank algorithms.

dgtreal can be used to manually compute a spectrogram, if you want full control over the parameters
and want to capture the output

f=greasy; % Input test signal


fs=16000; % The sampling rate of this particular test signal
a=10; % Downsampling factor in time
M=200; % Total number of channels, only 101 will be computed

% Compute the coefficients using a 20 ms long Hann window


c=dgtreal(f,{’hann’,0.02*fs’},a,M);

% Visualize the coefficients as a spectrogram


dynrange=90; % 90 dB dynamical range for the plotting
plotdgtreal(c,a,M,fs,dynrange);
2.2. GABOR SYSTEMS 33

References: [32], [40]

2.2.8 IDGTREAL - Inverse discrete Gabor transform for real-valued signals


Usage
f=idgtreal(c,g,a,M);
f=idgtreal(c,g,a,M,Ls);

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

% ... do interesting stuff to c at this point ...

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);

% Analysis and synthesis window


gs=firwin(’blackman’,128);
ga=gabdual(gs,a,M,L);

c=dgtreal(f,ga,a,M); % analysis

% ... do interesting stuff to c at this point ...

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

2.2.9 GABWIN - Compute a Gabor window from text or cell array


Usage
[g,info] = gabwin(g,a,M,L);

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:

’gauss’ Gaussian window fitted to the lattice, i.e. t f r = a · M/L.

’dualgauss’ Canonical dual of Gaussian window.

’tight’ Tight window generated from a Gaussian.

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, gabwin will generate
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’,...} Canonical dual window of whatever follows. See the examples below.
{’tight’,...} Canonical tight 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: 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);

To compute the dual of a Hann window of length 20:

g=gabwin({’dual’,{’hann’,20}},a,M,L);

The structure info provides some information about the computed window:

info.gauss True if the window is a Gaussian.


info.tfr Time/frequency support ratio of the window. Set whenever it makes sense.
36 CHAPTER 2. LTFAT - GABOR ANALYSIS

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.

2.2.10 PROJKERN - Projection onto generating kernel space


Usage

cout=projkern(cin,a);
cout=projkern(cin,g,a);
cout=projkern(cin,ga,gs,a);

Input parameters

cin Input coefficients

g analysis/synthesis window

ga analysis window

gs synthesis window

a Length of time shift.

Output parameters

cout Output coefficients

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.

2.2.11 DGTLENGTH - DGT length from signal


Usage

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);

and all valid transform lengths are multipla of Lsmallest

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);

2.3 Wilson bases and WMDCT


2.3.1 DWILT - Discrete Wilson transform
Usage
c=dwilt(f,g,M);
c=dwilt(f,g,M,L);
[c,Ls]=dwilt(...);

Input parameters
f Input data

g Window function.

M Number of bands.

L Length of transform to do.

Output parameters
c 2M × N array of coefficients.

Ls Length of input signal.

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]

2.3.2 IDWILT - Inverse discrete Wilson transform


Usage
f=idwilt(c,g);
f=idwilt(c,g,Ls);

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]

2.3.3 DWILT2 - 2D Discrete Wilson transform


Usage
c=dwilt2(f,g,M);
c=dwilt2(f,g1,g2,[M1,M2]);
c=dwilt2(f,g1,g2,[M1,M2],[L1,L2]);
[c,Ls]=dwilt2(f,g1,g2,[M1,M2],[L1,L2]);

Input parameters
f Input data, matrix.

g, g1, g2 Window functions.

M, M1, M2 Number of bands.

L1, L2 Length of transform to do.

Output parameters
c array of coefficients.

Ls Original size of input matrix.

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:

1. Number of translations along 1st dimension of input.


2. Number of channels along 1st dimension of input
3. Number of translations along 2nd dimension of input.
40 CHAPTER 2. LTFAT - GABOR ANALYSIS

4. Number of channels along 2nd dimension of input


5. Plane number, corresponds to 3rd dimension of input.

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;

2.3.4 IDWILT2 - 2D Inverse Discrete Wilson transform


Usage
f=idwilt2(c,g);
2.3. WILSON BASES AND WMDCT 41

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.

2.3.5 WMDCT - Windowed MDCT transform


Usage
c=wmdct(f,g,M);
c=wmdct(f,g,M,L);
[c,Ls]=wmdct(...);

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]

2.3.6 IWMDCT - Inverse MDCT


Usage
f=iwmdct(c,g);
f=iwmdct(c,g,Ls);
2.3. WILSON BASES AND WMDCT 43

Input parameters
c M*N array of coefficients.

g Window function.

Ls Final length of function (optional)

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]

2.3.7 WMDCT2 - 2D Discrete windowed MDCT transform


Usage
c=wmdct2(f,g,M);
c=wmdct2(f,g1,g2,[M1,M2]);
c=wmdct2(f,g1,g2,[M1,M2],[L1,L2]);
[c,L]=wmdct2(f,g1,g2,[M1,M2],[L1,L2]);

Input parameters
f Input data, matrix.

g, g1, g2 Window functions.

M, M1, M2 Number of bands.

L1, L2 Length of transform to do.

Output parameters
c array of coefficients.

Ls Original size of input matrix.

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:

1. Number of translation along 1st dimension of input.


2. Number of channel along 1st dimension of input
3. Number of translation along 2nd dimension of input.
4. Number of channel along 2nd dimension of input
5. Plane number, corresponds to 3rd dimension of input.

2.3.8 IWMDCT2 - 2D Inverse windowed MDCT transform


Usage
f=iwmdct2(c,g);
f=iwmdct2(c,g1,g2);
f=iwmdct2(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
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.

2.3.9 WIL2RECT - Arrange Wilson coefficients in a rectangular layout


Usage
c=wil2rect(c);

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.

2.3.10 RECT2WIL - Inverse of WIL2RECT


Usage
c=rect2wil(c);
2.3. WILSON BASES AND WMDCT 45

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.

2.3.11 WILWIN - Compute a Wilson/WMDCT window from text or cell array


Usage
[g,info] = wilwin(g,M,L);

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.

2.3.12 DWILTLENGTH - DWILT/WMDCT length from signal


Usage

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;

and all valid transform lengths are multipla of Lsmallest

2.4 Reconstructing windows


2.4.1 GABDUAL - Canonical dual window of Gabor frame
Usage

gd=gabdual(g,a,M);
gd=gabdual(g,a,M,L);
gd=gabdual(g,a,M,’lt’,lt);

Input parameters

g Gabor window.

a Length of time shift.

M Number of channels.

L Length of window. (optional)

lt Lattice type (for non-separable lattices).

Output parameters

gd Canonical dual window.


2.4. RECONSTRUCTING WINDOWS 47

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);

% Simple plot in the time-domain


figure(1);
plot(gd);

% Frequency domain
figure(2);
magresp(gd,’dynrange’,100);
48 CHAPTER 2. LTFAT - GABOR ANALYSIS

2.4.2 GABTIGHT - Canonical tight window of Gabor frame


Usage
gt=gabtight(a,M,L);
gt=gabtight(g,a,M);
gt=gabtight(g,a,M,L);
gd=gabtight(g,a,M,’lt’,lt);

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);

% Simple plot in the time-domain


figure(1);
plot(gt);

% Frequency domain
figure(2);
magresp(gt,’dynrange’,100);
50 CHAPTER 2. LTFAT - GABOR ANALYSIS

2.4.3 GABFIRDUAL - Compute FIR dual window


Usage
gd=gabfirdual(Ldual,g,a,M);
gd=gabfirdual(Ldual,g,a,M, varagin);

Input parameters
Ldual Length of dual window

g Window function

a Time shift

M Number of Channels

alpha1 Weight of l 1 -norm in the time domain

alpha2 Weight of l 1 -norm in the freq. domain

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:

gd =arg min ‖αx‖1 + ‖β F x‖1


x

+ ‖ω(x − gl )‖22

δ ‖x‖S0 + µ‖∇x‖22 + γ‖∇F x‖22

such that x is a dual window of g

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:

’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
2.4. RECONSTRUCTING WINDOWS 51

’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.4 GABOPTDUAL - Compute dual window


Usage
gd=gaboptdual(g,a,M);
gd=gaboptdual(g,a,M, varagin);

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:

gd =arg min ‖αx‖1 + ‖β F x‖1


x

+ ‖ω(x − gl )‖22

δ ‖x‖S0 + µ‖∇x‖22 + γ‖∇F x‖22

such that x is a dual window of g

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

’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.5 GABFIRTIGHT - Compute FIR tight window


Usage
gt=gabfirtight(Lsupport,g,a,M);
gt=gabfirtight(Lsupport,g,a,M, varagin);

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:

gd =arg min ‖αx‖1 + ‖β F x‖1


x

+ ‖ω(x − gl )‖22

δ ‖x‖S0 + µ‖∇x‖22 + γ‖∇F x‖22

such that x is a tight FIR window


54 CHAPTER 2. LTFAT - GABOR ANALYSIS

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

2.4.6 GABOPTTIGHT - Compute a optimized tight window


Usage
gt=gabopttight(Ltight,g,a,M);
gt=gabopttight(Ltight,g,a,M, varagin);

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:

gd =arg min ‖αx‖1 + ‖β F x‖1


x

+ ‖ω(x − gl )‖22

δ ‖x‖S0 + µ‖∇x‖22 + γ‖∇F x‖22

such that x is tight windowg

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:

’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
56 CHAPTER 2. LTFAT - GABOR ANALYSIS

’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 constraint: µ = 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.7 GABCONVEXOPT - Compute a window using convex optimization


Usage
gout=gabconvexopt(g,a,M);
gout=gabconvexopt(g,a,M, varagin);

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

gd =arg min ‖αx‖1 + ‖β F x‖1


x

+ ‖ω(x − gl )‖22

δ ‖x‖S0 + µ‖∇x‖22 + γ‖∇F x‖22

such that x satisfies the constraints

Three constraints are possible:


∙ x is dual with respect of g
∙ x is tight
∙ x is compactly supported on Ldual
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. 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 constraint: µ = 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

’support’ Ldual Add a constraint on the support. The windows should be com-
pactly supported on Ldual.
58 CHAPTER 2. LTFAT - GABOR ANALYSIS

’tight’ Look for a tight windows


’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.8 GABPROJDUAL - Gabor Dual window by projection


Usage
gd=gabprojdual(gm,g,a,M)
gd=gabprojdual(gm,g,a,M,L)

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

2.4.9 GABMIXDUAL - Computes the mixdual of g1


Usage
gamma=mixdual(g1,g2,a,M)

Input parameters
g1 Window 1

g2 Window 2

a Length of time shift.

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]

2.4.10 WILORTH - Wilson orthonormal window


Usage
gt=wilorth(M,L);
gt=wilorth(g,M);
gt=wilorth(g,M,L);

Input parameters
g Auxiliary window window function (optional).

M Number of modulations.

L Length of window (optional).

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.

2.4.11 WILDUAL - Wilson dual window


Usage

gamma=wildual(g,M);
gamma=wildual(g,M,L);

Input parameters

g Gabor window.

M Number of modulations.

L Length of window. (optional)

Output parameters

gamma Canonical dual window.

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.

2.5 Conditions numbers


2.5.1 GABFRAMEBOUNDS - Calculate frame bounds of Gabor frame
Usage

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.

a Length of time shift.

M Number of channels.

L Length of transform to consider.

lt Lattice type (for non-separable lattices).

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.

2.5.2 GABRIESZBOUNDS - Calculate Riesz sequence/basis bounds of Gabor frame


Usage
fcond=gabrieszbounds(g,a,M);
[A,B]=gabrieszbounds(g,a,M);
[A,B]=gabrieszbounds(g,a,M,L);

Input parameters
g The window function.

a Length of time shift.

M Number of channels.

L Length of transform to consider.

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

2.5.3 WILBOUNDS - Calculate frame bounds of Wilson basis


Usage
[AF,BF]=wilbounds(g,M)
[AF,BF]=wilbounds(g,M,L)

Input parameters
g Window function.

M Number of channels.

L Length of transform to do (optional)

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.

2.5.4 GABDUALNORM - Measure of how close a window is to being a dual win-


dow
Usage
dn=gabdualnorm(g,gamma,a,M);
dn=gabdualnorm(g,gamma,a,M,L);
dn=gabdualnorm(g,gamma,a,M,’lt’,lt);
[scal,res]=gabdualnorm(...);

Input parameters
gamma input window..

g window function.

a Length of time shift.

M Number of modulations.

L Length of transform to consider

Output parameters
dn dual norm.

scal Scaling factor

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);

Then er < eest for all possible input signals f.


To get a similar estimate for an almost tight window gt, simply use

eest=gabdualnorm(gt,gt,a,M,L);

2.5.5 GABFRAMEDIAG - Diagonal of Gabor frame operator


Usage
d=gabframediag(g,a,M,L);
d=gabframediag(g,a,M,L,’lt’,lt);

Input parameters
g Window function.

a Length of time shift.

M Number of channels.

L Length of transform to do.

lt Lattice type (for non-separable lattices).

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.

2.5.6 WILFRAMEDIAG - Diagonal of Wilson and WMDCT frame operator


Usage
d=wilframediag(g,M,L);
64 CHAPTER 2. LTFAT - GABOR ANALYSIS

Input parameters
g Window function.

M Number of channels.

L Length of transform to do.

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.

2.6 Phase gradient methods and reassignment


2.6.1 GABPHASEGRAD - Phase gradient of the DGT
Usage
[tgrad,fgrad,c] = gabphasegrad(’dgt’,f,g,a,M);
[tgrad,fgrad] = gabphasegrad(’phase’,cphase,a);
[tgrad,fgrad] = gabphasegrad(’abs’,s,g,a);

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

tgradabs = bsxfun(@plus,tgrad,fftindex(M)*L/M); fgradabs = bsxfun(@plus,fgrad,(0:L/a-1)*a);

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.

’cross’ Directly from the signal using algorithm by Nelson.

’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.

[tgrad,fgrad]=gabphasegrad(’dgt’,f,g,a,M) computes the time-frequency gradient us-


ing a DGT of the signal f. The DGT is computed using the window g on the lattice specified by the time
shift a and the number of channels M. The algorithm used to perform this calculation computes several
DGTs, and therefore this routine takes the exact same input parameters as dgt.
2.6. PHASE GRADIENT METHODS AND REASSIGNMENT 65

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]

2.6.2 GABPHASEDERIV - DGT phase derivatives


Usage
[phased,c] = gabphasederiv(dflag,’dgt’,f,g,a,M);
phased = gabphasederiv(dflag,’cross’,f,g,a,M)
phased = gabphasederiv(dflag,’phase’,cphase,a,difforder);
phased = gabphasederiv(dflag,’abs’,s,g,a);
[{phased1,phased2,...}] = gabphasederiv({dflag1,dflag2,...},...);
[{phased1,phased2,...},c] = gabphasederiv({dflag1,dflag2,...},’dgt’,...);

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

’cross’ Directly from the signal using algorithm by Nelson.


’phase’ From the unwrapped phase of a DGT of the signal using a finite differ-
ences scheme. This is the classic method used in the phase vocoder.
’abs’ From the absolute value of the DGT exploiting explicit dependency
between partial derivatives of log-magnitudes and phase. Currently
this method works only for Gaussian windows.
phased=gabphasederiv(dflag,’dgt’,f,g,a,M) computes the time-frequency derivative
using a DGT of the signal f. The DGT is computed using the window g on the lattice specified by the time
shift a and the number of channels M. The algorithm used to perform this calculation computes several
DGTs, and therefore this routine takes the exact same input parameters as dgt.
[phased,c]=gabphasederiv(dflag,’dgt’,f,g,a,M) additionally returns the Gabor co-
efficients c, as they are always computed as a byproduct of the algorithm.
phased=gabphasederiv(dflag,’cross’,f,g,a,M) does the same as above but this time
using algorithm by Nelson which is based on computing several DGTs.
phased=gabphasederiv(dflag,’phase’,cphase,a) computes the phase derivative 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.:
phased=gabphasederiv(dflag,’phase’,angle(dgt(f,g,a,M)),a)
phased=gabphasederiv(dflag,’abs’,s,g,a) computes the phase derivative from the ab-
solute values of DGT coefficients s. The spectrogram must have been computed using the window g and
time-shift a e.g.:
phased=gabphasederiv(dflag,’abs’,abs(dgt(f,g,a,M)),g,a)
Currently the ’abs’ method only works if the window g is a Gaussian window specified as a string or
a cell array.
phased=gabphasederiv(dflag,’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.

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

Several derivatives at once


phasedcell=gabphasederiv({dflag1,dflag2,...},...) computes several phase deriva-
tives at once while reusing some temporary computations thus saving computation time. {dflag1,dflag2,...}
is a cell array of the derivative flags and cell elements of the returned phasedcell contain the correspond-
ing derivatives i.e.:
[pderiv1,pderiv2,...] = deal(phasedcell{:});
[phasedcell,c]=gabphasederiv({dflag1,dflag2,...},’dgt’,...) works the same
as above but in addition returns coefficients c which are the byproduct of the ’dgt’ method.
Other flags and parameters work as before.
References: [10], [22], [34], [9], [33], [67], [75]

2.6.3 GABREASSIGN - Reassign time-frequency distribution


Usage
sr = gabreassign(s,tgrad,fgrad,a);

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);

% Perform the actual reassignment


sr = gabreassign(abs(c).^2,tgrad,fgrad,a);

% Display it using plotdgt


plotdgt(sr,a,143000,50);

References: [10]
68 CHAPTER 2. LTFAT - GABOR ANALYSIS

2.6.4 GABREASSIGNADJUST - Adjustable reassignment of a time-frequency dis-


tribution

Usage

sr = gabreassignadjust(s,pderivs,a,mu);

Description

gabreassignadjust(s,pderivs,a,mu) reassigns the values of the positive time-frequency distri-


bution s using first and second order phase derivatives given by pderivs and parameter mu>0. The lattice is
determined by the time shift a and the number of channels deduced from the size of s.
pderivs is a cell array of phase derivatives which can be obtained as follows:

pderivs = gabphasederiv({’t’,’f’,’tt’,’ff’,’tf’},...,’relative’);

Please see help of gabphasederiv for description of the missing parameters.


gabreassign(s,pderivs,a,mu,despeckle) works as above, but some coeficients are re-
moved prior to the reassignment process. More precisely a mixed phase derivative pderivs{5} is used to
determine which coefficients m,n belong to sinusoidal components (such that abs(1+pderivs{5}(m,n))
is close to zero) and to impulsive components (such that abs(pderivs{5}(m,n)) is close to zero).
Parameter despeckle determines a threshold on the previous quantities such that coefficients with higher
associated values are set to zeros.

Algorithm

The routine uses the adjustable reassignment presented in the references.

Examples:

The following example demonstrates how to manually create a reassigned spectrogram.:

% Compute the phase derivatives


a=4; M=100;
[pderivs, c] = gabphasederiv({’t’,’f’,’tt’,’ff’,’tf’},’dgt’,bat,’gauss’,a,M,’relat

% Reassignemt parameter
mu = 0.1;
% Perform the actual reassignment
sr = gabreassignadjust(abs(c).^2,pderivs,a,mu);

% Display it using plotdgt


plotdgt(sr,a,143000,50);
2.7. PHASE RECONSTRUCTION 69

References: [9], [8], [75]

2.7 Phase reconstruction


2.7.1 CONSTRUCTPHASE - Construct phase for DGT
Usage

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.

g Analysis Gabor window.

a Hop factor.

tol Relative tolerance.

mask Mask for selecting known phase.

usephase Explicit known phase.

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.


70 CHAPTER 2. LTFAT - GABOR ANALYSIS

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);

then constuctphase(s,g,a) 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’,tfr}.
constructphase(s,g,a,tol) does as above, but sets the phase of coefficients less than tol to
random values. By default, tol has the value 1e-10.
constructphase(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) determine
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]

2.7.2 CONSTRUCTPHASEREAL - Construct phase for DGTREAL


Usage

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.

g Analysis Gabor window.

a Hop factor.

M Number of channels.

tol Relative tolerance.

mask Mask for selecting known phase.

usephase Explicit known phase.


2.8. PHASE CONVERSIONS 71

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]

2.8 Phase conversions


2.8.1 PHASELOCK - Phaselock Gabor coefficients
Usage
c=phaselock(c,a);

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

where m = 0, . . . , M − 1 and n = 0, . . . , N − 1 and l − an is computed modulo L.


phaselock(c,a,’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.
References: [77]

2.8.2 PHASEUNLOCK - Undo phase lock of Gabor coefficients


Usage
c=phaseunlock(c,a);

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]

2.8.3 PHASELOCKREAL - Phaselock Gabor coefficients


Usage
c=phaselockreal(c,a,M);

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]

2.8.4 PHASEUNLOCKREAL - Undo phase lock of Gabor coefficients


Usage
c=phaseunlockreal(c,a,M);

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]

2.8.5 SYMPHASE - Change Gabor coefficients to symmetric phase


Usage
c=symphase(c,a);
2.9. SUPPORT FOR NON-SEPARABLE LATTICES 73

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

where m = 0, . . . , M − 1 and n = 0, . . . , N − 1 and l − an is computed modulo L.


symphase(c,a,’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.
References: [22]

2.9 Support for non-separable lattices


2.9.1 MATRIX2LATTICETYPE - Convert matrix form to standard lattice descrip-
tion
Usage

[a,M,lt] = matrix2latticetype(L,V);

Description

[a,M,lt]=matrix2latticetype(L,V) converts a 2×2 integer matrix description into the standard


description of a lattice using the a, M and lt. The conversion is only valid for the specified transform length
L.
The lattice type lt is a 1×2 vector [lt1 , lt2 ] denoting an irreducible fraction lt1 /lt2 . This fraction describes
the distance in frequency (counted in frequency channels) that each coefficient is offset when moving in
time by the time-shift of a. Some examples: lt=[0 1] defines a square lattice, lt=[1 2] defines the
quinqux (almost hexagonal) lattice, lt=[1 3] describes a lattice with a 1/3 frequency offset for each
time shift and so forth.
An example:

[a,M,lt] = matrix2latticetype(120,[10 0; 5 10])

This code produces the following output:

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;

2.9.2 LATTICETYPE2MATRIX - Convert lattice description to matrix form


Usage

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])

This code produces the following output:

V =

10 0
5 10

2.9.3 SHEARFIND - Shears for transformation of a general lattice to separable


Usage
[s0,s1,br] = shearfind(L,a,M,lt);

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.

2.9.4 NOSHEARLENGTH - Transform length that does not require a frequency


shear
Usage
L=noshearlength(Ls,a,M,lt)

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.

’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 de-
fault 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.

’linsq’ Show the square of the coefficients on a linear scale.

’linabs’ Show the absolute value of the coefficients on a linear scale.

’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.

’image’ Use imagesc to display the plot. This is the default.

’contour’ Do a contour plot.

’surf’ Do a surf plot.

’colorbar’ Display the colorbar. This is the default.

’nocolorbar’ Do not display the colorbar.

’display’ Display the figure. This is the default.

’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’

’frequency’,f The word denoting frequency. Default is ’Frequency’

’samples’,s The word denoting samples. Default is ’samples’

’normalized’,n Defult value is ’normalized’.


2.10. PLOTS 77

2.10.2 PLOTDGT - Plot DGT coefficients


Usage
plotdgt(coef,a);
plotdgt(coef,a,fs);
plotdgt(coef,a,fs,dynrange);

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.

2.10.3 PLOTDGTREAL - Plot DGTREAL coefficients


Usage
plotdgtreal(coef,a,M);
plotdgtreal(coef,a,M,fs);
plotdgtreal(coef,a,M,fs,dynrange);

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.

2.10.4 PLOTDWILT - Plot DWILT coefficients


Usage
plotdwilt(coef);
plotdwilt(coef,fs);
plotdwilt(coef,fs,dynrange);

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

plotdwilt(coef,fs,dynrange) will additionally limit the dynamic range.


C=plotdwilt(...) 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.
plotdwilt supports all the optional parameters of tfplot. Please see the help of tfplot for an exhaustive
list.

2.10.5 PLOTWMDCT - Plot WMDCT coefficients


Usage
plotwmdct(coef);
plotwmdct(coef,fs);
plotwmdct(coef,fs,dynrange);

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.

2.10.6 SGRAM - Spectrogram


Usage
sgram(f,op1,op2, ... );
sgram(f,fs,op1,op2, ... );
C=sgram(f, ... );

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)

The arguments must be character strings possibly followed by an argument:

’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. A logarith-
mic scale is more adapted to perception of sound. This is the default.
2.10. PLOTS 79

’lin’ Show the energy of the coefficients on a linear scale.

’tfr’,v Set the ratio of frequency resolution to time resolution. A value v = 1


is the default. Setting v > 1 will give better frequency resolution at the
expense of a worse time resolution. A value of 0 < v < 1 will do the
opposite.

’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.

’nf’ Display negative frequencies, with the zero-frequency centered in the


middle. For real signals, this will just mirror the upper half plane. This
is standard for complex 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.

’image’ Use imagesc to display the spectrogram. 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.

’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.

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));

2.10.7 GABIMAGEPARS - Find Gabor parameters to generate image


Usage
[a,M,L,N,Ngood]=gabimagepars(Ls,x,y);

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);

The size of c is (M/2) + 1 × N equal to 601 × 700 pixels.


For this function to work properly, the specified numbers for x and y must not be large prime numbers.

2.10.8 RESGRAM - Reassigned spectrogram plot

Usage

resgram(f,op1,op2, ... );
resgram(f,fs,op1,op2, ... );

Description

resgram(f) plots a reassigned spectrogram of f.


resgram(f,fs) does the same for a signal with sampling rate fs (sampled with fs samples per sec-
ond).
Because reassigned spectrograms can have an extreme dynamical range, consider always using the
’dynrange’ or ’clim’ options (see below) in conjunction with the ’db’ option (on by default). An
example:

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:

’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. A logarith-
mic scale is more adapted to perception of sound. This is the default.

’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.

’lin’ Show the energy of the coefficients on a linear scale.

’tfr’,v Set the ratio of frequency resolution to time resolution. A value v = 1


is the default. Setting v > 1 will give better frequency resolution at the
expense of a worse time resolution. A value of 0 < v < 1 will do the
opposite.

’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.

’nf’ Display negative frequencies, with the zero-frequency centered in the


middle. For real signals, this will just mirror the upper half plane. This
is standard for complex 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.

’image’ Use imagesc to display the spectrogram. This is the default.


2.10. PLOTS 83

’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.

2.10.9 INSTFREQPLOT - Plot of instantaneous frequency


Usage
instfreqplot(f,op1,op2, ... );
instfreqplot(f,fs,op1,op2, ... );

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

will produce a nice instantaneous frequency plot of the greasy signal.


instfreqplot accepts the following optional arguments:

’tfr’,v Set the ratio of frequency resolution to time resolution. A value v = 1


is the default. Setting v > 1 will give better frequency resolution at the
expense of a worse time resolution. A value of 0 < v < 1 will do the
opposite.

’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

’nf’ Display negative frequencies, with the zero-frequency centered in the


middle. For real signals, this will just mirror the upper half plane. This
is standard for complex 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.

’image’ Use imagesc to display the spectrogram. This is the default.

’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.

’climsym’,cval Use a colormap ranging from −cval to cval

’fmax’,y Display y as the highest frequency.

2.10.10 PHASEPLOT - Phase plot


Usage
phaseplot(f,op1,op2, ... );
phaseplot(f,fs,op1,op2, ... );

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:

’tfr’,v Set the ratio of frequency resolution to time resolution. A value v = 1


is the default. Setting v > 1 will give better frequency resolution at the
expense of a worse time resolution. A value of 0 < v < 1 will do the
opposite.

’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

’nf’ Display negative frequencies, with the zero-frequency centered in the


middle. For real signals, this will just mirror the upper half plane. This
is standard for complex signals.

’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.

’timeinv’ Display the phase as computed by a time-invariant dgt. This is the


default.

’freqinv’ Display the phase as computed by a frequency-invariant dgt.

’fmax’,y Display y as the highest frequency.

’colorbar’ Display the colorbar. This is the default.

’nocolorbar’ Do not display the colorbar.

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);

The following phaseplot shows the phase of white, Gaussian noise:

phaseplot(randn(200,1));
colormap(hsv);
86 CHAPTER 2. LTFAT - GABOR ANALYSIS

References: [20]
Chapter 3

LTFAT - Basic Fourier and DCT


analysis.

3.1 Support routines


3.1.1 FFTINDEX - Frequency index of FFT modulations
Usage
n=fftindex(N);

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.

3.1.2 MODCENT - Centered modulo


Usage
y=modcent(x,r);

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);

3.1.3 FLOOR23 - Previous number with only 2,3 factors


Usage
nceil=floor23(n);

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’);

3.1.4 FLOOR235 - Previous number with only 2,3 and 5 factors


Usage
nfloor=floor235(n);

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’);

3.1.5 CEIL23 - Next number with only 2,3 factors


Usage

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)

This code produces the following output:

ans =

24

3.1.6 CEIL235 - Next number with only 2,3 and 5 factors


Usage

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

3.1.7 NEXTFASTFFT - Next higher number with a fast FFT


Usage
nfft=nextfastfft(n);

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]

3.2 Basic Fourier analysis


3.2.1 DFT - Normalized Discrete Fourier Transform
Usage
f=dft(f);
f=dft(f,N,dim);

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

3.2.2 IDFT - Inverse normalized Discrete Fourier Transform


Usage
f=idft(c);
f=idft(c,N,dim);

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.

3.2.3 FFTREAL - FFT for real valued input data


Usage
f=fftreal(f);
f=fftreal(f,N,dim);

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.

3.2.4 IFFTREAL - Inverse FFT for real valued signals


Usage
f=ifftreal(c,N);
f=ifftreal(c,N,dim);

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.

3.2.5 GGA - Generalized Goertzel algorithm


Usage
c = gga(x,fvec)
c = gga(x,fvec,fs)

Input parameters
x Input data.

fvec Indices to calculate.

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:

% Generate input signal


fs = 8000;
L = 2^10;
k = (0:L-1).’;
freq = [400,510,620,680,825];
phase = [pi/4,-pi/4,-pi/8,pi/4,-pi/3];
amp = [5,3,4,1,2];
f = arrayfun(@(a,f,p) a*sin(2*pi*k*f/fs+p),...
amp,freq,phase,’UniformOutput’,0);
f = sum(cell2mat(f),2);

% This is equal to fft(f)


ck = gga(f);

%GGA to FFT error:


norm(ck-fft(f))

% DTFT samples at 400,510,620,680,825 Hz


ckgga = gga(f,freq,fs);

% Plot modulus of coefficients


figure(1);clf;hold on;
stem(k/L*fs,2*abs(ck)/L,’k’);
stem(freq,2*abs(ckgga)/L,’r:’);
set(gca,’XLim’,[freq(1)-50,freq(end)+50]);
set(gca,’YLim’,[0 6]);
xlabel(’f[Hz]’);
ylabel(’|c(k)|’);
hold off;

% Plot phase of coefficients


figure(2);clf;hold on;
stem(k/L*fs,angle(ck),’k’);
stem(freq,angle(ckgga),’r:’);
set(gca,’XLim’,[freq(1)-50,freq(end)+50]);
set(gca,’YLim’,[-pi pi]);
3.2. BASIC FOURIER ANALYSIS 93

xlabel(’f[Hz]’);
ylabel(’angle(c(k))’);
hold off;
This code produces the following output:
ans =

1.604964106526122e-09

References: [90]

3.2.6 CHIRPZT - Chirped Z-transform


Usage
c = chirpzt(f,K,fdiff)
c = chirpzt(f,K,fdiff,foff)
c = chirpzt(f,K,fdiff,foff,fs)

Input parameters
f Input data.
K Number of values.
94 CHAPTER 3. LTFAT - BASIC FOURIER AND DCT ANALYSIS.

fdiff Frequency increment.

foff Starting frequency.

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):

% Generate input signal


fs = 8000;
L = 2^10;
k = (0:L-1).’;
f1 = 400;
f2 = 825;
f = 5*sin(2*pi*k*f1/fs + pi/4) + 2*sin(2*pi*k*f2/fs - pi/3);

% This is equal to fft(f)


ck = chirpzt(f,L);

%chirpzt to FFT error:


norm(ck-fft(f))

% 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);

% Plot modulus of coefficients


figure(1);
fax=foff+fdiff.*(0:K-1);
hold on;
stem(k/L*fs,abs(ck),’k’);
stem(fax,abs(ckchzt),’r:’);
set(gca,’XLim’,[foff,foff+K*fdiff]);
set(gca,’YLim’,[0 1065]);
xlabel(’f[Hz]’);
ylabel(’|ck|’);
3.2. BASIC FOURIER ANALYSIS 95

% Plot phase of coefficients


figure(2);
hold on;
stem(k/L*fs,angle(ck),’k’);
stem(fax,angle(ckchzt),’r:’);
set(gca,’XLim’,[foff,foff+K*fdiff]);
set(gca,’YLim’,[-pi pi]);
xlabel(’f[Hz]’);
ylabel(’angle(ck)’);
This code produces the following output:
ans =

5.944006695631077e-10

References: [78]

3.2.7 FFTGRAM - Plot the energy of the discrete Fourier transform


Usage
fftgram(f)
96 CHAPTER 3. LTFAT - BASIC FOURIER AND DCT ANALYSIS.

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:

’db’ Plots the energy on a dB scale. This is the default.


’lin’ Plots the energy on a linear scale.

In addition to these parameters, fftgram accepts any of the flags from normalize. The input signal
will be normalized as specified.

3.2.8 PLOTFFT - Plot the output from FFT


Usage
plotfft(coef);
plotfft(coef,fs);

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:

’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.

’nf’ Display negative frequencies, with the zero-frequency centered in the


middle. This is the default.

’posfreq’ Display only the positive frequencies.

’dim’,dim If coef is multidimensional, dim indicates the dimension along which


are the individual channels oriented. Value 1 indicates columns, value
2 rows.
3.3. SIMPLE OPERATIONS ON PERIODIC FUNCTIONS 97

’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.

3.2.9 PLOTFFTREAL - Plot the output from FFTREAL


Usage
plotfftreal(coef);
plotfftreal(coef,fs);

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.

3.3 Simple operations on periodic functions


3.3.1 INVOLUTE - Involution
Usage
finv=involute(f);
finv=involute(f,dim);
98 CHAPTER 3. LTFAT - BASIC FOURIER AND DCT ANALYSIS.

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);

The involution finv of f is given by:

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)));

3.3.2 PEVEN - Even part of periodic function


Usage
fe=peven(f);
fe=peven(f,dim);

Description
peven(f) returns the even part of the periodic sequence f.
peven(f,dim) does the same along dimension dim.

3.3.3 PODD - Odd part of periodic function


Usage
fe=podd(f);
fe=podd(f,dim);

Description
podd(f) returns the odd part of the periodic sequence f.
podd(f,dim) does the same along dimension dim.

3.3.4 PCONV - Periodic convolution


Usage
h=pconv(f,g)
h=pconv(f,g,ftype);

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

pconv(f,g,’r’) computes the convolution where g is reversed (involuted) given by


3.3. SIMPLE OPERATIONS ON PERIODIC FUNCTIONS 99

L−1
h (l + 1) = ∑ f (k + 1) g (k − l + 1)
k=0

This type of convolution is also known as cross-correlation.


pconv(f,g,’rr’) computes the alternative where both f and g are reversed given by
L−1
h (l + 1) = ∑ f (−k + 1) g (l − k + 1)
k=0

In the above formulas, l − k, k − l and −k are computed modulo L.


The input arrays f and g can be 1D vectors or one of them can be a multidimensional array. In either
case, the convolution is performed along columns with row vectors transformed to columns.

3.3.5 PXCORR - Periodic cross correlation


Usage
h=pxcorr(f,g)

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

In the above formula, k − l is computed modulo L.


pxcorr(f,g,’normalize’) does the same, but normalizes the output by the product of the l 2 -
norm of f and g.

3.3.6 LCONV - Linear convolution


Usage
h=lconv(f,g);

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

with Lh = L f + Lg − 1 where L f and Lg are the lengths of f and g, respectively.


lconv(f,g,’r’) computes the linear convolution of f and g where g is reversed. This type of
convolution is also known as linear cross-correlation and is given by
Lh −1
h (l + 1) = ∑ f (k + 1) g (k − l + 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

In the above formulas, l − k, k − l and −k are computed modulo Lh .


The input arrays f and g can be 1D vectors or one of them can be a multidimensional array. In either
case, the convolution is performed along columns with row vectors transformed to columns.
100 CHAPTER 3. LTFAT - BASIC FOURIER AND DCT ANALYSIS.

3.3.7 LXCORR - Linear crosscorrelation


Usage
h=lxcorr(f,g)

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

with Lh = L f + Lg − 1 where L f and Lg are the lengths of f and g, respectively.


lxcorr(f,’normalize’) does the same, but normalizes the output by the product of the l 2 -norm
of f and g.

3.3.8 ISEVENFUNCTION - True if function is even


Usage
t=isevenfunction(f);
t=isevenfunction(f,tol);

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.

3.3.9 MIDDLEPAD - Symmetrically zero-extends or cuts a function


Usage
h=middlepad(f,L);
h=middlepad(f,L,dim);
h=middlepad(f,L,...);

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.

3.4 Periodic functions


3.4.1 EXPWAVE - Complex exponential wave
Usage
h=expwave(L,m);
h=expwave(L,m,cent);
3.4. PERIODIC FUNCTIONS 101

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.

3.4.2 PCHIRP - Periodic chirp


Usage

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));

The chirp is computed by:

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:

A spectrogram on a linear scale of an even length chirp:

sgram(pchirp(40,2),’lin’);

The DFT of the same chirp, now revolving around in time:

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]

3.4.3 PGAUSS - Sampled, periodized Gaussian


Usage
g=pgauss(L);
g=pgauss(L,tfr);
g=pgauss(L,...);
[g,tfr]=pgauss( ... );

Input parameters
L Length of vector.

tfr ratio between time and frequency support.

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.

’cf’,cf Set the centre frequency of the Gaussian to fc.

’wp’ Output is whole point even. This is the default.

’hp’ Output is half point even, as most Matlab filter routines.

’delay’,d Delay the output by d. Default is zero delay.

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);

% Test of DFT invariance: Should be close to zero.


norm(g-dft(g))

This code produces the following output:

ans =

2.481524897647706e-15

The next plot shows the Gaussian in the time domain:


104 CHAPTER 3. LTFAT - BASIC FOURIER AND DCT ANALYSIS.

plot(fftshift(pgauss(128)));

The next plot shows the Gaussian in the frequency domain on a log scale:

magresp(pgauss(128),’dynrange’,100);

The next plot shows the Gaussian in the time-frequency plane:

sgram(pgauss(128),’tc’,’nf’,’lin’);
3.4. PERIODIC FUNCTIONS 105

References: [62]

3.4.4 PSECH - Sampled, periodized hyperbolic secant


Usage

g=psech(L);
g=psech(L,tfr);
g=psech(L,s,’samples);
[g,tfr]=psech( ... );

Input parameters

L Length of vector.

tfr ratio between time and frequency support.

Output parameters

g The periodized hyperbolic cosine.

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);

% Test of DFT invariance: Should be close to zero.


norm(g-dft(g))

This code produces the following output:

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

The next plot shows psech in the time-frequency plane:


sgram(psech(128),’tc’,’nf’,’lin’);

References: [48]

3.4.5 PBSPLINE - Periodized B-spline


Usage
g=pbspline(L,order,a,...);
[g,nlen]=pbspline(L,order,a,...);

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

pbspline(L,order,a) computes a (slightly modified) B-spline of order order of total length L.


If shifted by the distance a, the
preturned function will form a partition of unity. The result is normalized
such that the functions sum to 1/ (a).
pbspline takes the following flags at the end of the input arguments:

’ed’ Even discrete fractional spline. This is the default

’xd’ ’flat’ discrete fractional spline.

’stard”pointy discrete fractional spline

’ec”’ Even fractional spline by sampling.

’xc’ ’flat’ fractional spline by sampling.

’starc”pointy fractional spline by sampling.

’wp”’ Generate whole point centered splines. This is the default.

’hp’ Generate half point centered splines.

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]

3.4.6 SHAH - Discrete Shah-distribution


Usage

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’)

3.4.7 PHEAVISIDE - Periodic Heaviside function


Usage
h=pheaviside(L);

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)));

3.4.8 PRECT - Periodic rectangle


Usage
f=prect(L,n);

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]);

3.4.9 PSINC - Periodic Sinc function (Dirichlet function)


Usage
f=psinc(L,n);

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));

3.5 Hermite functions and fractional Fourier transforms


3.5.1 PHERM - Periodized Hermite function
Usage
g=pherm(L,order);
g=pherm(L,order,tfr);
[g,D]=pherm(...);

Input parameters
L Length of vector.

order Order of Hermite function.

tfr ratio between time and frequency support.

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.

’noorth’ No orthonormalization of the Hermite functions. This is the default.

’polar’ Orthonormalization of the Hermite functions using the polar decom-


position orthonormalization method.

’qr’ Orthonormalization of the Hermite functions using the Gram-Schmidt


orthonormalization method (usign qr).

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

3.5.2 HERMBASIS - Orthonormal basis of discrete Hermite functions


Usage

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’);

References: [70, 19]


114 CHAPTER 3. LTFAT - BASIC FOURIER AND DCT ANALYSIS.

3.5.3 DFRACFT - Discrete Fractional Fourier transform


Usage
V=dfracft(f,a,p);
V=dfracft(f,a);

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]

3.5.4 FFRACFT - Approximate fast fractional Fourier transform


Usage
frf=ffracft(f,a)
frf=ffracft(f,a,dim)

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]

3.6 Approximation of continuous functions


3.6.1 FFTRESAMPLE - Resample signal using Fourier interpolation
Usage

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.

3.6.2 DCTRESAMPLE - Resample signal using Fourier interpolation


Usage

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.

3.6.3 PDERIV - Derivative of smooth periodic function


Usage

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.

3.6.4 FFTANALYTIC - Compute analytic representation


Usage
z = fftanalytic(f);
z = fftanalytic(f,L);
z = fftanalytic(f,L,dim);

Input parameters
f Input data.

L Extend or truncate f to this length.

dim Dimension to along which to apply the computations.

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));

The instantaneous phase of the function f can be computed as:

angle(fftanalytic(f));

3.7 Cosine and Sine transforms.


3.7.1 DCTI - Discrete Cosine Transform type I
Usage
c=dcti(f);
c=dcti(f,L);
c=dcti(f,[],dim);
c=dcti(f,L,dim);

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:

% The dcti is its own adjoint.


F=dcti(eye(20));

for ii=1:4
subplot(4,1,ii);
stem(F(:,ii));
end;

References: [79], [97]

3.7.2 DCTII - Discrete Consine Transform type II


Usage
c=dctii(f);
c=dctii(f,L);
c=dctii(f,[],dim);
c=dctii(f,L,dim);

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.

dctii(f,L) zero-pads or truncates f to length L before doing the transformation.


dctii(f,[],dim) or dctii(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 dctiii.
Let f be a signal of length L, let c=dctii(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 (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:

% The dctiii is the adjoint of dctii.


F=dctiii(eye(20));

for ii=1:4
subplot(4,1,ii);
stem(F(:,ii));
end;

References: [79], [97]

3.7.3 DCTIII - Discrete Consine Transform type III


Usage

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:

% The dctii is the adjoint of dctiii.


F=dctii(eye(20));

for ii=1:4
subplot(4,1,ii);
stem(F(:,ii));
end;

References: [79], [97]

3.7.4 DCTIV - Discrete Consine Transform type IV


Usage

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:

% The dctiv is its own adjoint.


F=dctiv(eye(20));

for ii=1:4
subplot(4,1,ii);
stem(F(:,ii));
end;

References: [79], [97]

3.7.5 DSTI - Discrete Sine Transform type I


Usage
c=dsti(f);
c=dsti(f,L);
c=dsti(f,[],dim);
c=dsti(f,L,dim);

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

The transform is real (output is real if input is real) and orthonormal.


This transform is its own inverse.
Let f be a signal of length L and let c=dsti(f). Then
r
2 L−1
 
π (n + 1) (m + 1)
c (n + 1) = ∑ f (m + 1) sin
L + 1 m=0 L+1
The implementation of this functions uses a simple algorithm that requires an FFT of length 2N + 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 DST transforms.

Examples:
The following figures show the first 4 basis functions of the DSTI of length 20:

% The dsti is its own adjoint.


F=dsti(eye(20));

for ii=1:4
subplot(4,1,ii);
stem(F(:,ii));
end;

References: [79], [97]

3.7.6 DSTII - Discrete Sine Transform type II


Usage
c=dstii(f);
c=dstii(f,L);
c=dstii(f,[],dim);
c=dstii(f,L,dim);

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.

The inverse transform of dstii is dstiii.


Let f be a signal of length L, let c=dstii(f) and define the vector w of length L by
 1
 √2 if n = L − 1

w (n) =

1 otherwise

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;

References: [79], [97]

3.7.7 DSTIII - Discrete sine transform type III


Usage
c=dstiii(f);
c=dstiii(f,L);
c=dstiii(f,[],dim);
c=dstiii(f,L,dim);

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

The transform is real (output is real if input is real) and orthonormal.


This is the inverse of dstii.
Let f be a signal of length L, let c=dstiii(f) and define the vector w of length L by
 1
 √2 if n = L − 1

w (n) =

1 otherwise

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;

References: [79], [97]

3.7.8 DSTIV - Discrete Sine Transform type IV


Usage
c=dstiv(f);
c=dstiv(f,L);
c=dstiv(f,[],dim);
c=dstiv(f,L,dim);

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.

dstiv(f,L) zero-pads or truncates f to length L before doing the transformation.


dstiv(f,[],dim) applies the transformation along dimension dim. dstiv(f,L,dim) does the
same, but pads or truncates to length L.
The transform is real (output is real if input is real) and it is orthonormal. It is its own inverse.
Let f be a signal of length L and let c=dstiv(f). Then
r
2 L−1
   
π 1 1
c (n + 1) = ∑ f (m + 1) sin L n + 2 m + 2
L m=0

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;

References: [79], [97]


Chapter 4

LTFAT - Wavelets

4.1 Basic analysis/synthesis

4.1.1 FWT - Fast Wavelet Transform

Usage

c = fwt(f,w,J);
c = fwt(f,w,J,dim);
[c,info] = fwt(...);

Input parameters

f Input data.

w Wavelet definition.

J Number of filterbank iterations.

dim Dimension to along which to apply the transform.

Output parameters

c Coefficient vector.

info Transform parameters struct.

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:

’zero’ Zeros are considered outside of the signal (coefficient) support.

’even’ Even symmetric extension.

’odd’ Odd symmetric extension.

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]

4.1.2 IFWT - Inverse Fast Wavelet Transform


Usage

f = ifwt(c,info)
f = ifwt(c,w,J,Ls)
f = ifwt(c,w,J,Ls,dim)

Input parameters

c Wavelet coefficients.

info, w Transform parameters struct/Wavelet filters definition.

J Number of filterbank iterations.

Ls Length of the reconstructed signal.

dim Dimension to along which to apply the transform.

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)

This code produces the following output:

ans =

3.542640048596510e-14

References: [60]

4.1.3 FWT2 - Fast Wavelet Transform 2D


Usage
c = fwt2(f,w,J);
c = fwt2(f,w,J,...);

Input parameters
f Input data.

w Wavelet filter bank definition.

J Number of filter bank iterations.

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

The second example uses the tensor product layout:

c = fwt2(cameraman,’db8’,4,’tensor’);
imagesc(dynlimit(20*log10(abs(c)),70));
axis(’image’); colormap(gray);

References: [60]

4.1.4 IFWT2 - Inverse Fast Wavelet Transform


Usage
f = ifwt2(c,w,J)
f = ifwt2(c,w,J,Ls,...)

Input parameters
c Coefficients stored in a matrix.

w Wavelet filters definition.

J Number of filterbank iterations.

Ls Size of the reconstructed signal.


4.1. BASIC ANALYSIS/SYNTHESIS 131

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]

4.1.5 UFWT - Undecimated Fast Wavelet Transform


Usage

c = ufwt(f,w,J);
[c,info] = ufwt(...);

Input parameters

f Input data.

w Wavelet Filterbank.

J Number of filterbank iterations.

Output parameters

c Coefficients stored in L × J + 1 matrix.

info Transform paramaters struct.

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:

A simple example of calling the ufwt function:

[f,fs] = greasy;
J = 8;
[c,info] = ufwt(f,’db8’,J);
plotwavelets(c,info,fs,’dynrange’,90);

References: [46]

4.1.6 IUFWT - Inverse Undecimated Fast Wavelet Transform


Usage

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.

info, w Transform parameters struct/Wavelet filters definition.

J Number of filterbank iterations.

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)

This code produces the following output:

ans =

6.468488239052756e-14

References: [60]

4.1.7 FWTLENGTH - FWT length from signal


Usage
L=fwtlength(Ls,w,J);
134 CHAPTER 4. LTFAT - WAVELETS

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).

4.1.8 FWTCLENGTH - FWT subbands lengths from a signal length


Usage
Lc=fwtclength(Ls,w,J);
[Lc,L]=fwtclength(...);

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.

4.2 Advanced analysis/synthesis


4.2.1 WFBT - Wavelet FilterBank Tree
Usage
c=wfbt(f,wt);
c=wfbt(f,wt,ext);
[c,info]=wfbt(...);

Input parameters
f Input data.

wt Wavelet filterbank tree definition.

Output parameters
c Coefficients stored in a cell-array.

info Transform parameters struct.

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);

4.2.2 IWFBT - Inverse Wavelet Filterbank Tree


Usage
f=iwfbt(c,info);
f=iwfbt(c,wt,Ls);
136 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 = 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:

A simple example showing perfect reconstruction using idtwfb:

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)

This code produces the following output:

ans =

1.392090799573605e-13

4.2.3 UWFBT - Undecimated Wavelet FilterBank Tree


Usage

c=uwfbt(f,wt);
[c,info]=uwfbt(...);

Input parameters

f Input data.

wt Wavelet Filterbank tree

Output parameters

c Coefficients stored in L × M matrix.


4.2. ADVANCED ANALYSIS/SYNTHESIS 137

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

4.2.4 IUWFBT - Inverse Undecimated Wavelet Filterbank Tree


Usage
f = iuwfbt(c,info)
f = iuwfbt(c,wt)

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

4.2.5 WPFBT - Wavelet Packet FilterBank Tree


Usage
c=wpfbt(f,wt);
[c,info]=wpfbt(...);
4.2. ADVANCED ANALYSIS/SYNTHESIS 139

Input parameters

f Input data.

wt Wavelet Filterbank tree definition.

Output parameters

c Coefficients stored in a cell-array.

info Transform parameters struct.

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.

Scaling of intermediate outputs:

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.

’intscale’ Each intermediate output is scaled by 1/2.

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

4.2.6 IWPFBT - Inverse Wavelet Packet Filterbank Tree


Usage
f=iwpfbt(c,info);
f=iwpfbt(c,wt,Ls);

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.

Scaling of intermediate outputs:


The following flags control scaling of the intermediate coefficients. The intermediate coefficients are out-
puts of nodes which ale also inputs to nodes further in the tree.
’intsqrt’ Each intermediate output is scaled by 1/sqrt(2). If the filterbank in each node is
orthonormal, the overall undecimated transform is a tight frame. This is the default.
’intnoscale’ No scaling of intermediate results is used.
’intscale’ Each intermediate output is scaled by 1/2.
If ’intnoscale’ is used, ’intscale’ must have been used in wpfbt (and vice versa) in order to obtain a
perfect reconstruction.
4.2. ADVANCED ANALYSIS/SYNTHESIS 141

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

4.2.7 UWPFBT - Undecimated Wavelet Packet FilterBank Tree


Usage
c=uwpfbt(f,wt);
[c,info]=uwpfbt(...);

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 intermediate outputs:


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.
’intscale’ Each intermediate output is scaled by 1/2.
If ’intnoscale’ is used, ’intscale’ must be used in iuwpfbt (and vice versa) in order to obtain a perfect
reconstruction.
142 CHAPTER 4. LTFAT - WAVELETS

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);

4.2.8 IUWPFBT - Inverse Undecimated Wavelet Packet Filterbank Tree


Usage
f=iuwpfbt(c,info);
f=iuwpfbt(c,wt);

Input parameters
c Coefficients stored in L × M matrix.

info, wt Transform parameters struct/Wavelet tree definition.

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.

Scaling of intermediate outputs:


The following flags control scaling of the intermediate coefficients. The intermediate coefficients are out-
puts of nodes which ale also inputs to nodes further in the tree.

’intsqrt’ Each intermediate output is scaled by 1/sqrt(2). If the filterbank in each node is
orthonormal, the overall undecimated transform is a tight frame. This is the default.
’intnoscale’ No scaling of intermediate results is used.
’intscale’ Each intermediate output is scaled by 1/2.

If ’intnoscale’ is used, ’intscale’ must have been used in uwpfbt (and vice versa) in order to obtain a
perfect reconstruction.

Examples:
A simple example showing perfect reconstruction using the "full decomposition" wavelet tree:

f = greasy;
J = 7;
wtdef = {’db10’,J,’full’};
c = uwpfbt(f,wtdef);
fhat = iuwpfbt(c,wtdef);
% The following should give (almost) zero
norm(f-fhat)

This code produces the following output:

ans =

3.279270462493657e-14

4.2.9 WPBEST - Best Tree selection


Usage
c = wpbest(f,w,J,cost);
[c,info] = wpbest(...);
144 CHAPTER 4. LTFAT - WAVELETS

Input parameters
f Input data.

w Wavelet Filterbank.

J Maximum depth of the tree.

Output parameters
c Coefficients stored in a cell-array.

info Transform parameters struct.

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.

{’shannon’} A cost function derived from the Shannon entropy:

Esh (x) = − ∑ |x(k)|2 log |x(k)|2


k:x(k)̸=0

{’log’} A logarithm of energy:

Elog (x) = ∑ ln |x(k)|2


k:x(k)̸=0

{’lpnorm’,p} Concentration in l p norm:


!
p
El p (x) = ∑ |x(k)|
k

{’thre’,th} Number of coefficients above a threshold th.


4.2. ADVANCED ANALYSIS/SYNTHESIS 145

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.

{’wlpnorm’,p} The weak-l p norm cost function:

Ewl p (x) = max k1/p vk (x),

where 0 < p ≤ 2 and vk (x) denotes the k-th largest absolute value of x.

{’compn’,p,f} Compression number cost:

Ecn (x) = arg min |wk (x, p) − f | ,


k

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.

{’compa’,p} Compression area cost:

Eca (x) = N − ∑ wk (x, p),


k

where 0 < p ≤ 2 and wk (u, p) and N as in the previous case.

Examples:

A simple example of calling wpbest

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

References: [96], [91]

4.2.10 WFBTLENGTH - WFBT length from signal


Usage

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).

4.2.11 WFBTCLENGTH - WFBT subband lengths from a signal length


Usage

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.

4.2.12 WPFBTCLENGTH - WPFBT subband length from a signal length


Usage

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.

4.3 Dual-tree complex wavelet transform


4.3.1 DTWFB - Dual-Tree Wavelet Filter Bank
Usage
c=dtwfb(f,dualwt);
c=dtwfb(f,{dualw,J});
[c,info]=dtwfb(...);

Input parameters
f Input data.

dualwt Dual-tree Wavelet Filter bank definition.

Output parameters
c Coefficients stored in a cell-array.

info Additional transform parameters struct.

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}.

dualw Basic dual-tree filters


J Number of levels of the filter bank tree

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.:

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 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

References: [50], [86], [12]

4.3.2 IDTWFB - Inverse Dual-tree Filterbank


Usage

f=idtwfb(c,info);
f=idtwfb(c,dualwt,Ls);

Input parameters

c Input coefficients.

info Transform params. struct

dualwt Dual-tree Wavelet Filterbank definition

Ls Length of the reconstructed signal.

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)

This code produces the following output:

ans =

9.605850455567395e-14

4.3.3 DTWFBREAL - Dual-Tree Wavelet FilterBank for real-valued signals


Usage
c=dtwfbreal(f,dualwt);
c=dtwfbreal(f,{dualw,J});
[c,info]=dtwfbreal(...);

Input parameters
f Input data.

dualwt Dual-tree Wavelet Filterbank definition.

Output parameters
c Coefficients stored in a cell-array.

info Additional transform parameters struct.

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}.

dualw Basic dual-tree filters


J Number of levels of the filterbank tree

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

References: [50], [86], [12]

4.3.4 IDTWFBREAL - Inverse Dual-tree Filterbank for real-valued signals


Usage

f=idtwfbreal(c,info);
f=idtwfbreal(c,dualwt,Ls);

Input parameters

c Input coefficients.

info Transform params. struct

dualwt Dual-tree Wavelet Filterbank definition

Ls Length of the reconstructed signal.

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

4.4 Wavelet Filterbank trees manipulation


4.4.1 WFBTINIT - Initialize Filterbank Tree
Usage
wt = wfbtinit(wtdef);

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

.children Indexes of children nodes


.parents Indexes of a parent node
.forder Frequency ordering of the resultant frequency bands.
The structure together with functions from the wfbtmanip subdirectory acts as an abstract data struc-
ture tree.
Regular wfbtinit flags:
’freq’,’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).

4.4.2 DTWFBINIT - Dual-Tree Wavelet Filterbank Initialization


Usage
dualwt=dtwfbinit(dualwtdef);

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_’).

Additional optional flags


’freq’,‘’nat’‘ Frequency or natural ordering of the resulting coefficient subbands. Default ordering is
’freq’.

4.4.3 WFBTPUT - Put node to the filterbank tree


Usage
wt = wfbtput(d,k,w,wt);
wt = wfbtput(d,k,w,wt,’force’);
4.4. WAVELET FILTERBANK TREES MANIPULATION 157

Input parameters

d Level in the tree (0 - root).

k Index (array of indexes) of the node at level d (starting at 0).

w Node, basic wavelet filterbank.

wt Wavelet filterbank tree structure (as returned from wfbtinit).

Output parameters

wt Modified filterbank structure.

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:

% Initialize empty struct


wt = wfbtinit();
% Put root node to the empty struct
wt1 = wfbtput(0,0,’db8’,wt);
% Connect a different nodes to both outputs of the root
wt2 = wfbtput(1,[0,1],’db10’,wt1);
% Connect another nodes just to high-pass outputs of nodes just added
wt3 = wfbtput(2,[1,3],’db10’,wt2);
% Add another node at level 3
wt4 = wfbtput(3,1,’db16’,wt3);

% Create identical filterbanks


[g1,a1] = wfbt2filterbank(wt1,’freq’);
[g2,a2] = wfbt2filterbank(wt2,’freq’);
[g3,a3] = wfbt2filterbank(wt3,’freq’);
[g4,a4] = wfbt2filterbank(wt4,’freq’);

% Plot frequency responses of the growing tree. Linear scale


% (both axis) is used and positive frequencies only are shown.
subplot(4,1,1);
filterbankfreqz(g1,a1,1024,’plot’,’linabs’,’posfreq’);
subplot(4,1,2);
filterbankfreqz(g2,a2,1024,’plot’,’linabs’,’posfreq’);
subplot(4,1,3);
filterbankfreqz(g3,a3,1024,’plot’,’linabs’,’posfreq’);
subplot(4,1,4);
filterbankfreqz(g4,a4,1024,’plot’,’linabs’,’posfreq’);
158 CHAPTER 4. LTFAT - WAVELETS

4.4.4 WFBTREMOVE - Remove node(s) from the filterbank tree


Usage
wt = wbftremove(d,kk,wt);
wt = wfbtremove(d,kk,wt,’force’);

Input parameters
d Level in the tree (0 - root).

kk Index of the node at level d (starting at 0) or array of indexes.

wt Wavelet filterbank tree structure (as returned from wfbtinit).

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.:

% Create a full filterbank tree usinf ’db10’ basic filterbank.


wt1 = wfbtinit({’db10’,4,’full’});
% Remove a subtree starting by root’s high-pass filter. Force flag
% is used because we are removing a non-leaf node.
wt2 = wfbtremove(1,1,wt1,’force’);

% Create identical filterbanks


[g1,a1] = wfbt2filterbank(wt1,’freq’);
[g2,a2] = wfbt2filterbank(wt2,’freq’);

% Plot the frequency responses


4.4. WAVELET FILTERBANK TREES MANIPULATION 159

subplot(2,1,1);
filterbankfreqz(g1,a1,1024,’plot’,’posfreq’,’linabs’);
subplot(2,1,2);
filterbankfreqz(g2,a2,1024,’plot’,’posfreq’,’linabs’);

4.4.5 WFBT2FILTERBANK - WFBT equivalent non-iterated filterbank


Usage

[g,a] = wfbt2filterbank(wt)

Input parameters

wt Wavelet filter tree definition

Output parameters

g Cell array containing filters

a Vector of sub-/upsampling factors

Description

[g,a]=wfbt2filterbank(wt) calculates the impulse responses g and the subsampling factors a of


non-iterated filterbank, which is equivalent to the wavelet filterbank tree described by wt used in wfbt. The
returned parameters can be used directly in filterbank and other routines.
[g,a]=wfbt2filterbank({w,J,’dwt’}) does the same for the DWT (fwt) filterbank tree.
Please see help on wfbt for description of wt and help on fwt for description of w and J.
The function additionally support the following flags:

’freq’‘(default),’nat’‘ The filters are ordered to produce subbands in the same order as wfbt with
the same flag.

’scaling_notset’‘(default),’noscale’,’scale’,’sqrt’‘ Support for scaling flags as described


in uwfbt. By default, the returned filterbank g and a is equivalent to wfbt, passing any of the non-
default flags results in a filterbank equivalent to uwfbt i.e. scaled and with a(:)=1.
160 CHAPTER 4. LTFAT - WAVELETS

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’);

4.4.6 WPFBT2FILTERBANK - WPFBT equivalent non-iterated filterbank


Usage
[g,a] = wpfbt2filterbank(wt)

Input parameters
wt Wavelet filter tree definition
4.4. WAVELET FILTERBANK TREES MANIPULATION 161

Output parameters

g Cell array containing filters

a Vector of sub-/upsampling factors

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.

’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 returned filterbank g and a is equivalent to wpfbt, passing any of the
non-default flags results in a filterbank equivalent to uwpfbt i.e. scaled and with a(:)=1.

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

4.4.7 DTWFB2FILTERBANK - DTWFB equivalent non-iterated filterbank


Usage

[g,a] = dtwfb2filterbank(dualwt)
[g,a,info] = dtwfb2filterbank(...)

Input parameters

dualwt Dual-tree wavelet filterbank specification.

Output parameters

g Cell array of filters.

a Downsampling rate for each channel.

info Additional information.

Description

[g,a] = dtwfb2filterbank(dualwt) constructs a set of filters g and subsampling factors a of


a non-iterated filterbank, which is equivalent to the dual-tree wavelet filterbank defined by dualwt. The
returned parameters can be used directly in filterbank and other routines. The format of dualwt is the same
as in dtwfb and dtwfbreal.
The function internally calls dtwfbinit and passes dualwt and all additional parameters to it.
[g,a,info] = dtwfb2filterbank(...) additionally outputs a info struct containing equiv-
alent filterbanks of individual real-valued trees as fields info.g1 and info.g2.

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’);

4.4.8 FWTINIT - Wavelet Filterbank Structure Initialization


Usage
w = fwtinit(wdef);
w = fwtinit(wdef,prefix);
[w,info]=fwtinit(...)

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]

4.5 Frame properties of wavelet filter banks:


4.5.1 WFBTBOUNDS - Frame bounds of WFBT
Usage
fcond=wfbtbounds(wt,L);
[A,B]=wfbtbounds(wt,L);
[...]=wfbtbounds(wt);

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.

4.5.2 WPFBTBOUNDS - Frame bounds of WPFBT


Usage
fcond=wpfbtbounds(wt,L);
[A,B]=wpfbtbounds(wt,L);
[...]=wpfbtbounds(wt);

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

4.5.3 DTWFBBOUNDS - Frame bounds of DTWFB


Usage
fcond=dtwfbbounds(dualwt,L);
[A,B]=dtwfbbounds(dualwt,L);
[...]=dtwfbbounds(dualwt);

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.

4.6.2 WFILTINFO - Plots filters info


Usage
wfiltinfo(w);

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:

’db’,’lin’ dB or linear scale respectivelly. By deault a dB scale is used.


4.6. PLOTS 167

Examples:
Details of the ’syn:spline8:8’ wavelet filters (see wfilt_spline):
wfiltinfo(’syn:spline8:8’);

Details of the ’ana:spline8:8’ wavelet filters:


wfiltinfo(’ana:spline8:8’);

4.6.3 WFILTDTINFO - Plots dual-tree filters info


Usage
wfiltdtinfo(dw);

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

The figure is organized as follows:


First row shows impulse responses of the first (real) tree.
Second row shows impulse responses of the second (imag) tree.
Third row contains plots of real (green), imaginary (red) and absolute (blue) parts of approximation of
scaling and wavelet function(s).
Fourth and fifth row show magnitude and phase frequency responses respectivelly of filters from rows
1 and 2 with matching colors.
Optionally it is possible to define scaling of the y axis of the frequency seponses. Supported are:

’db’,’lin’ dB or linear scale respectivelly. By deault a dB scale is used.

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

wfunc Approximation of wavelet function(s)

sfunc Approximation of the scaling function

xvals Correct x-axis values


4.7. AUXILARY 169

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.

WARNING: The output array lengths L depend on N exponentially like:

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’);

4.7.2 WAVCELL2PACK - Changes wavelet coefficients storing format


Usage

[cvec,Lc] = wavcell2pack(ccell);
[cvec,Lc] = wavcell2pack(ccell,dim);

Input parameters

ccell Coefficients stored in a collumn cell-array.

dim Dimension along which the data were transformed.


170 CHAPTER 4. LTFAT - WAVELETS

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.

4.7.3 WAVPACK2CELL - Changes wavelet coefficients storing format


Usage
ccell = wavpack2cell(cvec,Lc);
ccell = wavpack2cell(cvec,Lc,dim);

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)).’;

4.8 Wavelet Filters defined in the time-domain


4.8.1 WFILT_ALGMBAND - An ALGebraic construction of orthonormal M-BAND
wavelets with perfect reconstruction
Usage
[h,g,a] = wfilt_algmband(K);
4.8. WAVELET FILTERS DEFINED IN THE TIME-DOMAIN 171

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]

4.8.2 WFILT_CMBAND - Generates M-Band cosine modulated wavelet filters


Usage
[h,g,a] = wfilt_cmband(M);

Input parameters
M Number of channels.
172 CHAPTER 4. LTFAT - WAVELETS

Description

[h,g,a]=wfilt_cmband(M) with M ∈ 2, 3, . . . returns smooth, 1-regular cosine modulated M-band


wavelet filters according to the reference paper. The length of the filters is 4M.

Examples:

wfiltinfo(’cmband3’);

wfiltinfo(’cmband4’);

wfiltinfo(’cmband5’);
4.8. WAVELET FILTERS DEFINED IN THE TIME-DOMAIN 173

References: [38]

4.8.3 WFILT_COIF - Coiflets


Usage

[h,g,a] = wfilt_coif(K);

Description

[h,g,a]=wfilt_coif(K) with K ∈ 1, 2, 3, 4, 5 returns a Coiflet filters of order 2K the number of


vanishing moments of both the scaling and the wavelet functions.
Values are taken from table 8.1 from the reference. REMARK: There is a typo in 2nd element for
K == 1.

Examples:

wfiltinfo(’coif2’);

wfiltinfo(’coif5’);
174 CHAPTER 4. LTFAT - WAVELETS

References: [24]

4.8.4 WFILT_DB - Daubechies FIR filterbank


Usage
[h,g] = wfilt_db(N);

Input parameters
N Order of Daubechies filters.

Output parameters
H cell array of analysing filters impulse reponses

G cell array of synthetizing filters impulse reponses

a array of subsampling (or hop) factors accociated with corresponding


filters

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 )

Gh (z) = −Hl (−z)


making them an orthogonal perfect-reconstruction QMF.
4.8. WAVELET FILTERS DEFINED IN THE TIME-DOMAIN 175

Examples:
wfiltinfo(’db8’);

References: [24]

4.8.5 WFILT_DDEN - Double-DENsity DWT filters (tight frame)


Usage
[h,g,a] = wfilt_dden(N);

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

4.8.6 WFILT_DGRID - Dense GRID framelets (tight frame, symmetric)

Usage

[h,g,a] = wfilt_dgrid(N);

Description

[h,g,a]=wfilt_dgrid(N) computes Dense GRID framelets. Redundancy equal to 2.

Examples:

wfiltinfo(’dgrid3’);

References: [1]

4.8.7 WFILT_HDEN - Higher DENsity dwt filters (tight frame, frame)

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]

4.8.8 WFILT_LEMARIE - Battle and Lemarie filters


Usage

[h,g,a]=wfilt_lemarie(N)

Input parameters

N Filter length, must be even.

Description

[h,g,a]=wfilt_lemarie(N) calculates N (even) truncated coeficients of orthonormal Battle-Lemarie


wavelets. Filter coefficients are obtained by frequency domain sampling and trunctating the impulse re-
sponse. Due to the truncation, the filterbank might not achieve a perfect reconstruction. The filetrs are
included nevertheless since they were the original ones used in the first MRA paper.
178 CHAPTER 4. LTFAT - WAVELETS

Examples:

wfiltinfo(’lemarie50’);

References: [63]

4.8.9 WFILT_MATLABWRAPPER - Wrapper of the Matlab Wavelet Toolbox wfil-


ters function
Usage

[h,g,a] = wfilt_matlabwrapper(wname);

Description

[h,g,a]=wfilt_matlabwrapper(wname) calls Matlab Wavelet Toolbox function wfilters and


passes the parameter wname to it.
This function requires the Matlab Wavelet Toolbox.

4.8.10 WFILT_MBAND - Generates 4-band coder


Usage

[h,g,a] = wfilt_mband(N);

Description

[h,g,a]=wfilt_mband(1) returns linear-phase 4-band filters from the reference.


The filters are not actually proper wavelet filters, because the scaling filter is not regular, therefore it is
not stable under iterations (does not converge to a scaling function).

Examples:

wfiltinfo(’mband1’);
4.8. WAVELET FILTERS DEFINED IN THE TIME-DOMAIN 179

References: [7]

4.8.11 WFILT_REMEZ - Filters designed using Remez exchange algorithm

Usage

[h,g,a]=wfilt_remez(L,K,B)

Input parameters

L Length of the filters.

K Degree of flatness (regularity) at z = −1.

B Normalized transition bandwidth.

Description

[h,g,a]=wfilt_remez(L,K,B) calculates a set of wavelet filters. Regularity, frequency selectivity,


and length of the filters can be controlled by K, B and L parameters respectivelly.
The filter desigh algorithm is based on a Remez algorithm and a factorization of the complex cepstrum
of the polynomial.

Examples:

wfiltinfo(’remez50:2:0.1’);
180 CHAPTER 4. LTFAT - WAVELETS

References: [80]

4.8.12 WFILT_SYMDS - Symmetric wavelets dyadic sibling


Usage

[h,g,a] = wfilt_symds(K);

Description

[h,g,a]=wfilt_symds(K) with K ∈ 1, 2, 3, 4, 5 returns symmetric dyadic sibling wavelet frame filters


from the reference.
The returned filterbank has redundancy equal to 2 and it does not form a tight frame.

Examples:

wfiltinfo(’ana:symds3’);

wfiltinfo(’syn:symds3’);
4.8. WAVELET FILTERS DEFINED IN THE TIME-DOMAIN 181

References: [3]

4.8.13 WFILT_SPLINE - Biorthogonal spline wavelets


Usage
[h,g,a]=wfilt_spline(m,n);

Input parameters
m Number of zeros at z = −1 of the lowpass filter in g{1}

n Number of zeros at z = −1 of the lowpass filter in h{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

4.8.14 WFILT_SYM - Symlet filters


Usage

[h,g,a]=wfilt_sym(N);

Description

[h,g,a]=wfilt_sym(N) generates the "least asymmetric" Daubechies’ orthogonal wavelets or "sym-


lets" with N vanishing moments and length 2N. Zeros of the trigonometrical polynomial the filters consist
of in the Z-plane are selected alternatingly inside and outside the unit circle.
Remark: Filters generated by this routine differ slightly from the ones in the reference (table 6.3, figure.
6.4) because of the ambiguity in the algorithm.

Examples:

wfiltinfo(’sym8’);

References: [24]
4.8. WAVELET FILTERS DEFINED IN THE TIME-DOMAIN 183

4.8.15 WFILT_SYMDDEN - Symmetric Double-Density DWT filters (tight frame)


Usage

[h,g,a] = wfilt_symdden(K);

Description

[h,g,a]=wfilt_symdden(K) with K ∈ 1, 2 returns oversampled symmetric double-density DWT fil-


ters. The redundancy of the basic filterbank is equal to 1.5.

Examples:

wfiltinfo(’symdden1’);

wfiltinfo(’symdden2’);

References: [85]
184 CHAPTER 4. LTFAT - WAVELETS

4.8.16 WFILT_SYMORTH - Symmetric nearly-orthogonal and orthogonal nearly-


symmetric
Usage

[h,g,a] = wfilt_symorth(N);

Description

[h,g,a]=wfilt_symorth(N) with N ∈ 1, 2, 3 returns orthogonal near-symmetric (N == 1) and sym-


metric near-orthogonal (N == [2, 3]) wavelet filters from the reference.
The filters exhibit a coiflet-like behavior i.e. the scaling filter has vanishing moments too.

Examples:

wfiltinfo(’ana:symorth2’);

wfiltinfo(’syn:symorth2’);

References: [4]
4.8. WAVELET FILTERS DEFINED IN THE TIME-DOMAIN 185

4.8.17 WFILT_SYMTIGHT - Symmetric Nearly Shift-Invariant Tight Frame Wavelets


Usage
[h,g,a] = wfilt_symtight(K);

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]

4.8.18 WFILT_QSHIFTA - Improved Orthogonality and Symmetry properties


Usage
[h,g,a] = wfilt_qshifta(N);
186 CHAPTER 4. LTFAT - WAVELETS

Description

[h,g,a]=wfilt_qshift(N) with N ∈ 1, 2, 3, 4, 5, 6, 7 returns Kingsbury’s Q-shift wavelet filters for


tree A.

Examples:

figure(1);
wfiltinfo(’qshifta3’);

References: [52], [51]

4.8.19 WFILT_QSHIFTB - Improved Orthogonality and Symmetry properties

Usage

[h,g,a] = wfilt_qshiftb(N);

Description

[h,g,a]=wfilt_qshiftb(N) with N ∈ 1, 2, 3, 4, 5, 6, 7 returns Kingsbury’s Q-shift wavelet filters for


tree B.

Examples:

figure(1);
wfiltinfo(’qshiftb3’);
4.8. WAVELET FILTERS DEFINED IN THE TIME-DOMAIN 187

References: [52], [51]

4.8.20 WFILT_ODDEVENA - Kingsbury’s symmetric even filters


Usage

[h,g,a] = wfilt_oddevena(N);

Description

[h,g,a]=wfilt_oddevena(N) with N ∈ 1 returns Kingsbury’s even filters.

Examples:

figure(1);
wfiltinfo(’ana:oddevena1’);

figure(2);
wfiltinfo(’syn:oddevena1’);
188 CHAPTER 4. LTFAT - WAVELETS

References: [50]

4.8.21 WFILT_ODDEVENB - Kingsbury’s symmetric odd filters


Usage

[h,g,a] = wfilt_oddevenb(N);

Description

[h,g,a]=wfilt_oddevenb(N) with N ∈ 1 returns Kingsbury’s odd filters.

Examples:

figure(1);
wfiltinfo(’ana:oddevenb1’);

figure(2);
wfiltinfo(’syn:oddevenb1’);
4.8. WAVELET FILTERS DEFINED IN THE TIME-DOMAIN 189

References: [50]

4.8.22 WFILT_OPTSYMA - Optimizatized Symmetric Self-Hilbertian Filters


Usage
[h,g,a] = wfilt_optsyma(N);

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]

4.8.23 WFILT_OPTSYMB - Optimizatized Symmetric Self-Hilbertian Filters


Usage
[h,g,a] = wfilt_optsymb(N);
190 CHAPTER 4. LTFAT - WAVELETS

Description

[h,g,a]=wfiltdt_optsymb(N) with N ∈ 1, 2, 3 returns filters suitable with optimized symmetry


suitable for for dual-tree complex wavelet transform tree B.

Examples:

wfiltinfo(’optsymb3’);

References: [29]

4.8.24 WFILT_DDENA - Double-Density Dual-Tree DWT filters

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]

4.8.25 WFILT_DDENB - Double-Density Dual-Tree DWT filters


Usage

[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

4.9 Dual-Tree Filters


4.9.1 WFILTDT_QSHIFT - Improved Orthogonality and Symmetry properties
Usage

[h,g,a] = wfiltdt_qshift(N);

Description

[h,g,a]=wfiltdt_qshift(N) with N ∈ 1, 2, 3, 4, 5, 6, 7 returns Kingsbury’s Q-shift filters suitable


for dual-tree complex wavelet transform. Filters in both trees are orthogonal and based on a single prototype
low-pass filter with a quarter sample delay. Other filters are derived by modulation and time reversal such
that they fulfil the half-sample delay difference between the trees.

Examples:

wfiltdtinfo(’qshift3’);

References: [52], [51]

4.9.2 WFILTDT_OPTSYM - Optimizatized Symmetric Self-Hilbertian Filters


Usage

[h,g,a] = wfiltdt_optsym(N);

Description

[h,g,a]=wfiltdt_optsym(N) with N ∈ 1, 2, 3 returns filters suitable for dual-tree complex wavelet


transform with optimized symmetry.

Examples:

wfiltdtinfo(’optsym3’);
4.9. DUAL-TREE FILTERS 193

References: [29]

4.9.3 WFILTDT_ODDEVEN - Kingsbury’s symmetric odd and even filters


Usage
[h,g,a] = wfiltdt_oddeven(N);

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]

4.9.4 WFILTDT_DDEN - Double-Density Dual-Tree DWT filters


Usage
[h,g,a] = wfiltdt_dden(N);
194 CHAPTER 4. LTFAT - WAVELETS

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

5.1 Transforms and basic routines


5.1.1 FILTERBANK - Apply filterbank
Usage
c=filterbank(f,g,a);

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

where an − l is computed modulo L.


References: [17]

5.1.2 UFILTERBANK - Apply Uniform filterbank


Usage
c=ufilterbank(f,g,a);

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

5.1.3 IFILTERBANK - Filter bank inversion


Usage
f=ifilterbank(c,g,a);

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:

info.M Number of windows (equal to the number of channels)


info.longestfilter Length of the longest filter
info.gauss True if the windows are Gaussian.
info.tfr Time/frequency support ratios of the window. Set whenever it makes sense.
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 windows.
info.isfac True if the frame generated by the window has a fast factorization.
5.2. AUDITORY INSPIRED FILTER BANKS 197

5.1.5 FILTERBANKLENGTH - Filterbank length from signal


Usage

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.

5.1.6 FILTERBANKLENGTHCOEF - Filterbank length from coefficients


Usage

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.

5.2 Auditory inspired filter banks


5.2.1 CQT - Constant-Q non-stationary Gabor filterbank
Usage

[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

f The signal to be analyzed (For multichannel signals, input should be a


matrix which each column storing a channel of the signal).

fmin Minimum frequency (in Hz)

fmax Maximum frequency (in Hz)

bins Vector consisting of the number of bins per octave

fs Sampling rate (in Hz)

M Number of time channels (optional) If M is constant, the output is


converted to a matrix
198 CHAPTER 5. LTFAT - FILTERBANKS

Output parameters

c Transform coefficients (matrix or cell array)

Ls Original signal length (in samples)

g Cell array of Fourier transforms of the analysis windows

shift Vector of frequency shifts

M Number of time channels

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)

The arguments must be character strings followed by an argument:

’min_win’,min_win Minimum admissible window length (in samples)

’Qvar’,Qvar Bandwidth variation factor

’M_fac’,M_fac Number of time channels are rounded to multiples of this

’winfun’,winfun Filter prototype (see firwin for available filters)

’fractional’ Allow fractional shifts and bandwidths

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

References: [93], [43]

5.2.2 ICQT - Constant-Q non-stationary Gabor synthesis


Usage
fr = icqt(c,g,shift,Ls,dual)
fr = icqt(c,g,shift,Ls)
fr = icqt(c,g,shift)

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]

5.2.3 ERBLETT - ERBlet non-stationary Gabor filterbank


Usage
[c,Ls,g,shift,M] = erblett(f,bins,fs,varargin)
[c,Ls,g,shift] = erblett(...)
[c,Ls] = erblett(...)
c = erblett(...)
200 CHAPTER 5. LTFAT - FILTERBANKS

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)

bins Desired bins per ERB

fs Sampling rate of f (in Hz)

varargin Optional input pairs (see table below)

Output parameters
c Transform coefficients (matrix or cell array)

Ls Original signal length (in samples)

g Cell array of Fourier transforms of the analysis windows

shift Vector of frequency shifts

M Number of time channels

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)

The arguments must be character strings followed by an argument:

’Qvar’,Qvar Bandwidth variation factor

’M_fac’,M_fac Number of time channels are rounded to multiples of this

’winfun’,winfun Filter prototype (see firwin for available filters)

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);

This code produces the following output:

rel_err =

5.133913799759292e-16
5.3. FILTER GENERATORS 201

References: [66]

5.2.4 IERBLETT - ERBlet non-stationary Gabor synthesis


Usage
fr = ierblett(c,g,shift,Ls,dual)
fr = ierblett(c,g,shift,Ls)
fr = ierblett(c,g,shift)

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]

5.3 Filter generators


5.3.1 CQTFILTERS - CQT-spaced filters
Usage
[g,a,fc]=cqtfilters(fs,fmin,fmax,bins,Ls,varargin);
202 CHAPTER 5. LTFAT - FILTERBANKS

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

’min_win’,min_win Minimum admissible window length (in samples). Default is 4. This


restrict the windows not to become too narrow when L is low. This
however brakes the constant-Q property for such windows and creates
rippling in the overall frequency response.
’redmul’,redmul Redundancy multiplier. Increasing the value of this will make the sys-
tem more redundant by lowering the channel downsampling rates. De-
fault value is 1. If the value is less than one, the system may no longer
be painless.

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)

% Plot the response


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’);

% Plot frequency responses of individual filters


204 CHAPTER 5. LTFAT - FILTERBANKS

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’);

This code produces the following output:

ans =

8.299315044804507e-15

References: [93], [43], [81]

5.3.2 ERBFILTERS - ERB-spaced filters


Usage

[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

’min_win’,min_win Minimum admissible window length (in samples). Default is 4. This


restrict the windows not to become too narrow when L is low.

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)

% Plot the response


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’);

% Plot frequency responses of individual filters


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’);
5.3. FILTER GENERATORS 207

This code produces the following output:

ans =

8.470876921240907e-15

References: [66]

5.3.3 WARPEDFILTERS - Frequency-warped band-limited filters


Usage
[g,a,fc]=warpedfilters(freqtoscale,scaletofreq,fs,fmin,fmax,bins,Ls);

Input parameters
freqtoscale Function converting frequency (Hz) to scale units

scaletofreq Function converting scale units to frequency (Hz)

fs Sampling rate (in Hz).

fmin Minimum frequency (in Hz)

fmax Maximum frequency (in Hz)


208 CHAPTER 5. LTFAT - FILTERBANKS

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 (in Hz).

L Next admissible length suitable for the generated 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:

a) Although the freqtoscale and scaletofreq can be chosen freely, it is as-


sumed that freqtoscale is an invertible, increasing function from R or R+ onto
R and that freqtoscale is the inverse function.
b) If freqtoscale is from R+ onto R, then necessarily f reqtoscale(0) = −∞.
c) If the slope of freqtoscale is (locally) too steep, then there is the chance that
some filters are effectively 0 or have extremely low bandwidth (1-3 samples), and
consequently very poor localization in time. If freqtoscale is from R+ onto
R then this usually occurs close to the DC component and can be alleviated by
increasing fmin.
d) Since the input parameter bins is supposed to be integer, freqtoscale and
scaletofreq have to be scaled appropriately. Note that f reqtoscale( f s) is in
some sense proportional to the resulting number of frequency bands and inversely
proportional to the filter bandwidths. For example, the ERB scale defined by 21.4 log10 (1+
f /228.8) works nicely out of the box, while the similar mel scale 2595 log10 (1 +
f /700) most likely has to be rescaled in order not to provide a filter bank with 1000s
of channels.

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

[g,a]=warpedfilters(...,’uniform’) constructs a uniform filterbank where the the down-


sampling rate is the same for all the channels. This results in most redundant representation, which produces
nice plots.
[g,a]=warpedfilters(...,’fractional’) constructs a filterbank with fractional down-
sampling rates a. This results in the least redundant system.
[g,a]=warpedfilters(...,’fractionaluniform’) constructs a filterbank with fractional
downsampling 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 re-
dundancy at the same time are desirable.
The filters are intended to work with signals with a sampling rate of fs.
warpedfilters accepts the following optional parameters:

’bwmul’,bwmul Bandwidth variation factor. Multiplies the calculated bandwidth. Default


value is 1. If the value is less than one, the system may no longer be painless.
’complex’ Construct a filterbank that covers the entire frequency range. When missing, only
positive frequencies are covered.
’redmul’,redmul Redundancy multiplier. Increasing the value of this will make the system
more redundant by lowering the channel downsampling rates. Default value is 1. If the
value is less than one, the system may no longer be painless.

Examples:

In the first example, we use the ERB scale functions freqtoerb and erbtofreq to construct a filter
bank and visualize the result:

[s,fs] = gspi; % Get a test signal


Ls = numel(gspi);

% Fix some parameters


fmax = fs/2;
bins = 1;

% Compute filters, using fractional downsampling


[g,a,fc]=warpedfilters(@freqtoerb,@erbtofreq,fs,0,fmax,bins,...
Ls,’bwmul’,1.5,’real’,’fractional’);

% Plot the filter transfer functions


figure(1);
filterbankfreqz(g,a,Ls,’plot’,’linabs’,’posfreq’);
title(’ERBlet filter transfer functions’);

% Compute the frame bounds


gf=filterbankresponse(g,a,Ls,’real’); framebound_ratio = max(gf)/min(gf);
disp([’Painless system frame bound ratio of ERBlets: ’,...
num2str(framebound_ratio)]);

% Plot the filter bank coefficients of the test signal


figure(2);
c=filterbank(s,g,a);
plotfilterbank(c,a,fc,fs,60);
title(’ERBlet transform of the test signal’);

This code produces the following output:

Painless system frame bound ratio of ERBlets: 1


210 CHAPTER 5. LTFAT - FILTERBANKS

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);

% Fix some parameters


fmax = fs/2;
bins = 1;

% Define the frequency-to-scale and scale-to-frequency functions


warpfun_log = @(x) 10*log(x);
invfun_log = @(x) exp(x/10);

bins_hi = 4; % Select bins/unit parameter


fmin = 50; % The logarithm’s derivative 1/x tends to Inf for x towards 0

% Compute filters, using fractional downsampling


[g,a,fc]=warpedfilters(warpfun_log,invfun_log,fs,fmin,fmax,bins_hi,Ls,’bwmul’,1,’r

% Plot the filter transfer functions


figure(1);
filterbankfreqz(g,a,Ls,’plot’,’linabs’,’posfreq’);
5.3. FILTER GENERATORS 211

title(’constant-Q filter transfer functions (4 bins)’);

% Compute the frame bounds


gf=filterbankresponse(g,a,Ls,’real’); framebound_ratio = max(gf)/min(gf);
disp([’Painless system frame bound ratio (constant-Q - 4 bins): ’, num2str(framebo

% Plot the filter bank coefficients of the test signal


figure(2);
c=filterbank(s,g,a);
plotfilterbank(c,a,fc,fs,60);
title(’constant-Q transform of the test signal (4 bins)’);
This code produces the following output:
Painless system frame bound ratio (constant-Q - 4 bins): 1.0007

References: [45]

5.3.4 AUDFILTERS - generates AUD-spaced filters


Usage
[g,a,fc,L]=audfilters(fs,Ls);
[g,a,fc,L]=audfilters(fs,Ls,...);
212 CHAPTER 5. LTFAT - FILTERBANKS

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,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)

[g,a,fc,L]=audfilters(...,’regsampling’) constructs a non-uniform filterbank with


integer subsampling factors.
[g,a,fc,L]=audfilters(...,’uniform’) constructs a uniform filterbank where the integer
downsampling rate is the same for all the channels. This results in most redundant representation which
produces nice plots.
[g,a,fc,L]=audfilters(...,’fractional’) constructs a filterbank with fractional down-
sampling rates a. This results in the least redundant system.
[g,a,fc,L]=audfilters(...,’fractionaluniform’) constructs a filterbank with frac-
tional downsampling 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.
audfilters accepts the following optional parameters:

’spacing’,b Specify the spacing in Ecritical bandwidth (ERB or Bark depending


on the scale) between the filters. Default value is b=1.

’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.

’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.

’min_win’,min_win Minimum admissible window length (in samples). Default is 4. This


restrict the windows not to become too narrow when L is low.

Examples:
In the first example, we construct a highly redudant uniform filterbank on the ERB scale and visualize the
result:

[f,fs]=greasy; % Get the test signal


[g,a,fc,L]=audfilters(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,L]=audfilters(fs,L,’fractional’);
c=filterbank(f,{’realdual’,g},a);
r=2*real(ifilterbank(c,g,a));
norm(f-r)

% Plot the response


214 CHAPTER 5. LTFAT - FILTERBANKS

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’);

% Plot frequency responses of individual filters


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’);
This code produces the following output:
ans =

8.470876921240907e-15

References: [66]
5.4. WINDOW CONSTRUCTION AND BOUNDS 215

5.4 Window construction and bounds


5.4.1 FILTERBANKDUAL - Dual filters
Usage
gd=filterbankdual(g,a,L);
gd=filterbankdual(g,a);

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.

5.4.2 FILTERBANKTIGHT - Tight filterbank


Usage
gt=filterbanktight(g,a,L);
gt=filterbanktight(g,a);

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.

5.4.3 FILTERBANKREALDUAL - Dual filters of filterbank for real signals only


Usage
gd=filterbankrealdual(g,a,L);
gd=filterbankrealdual(g,a);

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.

5.4.4 FILTERBANKREALTIGHT - Tight filters of filterbank for real signals only


Usage
gt=filterbankrealtight(g,a,L);
gt=filterbankrealtight(g,a);

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.

5.4.5 FILTERBANKBOUNDS - Frame bounds of a filterbank


Usage
fcond=filterbankbounds(g,a,L);
[A,B]=filterbankbounds(g,a,L);
[...]=filterbankbounds(g,a);

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.

5.4.6 FILTERBANKREALBOUNDS - Frame bounds of filter bank for real signals


only
Usage
fcond=filterbankrealbounds(g,a,L);
[A,B]=filterbankrealbounds(g,a,L);
[...]=filterbankrealbounds(g,a);

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.

5.4.7 FILTERBANKRESPONSE - Response of filterbank as function of frequency


Usage
gf=filterbankresponse(g,a,L);

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:

’fs’,fs Sampling rate, used only for plotting.


’complex’ Assume that the filters cover the entire frequency range. This is the default.
’real’ Assume that the filters only cover the positive frequencies (and is intended to work with
real-valued signals only).
’noplot’ Don’t plot the response, just return it.
’plot’ Plot the response using plotfftreal or plotfft.

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’.

5.5.2 NONU2UFILTERBANK - Non-uniform to uniform filterbank transform


Usage
[gu,au]=nonu2ufilterbank(g,a)
218 CHAPTER 5. LTFAT - FILTERBANKS

Input parameters
g Filters as a cell array of structs.

a Subsampling factors.

Output parameters
gu Filters as a cell array of structs.

au Uniform subsampling factor.

pk Numbers of copies of each filter.

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]

5.5.3 U2NONUCFMT - Uniform to non-uniform filterbank coefficient format


Usage
c=u2nonucfmt(cu,pk)

Input parameters
cu Uniform filterbank coefficients.

Output parameters
c Non-uniform filterbank coefficients.

p Numbers of copies of each filter.

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]

5.5.4 NONU2UCFMT - Non-uniform to uniform filterbank coefficient format


Usage
cu=nonu2ucfmt(c,pk)

Input parameters
c Non-uniform filterbank coefficients.
5.6. PLOTS 219

Output parameters

cu Uniform filterbank coefficients.

p Numbers of copies of each filter.

Description

cu = nonu2ucfmt(c,p) changes the coefficient format from non-uniform filterbank coefficients c


(M=numel(p) channels) to uniform coefficients c (sum(p) channels) such that each channel of cu con-
sinst of de-interleaved samples of channels of c.
The output cu is a cell-array in any case.
References: [6]

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

5.7 Reassignment and phase gradient


5.7.1 FILTERBANKPHASEGRAD - Phase gradient of a filterbank representation
Usage
[tgrad,fgrad,s,c] = filterbankphasegrad(f,g,a,L,minlvl);
[tgrad,fgrad,s,c] = filterbankphasegrad(f,g,a,L);
[tgrad,fgrad,s,c] = filterbankphasegrad(f,g,a,minlvl);
[tgrad,fgrad,s,c] = filterbankphasegrad(f,g,a);
[tgrad,fgrad,s] = filterbankphasegrad(...)
[tgrad,fgrad] = filterbankphasegrad(...)

Input parameters
f Signal to be analyzed.

g Cell array of filters

a Vector of time steps.

L Signal length (optional).

minlvl Regularization parameter (optional, required < 1).

Output parameters
tgrad Instantaneous frequency relative to original position.

fgrad Group delay 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]

5.7.2 FILTERBANKREASSIGN - Reassign filterbank spectrogram


Usage
sr = filterbankreassign(s,tgrad,fgrad,a,cfreq);
sr = filterbankreassign(s,tgrad,fgrad,a,g);
[sr,repos,Lc] = filterbankreassign(...);

Input parameters
s Spectrogram to be reassigned.

tgrad Instantaneous frequency relative to original position.

fgrad Group delay relative to original position.


5.7. REASSIGNMENT AND PHASE GRADIENT 221

a Vector of time steps.

cfreq Vector of relative center frequencies in ]-1,1].

g Set of filters.

Output parameters

sr Reassigned filterbank spectrogram.

repos Reassigned positions.

Lc Subband lengths.

Description

filterbankreassign(s,tgrad,fgrad,a,cfreq) will reassign the values of the filterbank spec-


trogram s using the group delay fgrad and instantaneous frequency tgrad. The time-frequency sampling
pattern is determined from the time steps a and the center frequencies cfreq.
filterbankreassign(s,tgrad,fgrad,a,g) will do the same thing except the center fre-
quencies are estimated from a set of filters g.
[sr,repos,Lc]=filterbankreassign(...) 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 and fgrad must be cell-arrays of vectors of the same lengths. Arguments a and
cfreq or g must have the same number of elements as the cell arrays with coefficients.

Examples:

This example shows how to reassign a ERB filterbank spectrogram:

% Genrate 3 chirps 1 second long


L = 44100; 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’;

% Create ERB filterbank


[g,a,fc]=erbfilters(fs,L,’fractional’,’spacing’,1/12,’warped’);

% Compute phase gradient


[tgrad,fgrad,cs,c]=filterbankphasegrad(f,g,a);
% Do the reassignment
sr=filterbankreassign(cs,tgrad,fgrad,a,cent_freqs(fs,fc));
figure(1); subplot(211);
plotfilterbank(cs,a,fc,fs,60);
title(’ERBlet spectrogram of 3 chirps’);
subplot(212);
plotfilterbank(sr,a,fc,fs,60);
title(’Reassigned ERBlet spectrogram of 3 chirps’);
222 CHAPTER 5. LTFAT - FILTERBANKS

References: [44]

5.7.3 FILTERBANKSYNCHROSQUEEZE - Synchrosqueeze filterbank spectro-


gram
Usage
cr = filterbanksynchrosqueeze(c,tgrad,cfreq);
cr = filterbanksynchrosqueeze(c,tgrad,g);
[cr,repos,Lc] = filterbanksynchrosqueeze(...);

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’;

% Create ERB filterbank


[g,~,fc]=erbfilters(fs,L,’uniform’,’spacing’,1/12,’warped’);

% Compute phase gradient


[tgrad,~,~,c]=filterbankphasegrad(f,g,1);
% Do the reassignment
sr=filterbanksynchrosqueeze(c,tgrad,cent_freqs(fs,fc));
figure(1); subplot(211);
plotfilterbank(c,1,fc,fs,60);
title(’ERBlet spectrogram of 3 chirps’);
subplot(212);
plotfilterbank(sr,1,fc,fs,60);
title(’Synchrosqueezed ERBlet spectrogram of 3 chirps’);

References: [44]
224 CHAPTER 5. LTFAT - FILTERBANKS
Chapter 6

LTFAT - Non-stationary Gabor systems

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]

6.1.2 UNSDGT - Uniform Non-stationary Discrete Gabor transform


Usage
c=unsdgt(f,g,a,M);
[c,Ls]=unsdgt(f,g,a,M);

Input parameters
f Input signal.

g Cell array of window functions.

a Vector of time positions of windows.

M Numbers of frequency channels.

Output parameters
c Cell array of coefficients.

Ls Length of input signal.

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]

6.1.3 INSDGT - Inverse non-stationary discrete Gabor transform


Usage

f=insdgt(c,g,a,Ls);

Input parameters

c Cell array of coefficients.

g Cell array of window functions.

a Vector of time positions of windows.

Ls Length of input signal.

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.

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
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) additionally returns the length Ls of the input signal f. This is


handy for reconstruction:

[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

6.1.5 UNSDGTREAL - Uniform non-stationary Discrete Gabor transform


Usage
c=unsdgtreal(f,g,a,M);
[c,Ls]=unsdgtreal(f,g,a,M);

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

6.1.6 INSDGTREAL - Inverse NSDGT for real-valued signals


Usage

f=insdgt(c,g,a,M,Ls);

Input parameters

c Cell array of coefficients.

g Cell array of window functions.

a Vector of time positions of windows.

M Vector of numbers of frequency channels.

Ls Length of input signal.

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.2 Window construction and bounds


6.2.1 NSGABDUAL - Canonical dual window for non-stationary Gabor frames
Usage

gd=nsgabdual(g,a,M);
gd=nsgabdual(g,a,M,L);

Input parameters

g Cell array of windows.

a Vector of time shift.

M Vector of numbers of channels.

L Transform length.

Output parameters

gd Cell array of canonical dual windows


6.2. WINDOW CONSTRUCTION AND BOUNDS 231

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]

6.2.2 NSGABTIGHT - Canonical tight window for non-stationary Gabor frames


Usage
gt=nsgabtight(g,a,M);
gt=nsgabtight(g,a,M,L);

Input parameters
g Cell array of windows

a Vector of time shifts of windows.

M Vector of numbers of channels.

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]

6.2.3 NSGABFRAMEBOUNDS - Frame bounds of non-stationary Gabor frame


Usage
fcond=nsgabframebounds(g,a,M);
[A,B]=nsgabframebounds(g,a,M);

Input parameters
g Cell array of windows

a Vector of time positions of windows.

M Vector of numbers of frequency channels.


232 CHAPTER 6. LTFAT - NON-STATIONARY GABOR SYSTEMS

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]

6.2.4 NSGABFRAMEDIAG - Diagonal of Gabor frame operator


Usage
d=nsgabframediag(g,a,M);

Input parameters
g Window function.

a Length of time shift.

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.

a Vector of time positions of windows.

fs signal sample rate in Hz (optional)

dynrange Color scale dynamic range in dB (optional).


6.3. PLOTS 233

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

6.3.2 PLOTNSDGTREAL - Plot NSDGTREAL coefficients


Usage
plotnsdgtreal(c,a,fs,dynrange);

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

LTFAT - Quadratic time-frequency


distributions

7.1 Quadratic distributions


7.1.1 AMBIGUITYFUNCTION - Ambiguity function
Usage
A = ambiguityfunction(f);
A = ambiguityfunction(f,g);

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.

7.1.2 WIGNERVILLEDIST - Wigner-Ville distribution


Usage
W = wignervilledist(f);
W = wignervilledist(f, g);

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.

7.1.3 DRIHACZEKDIST - discrete Rihaczek distribution


Usage
r = drihaczekdist(f);

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.

7.1.4 QUADTFDIST - Quadratic time-frequency distribution


Usage
p = quadtfdist(f, q);

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:

’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 de-
fault value of [] means to not limit the dynamical range.
’db’ Apply 20*log_{10} to the coefficients. This makes it possible to see
very weak phenomena, but it might show too much noise. A logarith-
mic scale is more adapted to perception of sound. This is the default.
’dbsq’ Apply 10*log_{10} 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.
’linsq’ Show the square of the coefficients on a linear scale.
’linabs’ Show the absolute value of the coefficients on a linear scale.
’tc’ Time centring. 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.
’image’ Use imagesc to display the plot. This is the default.

’contour’ Do a contour plot.


’surf’ Do a surf plot.
’colorbar’ Display the colorbar. This is the default.

’nocolorbar’ Do not display the colorbar.


’display’ Display the figure. This is the default.
238 CHAPTER 7. LTFAT - QUADRATIC TIME-FREQUENCY DISTRIBUTIONS
Chapter 8

LTFAT - Frames

8.1 Creation of a frame object


8.1.1 FRAME - Construct a new frame
Usage
F=frame(ftype,...);

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.

Pure frequency frames

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.

Special / general frames

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

frame(’fusion’,w,F1,F2,...) constructs a fusion frame, which is the collection of the frames


specified by F1, F2,... The vector w contains a weight for each frame. If w is a scalar, this weight will be
applied to all the sub-frames.
frame(’tensor’,F1,F2,...) constructs a tensor product frame, where the frames F1, *F2,...
are applied along the 1st, 2nd etc. dimensions. If you don’t want any action along a specific dimension, use
the identity frame along that dimension. Any remaining dimensions in the input signal are left alone.

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

8.1.2 FRAMEPAIR - Construct a new frame


Usage

[F1,F2]=framepair(ftype,g1,g2,...);

Description

[F1,F2]=framepair(ftype,g1,g2,...) constructs two new frame objects F1 and F2 of the


same type ftype using the windows g1 and g2. The windows are specific to choosen frame type. See the
help on frame for the windows and arguments.
This function makes it easy to create a pair of canonical dual frames: simply specify ’dual’ as window
if one frame should be the dual of the other.
This is most easily explained through some examples. The following example creates a Gabor frame for
real-valued signals with a Gaussian analysis window and its canonical dual frame as the synthesis frame:

f=greasy;
[Fa,Fs]=framepair(’dgtreal’,’gauss’,’dual’,20,294);
c=frana(Fa,f);
r=frsyn(Fs,c);
norm(f-r)

This code produces the following output:

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);

8.1.3 FRAMEDUAL - Construct the canonical dual frame


Usage

Fd=framedual(F);
242 CHAPTER 8. LTFAT - FRAMES

Description

Fd=framedual(F) returns the canonical dual frame of F.


The canonical dual frame can be used to get perfect reconstruction as in the following example:

% Create a frame and its canonical dual


F=frame(’dgt’,’hamming’,32,64);
Fd=framedual(F);

% Compute the frame coefficients and test for perfect


% reconstruction
f=gspi;
c=frana(F,f);
r=frsyn(Fd,c);
norm(r(1:length(f))-f)

This code produces the following output:

ans =

9.757245647085724e-15

8.1.4 FRAMETIGHT - Construct the canonical tight frame


Usage

Ft=frametight(F);

Description

Ft=frametight(F) returns the canonical tight frame of F.


The canonical tight frame can be used to get perfect reconstruction if it is used for both analysis and
synthesis. This is demonstrated in the following example:

% Create a frame and its canonical tight


F=frame(’dgt’,’hamming’,32,64);
Ft=frametight(F);

% Compute the frame coefficients and test for perfect


% reconstruction
f=gspi;
c=frana(Ft,f);
r=frsyn(Ft,c);
norm(r(1:length(f))-f)

This code produces the following output:

ans =

1.067814285565954e-14

8.1.5 FRAMEACCEL - Precompute structures


Usage

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.

8.2 Linear operators


8.2.1 FRANA - Frame analysis operator
Usage
c=frana(F,f);

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

8.2.2 FRSYN - Frame synthesis operator


Usage
f=frsyn(F,c);

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;

F = frame(’dgt’, ’gauss’, a, M);

c = framenative2coef(F, eye(40));

f = frsyn(F, c);

8.2.3 FRSYNMATRIX - Frame synthesis operator matrix


Usage
G=frsynmatrix(F,L);

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));

This code produces the following output:

ans =

7.106774012374892e-15
8.2. LINEAR OPERATORS 245

8.2.4 FRGRAMIAN - Frame Gramian operator


Usage
o=frgramian(c, F);
o=frgramian(c, Fa, Fs);

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.

8.2.5 FRAMEOPERATOR - Frame Operator


Usage
o=frameoperator(F, f);

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.

8.2.6 FRAMEDIAG - Compute the diagonal of the frame operator


Usage
d=framediag(F,L);

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.

8.2.7 FRANAITER - Iterative analysis


Usage
c=franaiter(F,f);
[c,relres,iter]=franaiter(F,f,...);

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)

’maxit’,n Do at most n iterations.

’pg’ Solve the problem using the Conjugate Gradient algorithm. This is the
default.

’pcg’ Solve the problem using the Preconditioned Conjugate Gradient algo-
rithm.

’print’ Display the progress.

’quiet’ Don’t print anything, this is the default.

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’);

This code produces the following output:

ans =

2.023584411446212e-15
248 CHAPTER 8. LTFAT - FRAMES

8.2.8 FRSYNITER - Iterative synthesis


Usage
f=frsyniter(F,c);
f=frsyniter(F,c,Ls);
[f,relres,iter]=frsyniter(F,c,...);

Input parameters
F Frame

c Array of coefficients.

Ls length of signal.

Output parameters
f Signal.

relres Vector of residuals.

iter Number of iterations done.

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)

’maxit’,n Do at most n iterations.

’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.

’print’ Display the progress.

’quiet’ Don’t print anything, this is the default.

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’);

This code produces the following output:

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.

’linsq’ Show the square of the coefficients on a linear scale.

’linabs’ Show the absolute value of the coefficients on a linear scale.

’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.

8.3.2 FRAMEGRAM - Easy visualization of energy in transform domain


Usage
framegram(F,x,...);

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);

Any additional arguments given to framegram are passed onto plotframe.

8.4 Information about a frame


8.4.1 FRAMEBOUNDS - Frame bounds
Usage
fcond=framebounds(F);
[A,B]=framebounds(F);
[...]=framebounds(F,Ls);

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:

’fac’ Use a factorization algorithm. The function will throw an error if no


algorithm is available.
8.4. INFORMATION ABOUT A FRAME 251

’iter’ Call eigs to use an iterative algorithm.


’full’ Call eig to solve the full problem.
’auto’ Choose the fac method if possible, otherwise use the full method
for small problems and the iter method for larger problems. This is
the default.
’crossover’,c Set the problem size for which the ’auto’ method switches between
full and iter. Default is 200.
The following parameters specifically related to the iter method:
’tol’,t Stop if relative residual error of eighs is less than the specified toler-
ance. Default is 1e-9
’maxit’,n Do at most n iterations in eigs. Default is 100.
’pcgtol’,t Stop if relative residual error of pcg is less than the specified tolerance.
Default is 1e-6
’pcgmaxit’,n Do at most n iterations in pcg. Default is 150.
’p’,p The number of Lanzcos basis vectors to use. More vectors will result
in faster convergence, but a larger amount of memory. The optimal
value of p is problem dependent and should be less than L. The default
value chosen automatically by eigs.
’print’ Display the progress.
’quiet’ Don’t print anything, this is the default.

8.4.2 FRAMERED - Redundancy of a frame


Usage
red=framered(F);

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

8.4.3 FRAMELENGTH - Frame length from signal


Usage
L=framelength(F,Ls);

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.

8.4.4 FRAMELENGTHCOEF - Frame length from coefficients


Usage
L=framelengthcoef(F,Ncoef);

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.

8.4.5 FRAMECLENGTH - Number of coefficients from length of signal


Usage
Ncoef=frameclength(F,Ls);
[Ncoef,L]=frameclength(...);

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.

8.5 Coefficients conversions


8.5.1 FRAMECOEF2NATIVE - Convert coefficients to native format
Usage
coef=framecoef2native(F,coef);

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.

8.5.2 FRAMENATIVE2COEF - Convert coefficient from native format


Usage
coef=framenative2coef(F,coef);
8.6. NON-LINEAR ANALYSIS AND SYNTHESIS 253

Description
framenative2coef(F,coef) converts the frame coefficients from the native format of the transform
into the common column format.

8.5.3 FRAMECOEF2TF - Convert coefficients to time-frequency plane


Usage
cout=framecoef2tf(F,cin);

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’.

8.5.4 FRAMETF2COEF - Convert coefficients from TF-plane format


Usage
cout=frametf2coef(F,cin);

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’.

8.5.5 FRAMECOEF2TFPLOT - Convert coefficients to time-frequency plane ma-


trix
Usage
cout=framecoef2tfplot(F,cin);

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.

8.6 Non-linear analysis and synthesis


8.6.1 FRANABP - Frame Analysis Basis Pursuit
Usage
c = franabp(F,f)
c = franabp(F,f,lambda,C,tol,maxit)
[c,relres,iter,frec,cd] = franabp(...)
254 CHAPTER 8. LTFAT - FRAMES

Input parameters
F Frame definition

f Input signal

lambda Regularisation parameter.

C Step size of the algorithm.

tol Reative error tolerance.

maxit Maximum number of iterations.

Output parameters
c Sparse coefficients.

relres Last relative error.

iter Number of iterations done.

frec Reconstructed signal such that frec = frsyn(F,c)

cd The min ||c||_2 solution using the canonical dual frame.

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.

Optional positional parameters (lambda,C,tol,maxit)


lambda A parameter for weighting coefficients in the objective function. For lambda~=1 the basis pursuit
problem changes to
8.6. NON-LINEAR ANALYSIS AND SYNTHESIS 255

arg min ||λ c||1


c

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.

Other optional parameters


Key-value pairs:
’Fd’,Fd A canonical dual frame object or an anonymous function acting as the analysis operator of the
canonical dual frame.
’printstep’,printstep Print current status every printstep iteration.
Flag groups (first one listed is the default):
’print’,’quiet’ Enables/disables printing of notifications.
’zeros’,’frana’ Starting point of the algorithm. With ’zeros’ enabled, the algorithm starts from
coefficients set to zero, with ’frana’ the algorithm starts from c=frana(F,f).

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);

% Plot coefficients obtained by applying an analysis operator of a


% dual Gabor system to *f*
figure(2);
plotframe(F,cd,’dynrange’,50);

% Check the reconstruction error (should be close do zero).


% frec is obtained by applying the synthesis operator of frame *F*
% to sparse coefficients *c*.
norm(f-frec)

% Compare decay of coefficients sorted by absolute values


% (compressibility of coefficients)
figure(3);
semilogx([sort(abs(c),’descend’)/max(abs(c)),...
sort(abs(cd),’descend’)/max(abs(cd))]);
legend({’sparsified coefficients’,’dual system coefficients’});

This code produces the following output:

Iteration 10: relative error = 0.068384


Iteration 20: relative error = 0.034516
Iteration 30: relative error = 0.022865
Iteration 40: relative error = 0.016747
Iteration 50: relative error = 0.013124
Iteration 60: relative error = 0.010508

ans =

2.334642657924850e-14
8.6. NON-LINEAR ANALYSIS AND SYNTHESIS 257

References: [84], [18]

8.6.2 FRANALASSO - Frame LASSO regression


Usage
tc = franalasso(F,f,lambda)
tc = franalasso(F,f,lambda,C,tol,maxit)
[tc,relres,iter,frec,cd] = franalasso(...)

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.


258 CHAPTER 8. LTFAT - FRAMES

Output parameters
tc Thresholded coefficients

relres Vector of residuals.

iter Number of iterations done.

frec Reconstructed signal

cd The min ||c||_2 solution using the canonical dual frame.

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

’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 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);

% Plot coefficients obtained by applying an analysis operator of a


% dual Gabor system to f
figure(2);
plotframe(F,cd,’dynrange’,50);

% Check the (NON-ZERO) reconstruction error .


% frec is obtained by applying the synthesis operator of frame F
% to sparse coefficients c.
norm(f-frec)

% Compare decay of coefficients sorted by absolute values


% (compressibility of coefficients)
figure(3);
semilogx([sort(abs(c),’descend’)/max(abs(c)),...
sort(abs(cd),’descend’)/max(abs(cd))]);
legend({’sparsified coefficients’,’dual system coefficients’});

This code produces the following output:

Iteration 10: relative error = 0.049584


Iteration 20: relative error = 0.032723
Iteration 30: relative error = 0.023291
Iteration 40: relative error = 0.015511
Iteration 50: relative error = 0.010411

ans =

3.163620955029133
260 CHAPTER 8. LTFAT - FRAMES

References: [25], [13]


8.6. NON-LINEAR ANALYSIS AND SYNTHESIS 261

8.6.3 FRANAGROUPLASSO - Group LASSO regression in the TF-domain


Usage
tc = franagrouplasso(F,f,lambda)
tc = franagrouplasso(F,f,lambda,C,tol,maxit)
[tc,relres,iter,frec] = franagrouplasso(...)

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

’quiet’ Don’t print anything, this is the default.

’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);

References: [54], [53]

8.6.4 FRSYNABS - Reconstruction from magnitude of coefficients


Usage
f=frsynabs(F,s);
f=frsynabs(F,s,Ls);
[f,relres,iter,c]=frsynabs(...);

Input parameters
F Frame

s Array of coefficients.

Ls length of signal.

Output parameters
f Signal.

relres Vector of residuals.

iter Number of iterations done.

c Coefficients with the reconstructed phase

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));

using an iterative method.


frsynabs(F,s,Ls) does as above but cuts or extends f to length Ls.
If the phase of the coefficients s is known, it is much better to use frsyn.
[f,relres,iter]=frsynabs(...) additionally returns the residuals in a vector relres and the
number of iteration steps iter. The residuals are computed as:

‖|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:

’griflim’ Use the Griffin-Lim iterative method. This is the default.


’fgriflim’ Use the Fast Griffin-Lim iterative method.
’Fd’,Fd A canonical dual frame object or an anonymous function acting as the
synthesis operator of the canonical dual frame. If not provided, the
function attempts to create one using Fd=framedual(F).
’alpha’,a Parameter of the Fast Griffin-Lim algorithm. It is ignored if not used
together with ’fgriflim’ flag.
The BFGS method related paramaters:

’bfgs’ Use the limited-memory Broyden Fletcher Goldfarb Shanno (BFGS)


method.
’p’,p Parameter for the compressed version of the obj. function in the l-
BFGS method. It is ignored if not used together with ’bfgs’ flag.

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.

’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], [71], [28]
264 CHAPTER 8. LTFAT - FRAMES
Chapter 9

LTFAT - Signal processing tools

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).

’dim’,d Work along specified dimension. The default value of [] means to


work along the first non-singleton one.

9.1.2 NORMALIZE - Normalize input signal by specified norm


Usage
h=normalize(f,...);

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:

’1’ Normalize the l 1 norm to be 1.

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’.

’2’ Normalize the l 2 norm to be 1.

’energy’ Normalize the energy of the signal to be 1. This is exactly the same as
’2’.

’inf’ Normalize the l inf norm to be 1.

’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.

’s0’ Normalize the S0-norm 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.

’null’ Do NOT normalize, output is identical to input.

It is possible to specify the dimension:

’dim’,d Work along specified dimension. The default value of [] means to work along the
first non-singleton one.

9.1.3 GAINDB - Increase/decrease level of signal


Usage
outsig = gaindb(insig,gn);

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.

9.1.4 CRESTFACTOR - Crest factor of input signal in dB


Usage
c=crestfactor(insig);

Description
crestfactor(insig) computes the crest factor of the input signal insig. The output is measured in
dB.

9.1.5 UQUANT - Simulate uniform quantization


Usage
x=uquant(x);
x=uquant(x,nbits,xmax,...);
9.2. WINDOW FUNCTIONS 267

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:

’nbits’ Number of bits to use in the quantization. Default is 8.

’xmax’ Maximal quantifiable value. Default is 1.

’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.

’u’ Use unsigned quantization. Assumes the signal is positive. Negative


values are silently rounded to zero. Useful for images.

If this function is applied to a complex signal, it will be applied to the real and imaginary part separately.

9.2 Window functions


9.2.1 FIRWIN - FIR window
Usage
g=firwin(name,M);
g=firwin(name,M,...);
g=firwin(name,x);

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’

’rect’ (Almost) rectangular window. The rectangular window has a mainlobe


width of 4/M, a PSL of -13.3 dB and decay rate of 6 dB/Octave. Forms
a PU if the order is odd. Alias: ’square’
268 CHAPTER 9. LTFAT - SIGNAL PROCESSING TOOLS

’tria’ (Almost) triangular window. Forms a PU. Alias: ’bartlett’

’sqrttria’ Square root of the triangular window.

’hamming’ Hamming window. Forms a PU that sums to 1.08 instead of 1.0 as


usual. The Hamming window has a mainlobe width of 8/M, a PSL of
-42.7 dB and decay rate of 6 dB/Octave. This window should not be
used for a Wilson basis, as a reconstruction window cannot be found
by wildual.

’blackman’ Blackman window. The Blackman window has a mainlobe width of


12/M, a PSL of -58.1 dB and decay rate of 18 dB/Octave.

’blackman2’ Alternate Blackman window. This window has a mainlobe width of


12/M, a PSL of -68.24 dB and decay rate of 6 dB/Octave.

’itersine’ Iterated sine window. Generates an orthonormal Wilson/WMDCT ba-


sis. This window is described in Wesfreid and Wickerhauser (1993)
and is used in the ogg sound codec. Alias: ’ogg’

’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.

’nuttall10’ 2-term Nuttall window with 1 continuous derivative. Alias: ’hann’,


’hanning’.

’nuttall01’ 2-term Nuttall window with 0 continuous derivatives. This is a slightly


improved Hamming window. It has a mainlobe width of 8/M, a PSL
of -43.19 dB and decay rate of 6 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.

’nuttall02’ 3-term Nuttall window with 0 continuous derivatives. The window


has a mainlobe width of 12/M, a PSL of -71.48 dB and decay rate of 6
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.

’nuttall12’ 4-term Nuttall window with 1 continuous derivatives. Alias: ’nuttall’.

’nuttall03’ 4-term Nuttall window with 0 continuous derivatives. The window


has a mainlobe width of 16/M, a PSL of -98.17 dB and decay rate of 6
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.

’wp’ Output is whole point even. This is the default. It corresponds to a


shift of s = 0.
9.2. WINDOW FUNCTIONS 269

’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’);

References: [69], [42], [68], [95]

9.2.2 FIRKAISER - Kaiser-Bessel window


Usage
g=firkaiser(L,beta);
g=firkaiser(L,beta,...);

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]

9.2.3 FIR2LONG - Extend FIR window to LONG


Usage
g=fir2long(g,Llong);

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.

9.2.4 LONG2FIR - Cut LONG window to FIR


Usage
g=long2fir(g,L);

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

’fs’,fs If the sampling frequency fs is specified then the length M is specified


in seconds and the centre frequency fc in Hz.
’complex’ Make the filter complex valued if the centre frequency is non-zero.
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.
’causal’ Create a causal filter starting at the first sample. If specified, this flag
overwrites the delay setting.
It is possible to normalize the impulse response of the filter by passing any of the flags from the nor-
malize 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.

9.3.2 BLFILTER - Construct a band-limited filter


Usage
g=blfilter(winname,fsupp,fc);
g=blfilter(winname,fsupp,fc,...);

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.

9.3.3 WARPEDBLFILTER - Construct a warped band-limited filter


Usage
g=warpedblfilter(winname,fsupp,fc,fs,freqtoscale,scaletofreq);

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.

’real’ Make the filter real-valued if the centre frequency is non-zero.

’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.

’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 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.

9.3.4 PFILT - Apply filter with periodic boundary conditions


Usage
h=pfilt(f,g);
h=pfilt(f,g,a,dim);

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.

The coefficients obtained from filtering a signal f by a filter g are defined by

L−1
c (n + 1) = ∑ f (l + 1) g (an − l + 1)
l=0

where an − l is computed modulo L.

9.3.5 MAGRESP - Magnitude response plot of window


Usage
magresp(g,...);
magresp(g,fs,...);
magresp(g,fs,dynrange,....);
274 CHAPTER 9. LTFAT - SIGNAL PROCESSING TOOLS

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.

’dynrange’,r Limit the dynamic range of the plot to r dB.

’fir’ Indicate that the input is an FIR window. magresp will zero-extend the
window to display a smooth magnitude response.

’L’,L Zero-extend the window to length L.

’posfreq’ Show only positive frequencies.

’nf’ Show also negative frequencies

’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’});

9.3.6 TRANSFERFUNCTION - The transferfunction of a filter


Usage

H=transferfunction(g,L);

Description

transferfunction(g,L) computes the transferfunction of length L of the filter defined by g.

9.3.7 PGRPDELAY - Group delay of a filter with periodic boundaries


Usage

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

9.4.2 RAMPDOWN - Falling ramp function


Usage
outsig=rampdown(siglen);

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.

9.4.3 RAMPSIGNAL - Ramp signal


Usage
outsig=rampsignal(insig,L);

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.

9.5 Thresholding methods


9.5.1 THRESH - Coefficient thresholding
Usage
x=thresh(x,lambda,...);
[x,N]=thresh(x,lambda,...);

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

’hard’ Perform hard thresholding. This is the default.

’wiener’ Perform empirical Wiener shrinkage. This is in between soft and hard
thresholding.

’soft’ Perform soft thresholding.

’full’ Returns the output as a full matrix. This is the default.

’sparse’ Returns the output as a sparse matrix.

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’);

References: [56], [36]

9.5.2 LARGESTR - Keep fixed ratio of largest coefficients


Usage
xo=largestr(x,p);
xo=largestr(x,p,mtype);
[xo,N]=largestr(...);

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:

’hard’ Perform hard thresholding. This is the default.


9.5. THRESHOLDING METHODS 279

’wiener’ Perform empirical Wiener shrinkage. This is in between soft and hard
thresholding.

’soft’ Perform soft thresholding.

’full’ Returns the output as a full matrix. This is the default.

’sparse’ Returns the output as a sparse matrix.

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]

9.5.3 LARGESTN - Keep N largest coefficients


Usage
xo=largestn(x,N);
xo=largestn(x,N,mtype);

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:

’hard’ Perform hard thresholding. This is the default.

’wiener’ Perform empirical Wiener shrinkage. This is in between soft and hard
thresholding.

’soft’ Perform soft thresholding.

’full’ Returns the output as a full matrix. This is the default.

’sparse’ Returns the output as a sparse matrix.

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]

9.5.4 DYNLIMIT - Limit the dynamical range of the input


Usage
xo=dynlimit(xi,dynrange);

Description
dynlimit(xi,dynrange) will threshold the input such that the difference between the maximum and
minumum value of xi is exactly dynrange.

9.5.5 GROUPTHRESH - Group thresholding


Usage
xo=groupthresh(xi,lambda);
280 CHAPTER 9. LTFAT - SIGNAL PROCESSING TOOLS

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,’group’) shrinks all coefficients within a given group according to


the value of the l 2 norm of the group in comparison to the threshold lambda. This is the default.

∙ groupthresh(x,lambda,’elite’) shrinks all coefficients within a given group according to


the value of the l 1 norm of the group in comparison to the threshold value lambda.

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]

9.6 Image processing


9.6.1 RGB2JPEG - Coverts from RGB format to the YCbCr format used by JPEG
Usage
YCbCr = rgb2jpeg(RGB);

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’);

9.6.2 JPEG2RGB - Coverts from RGB format to YCbCr format


Usage
RGB = jpeg2rgb(YCbCr);

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

For more information, see http://en.wikipedia.org/wiki/YCbCr and http://de.wikipedia.


org/wiki/JPEG

9.7 Tools for OFDM


9.7.1 QAM4 - Quadrature amplitude modulation of order 4
Usage
xo=qam4(xi);

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.

9.7.2 IQAM4 - Inverse QAM of order 4


iqam4(xi) demodulates a signal mapping the input coefficients to the closest complex root
of unity, and returning the associated bit pattern. This is the inverse operation of qam4.
Chapter 10

LTFAT - Simple auditory processing

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.

’y’ Make the y-axis use the auditory scale.

’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.

10.2 Auditory scales


10.2.1 AUDTOFREQ - Converts auditory units to frequency (Hz)
Usage
freq = audtofreq(aud);

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.

10.2.2 FREQTOAUD - Converts frequencies (Hz) to auditory scale units


Usage
aud = freqtoaud(freq,scale);

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:

’erb’ A distance of 1 erb is equal to the equivalent rectangular bandwidth


of the auditory filters at that point on the frequency scale. The scale
is normalized such that 0 erbs corresponds to 0 Hz. The width of the
auditory filters were determined by a notched-noise experiment. The
erb scale is defined in Glasberg and Moore (1990). This is the default.

’mel’ The mel scale is a perceptual scale of pitches judged by listeners to


be equal in distance from one another. The reference point between
this scale and normal frequency measurement is defined by equating
a 1000 Hz tone, 40 dB above the listener’s threshold, with a pitch of
1000 mels. The mel-scale is defined in Stevens et. al (1937).

’mel1000’ Alternative definition of the mel scale using a break frequency of 1000
Hz. This scale was reported in Fant (1968).

’bark’ The bark-scale is originally defined in Zwicker (1961). A distance of


1 on the bark scale is known as a critical band. The implementation
provided in this function is described in Traunmuller (1990).

’erb83’ This is the original defintion of the erb scale given in Moore. et al.
(1983).

’freq’ Return the frequency in Hz.

If no flag is given, the erb-scale will be selected.


References: [89], [100], [30], [37], [92], [65]

10.2.3 AUDSPACE - Equidistantly spaced points on auditory scale


Usage

y=audspace(flow,fhigh,n,scale);

Description

audspace(flow,fhigh,n,scale) computes a vector of length n containing values equidistantly


scaled on the selected auditory scale between the frequencies flow and fhigh. All frequencies are specified
in Hz.
See the help on freqtoaud to get a list of the supported values of the scale parameter.
[y,bw]=audspace(...) does the same but outputs the bandwidth between each sample measured
on the selected scale.

10.2.4 AUDSPACEBW - Auditory scale points specified by bandwidth


Usage

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.

10.2.5 ERBTOFREQ - Converts erb units to frequency (Hz)


Usage
freq = erbtofreq(erb);

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’);

10.2.6 FREQTOERB - Converts frequencies (Hz) to erbs


Usage
erb = freqtoerb(freq);

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

10.2.7 ERBSPACE - Equidistantly spaced points on erbscale


Usage

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.

10.2.8 ERBSPACEBW - Erbscale points specified by bandwidth


Usage

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.

10.2.9 AUDFILTBW - Bandwidth of auditory filter


Usage

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:

bw = 25 + 75(1 + 1.4 × 10−6 f c2 )0.69

as estimated by Zwicker and Terhardt (1980).


References: [37], [101]

10.3 Range compression


10.3.1 RANGECOMPRESS - Compress the dynamic range of a signal
Usage

[outsig, sigweight] = rangecompress(insig,mu);


10.3. RANGE COMPRESSION 287

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:

’mulaw’ Do mu-law compression, this is the default.

’alaw’ Do A-law compression.

’mu’,mu µ-law parameter. Default value is 255.

’A’,A A-law parameter. Default value is 87.7.

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]

10.3.2 RANGEEXPAND - Expand the dynamic range of a signal


Usage
sig = rangeexpand(insig,mu,sigweight);

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:

’mulaw’ Do mu-law compression, this is the default.

’alaw’ Do A-law compression.

’mu’,mu µ-law parameter. Default value is 255.

References: [49]
288 CHAPTER 10. LTFAT - SIMPLE AUDITORY PROCESSING

10.4 Auditory filters


10.4.1 GAMMATONEFIR - Gammatone filter coefficients
Usage
b = gammatonefir(fc,fs,n,betamul);
b = gammatonefir(fc,fs,n);
b = gammatonefir(fc,fs);

Input parameters
fc center frequency in Hz.
fs sampling rate in Hz.
n max. filter length.

beta bandwidth of the filter.

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

g(t) = at 4−1 cos(2π · f c · t)e−2πβ ·t


The gammatone filters as implemented by this function generate complex valued output, because the filters
are modulated by the exponential function. Using real on the output will give the coefficients of the
corresponding cosine modulated filters.
To create the filter coefficients of a 1-erb spaced filter bank using gammatone filters use the following
construction:
g = gammatonefir(erbspacebw(flow,fhigh),fs);

References: [5], [37]


Chapter 11

LTFAT - Signals

11.1 Signal generators


11.1.1 CTESTFUN - Complex 1-D test function
Usage
ftest=ctestfun(L);

Description
ctestfun(L) returns a test signal consisting of a superposition of a chirp and an indicator function.

11.1.2 NOISE - Stochastic noise generator


Usage
outsig = noise(siglen,nsigs,type);

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:

White noise in the time-frequency domain:

sgram(noise(5000,’white’),’dynrange’,70);

Pink noise in the time-frequency domain:

sgram(noise(5000,’pink’),’dynrange’,70);

Brown/red noise in the time-frequency domain:

sgram(noise(5000,’brown’),’dynrange’,70);
11.1. SIGNAL GENERATORS 291

11.1.3 PINKNOISE - Generates a pink noise signal


Usage
outsig = pinknoise(siglen,nsigs);

Input parameters
siglen Length of the noise (samples)

nsigs Number of signals (default is 1)

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’);

11.1.4 EXPCHIRP - Exponential chirp


Usage
outsig=expchirp(L,fstart,fend)

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:

’fs’,fs Use a sampling frequency of fs Hz. If this option is specified, fstart


and fend will be measured in Hz.

’phi’,phi Starting phase of the chirp. Default value is 0.

’fc’,fc Shift the chirp by fc in frequency. Default values is 0.


292 CHAPTER 11. LTFAT - SIGNALS

11.2 Sound signals.

11.2.1 BAT - Load the ’bat’ test signal

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 of ’bat’ in the time-domain:

plot((1:400)/143000,bat);
xlabel(’Time (seconds)’);
ylabel(’Amplitude’);

Plot of ’bat’ in the frequency-domain:

plotfftreal(fftreal(bat),143000,90);
11.2. SOUND SIGNALS. 293

Plot of ’bat’ in the time-frequency-domain:

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.

11.2.3 GREASY - Load the ’greasy’ test signal


Usage
s=greasy;
294 CHAPTER 11. LTFAT - SIGNALS

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’);

Plot of ’greasy’ in the frequency-domain:


plotfftreal(fftreal(greasy),16000,90);

Plot of ’greasy’ in the time-frequency-domain:


sgram(greasy,16000,90);
11.2. SOUND SIGNALS. 295

References: [62]

11.2.4 COCKTAILPARTY - Load the ’cocktailparty’ test signal


Usage

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.

11.2.5 GSPI - Load the ’glockenspiel’ test signal


gspi loads the ’glockenspiel’ signal. This is a recording of a simple tune played on a glockenspiel. It is
262144 samples long, mono, recorded at 44100 Hz using 16 bit quantization.
[sig,fs]=gspi additionally returns the sampling frequency fs.
This signal, and other similar audio tests signals, can be found on the EBU SQAM test signal CD
http://tech.ebu.ch/publications/sqamcd.

11.2.6 LINUS - Load the ’linus’ test signal


Usage

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

11.2.7 LTFATLOGO - Load the ’ltfatlogo’ test signal


Usage
s=ltfatlogo;

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);

11.2.8 OTOCLICK - Load the ’otoclick’ test signal


Usage
s=otoclick;

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.

11.2.9 TRAINDOPPLER - Load the ’traindoppler’ test signal


Usage
s=traindoppler;
11.3. IMAGES. 297

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’);

See ftp://nic.funet.fi/pub/graphics/misc/test-images/ or http://sipi.usc.


edu/database/database.cgi?volume=misc.

11.3.2 LICHTENSTEIN - Load the ’lichtenstein’ test image


Usage
s=lichtenstein;

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.

11.3.3 LTFATTEXT - Load the ’ltfattext’ test image


Usage
s=ltfattext;

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

12.1 Basic demos


12.1.1 DEMO_DGT - Basic introduction to DGT analysis/synthesis
This demo shows how to compute Gabor coefficients of a signal.

Figure 12.1: Spectrogram of the ’bat’ signal.


The figure shows a spectrogram of the ’bat’ signal. The coefficients are shown on a linear scale.

Output
Type "help demo_dgt" to see a description of how this demo works.

------ Spectrogram analysis -----------------------------------

The spectrogram is highly redundant.


No. of coefficients in the signal: 400
No. of coefficients in the spectrogram: 80400
Redundacy of the spectrogram: 201.000000

---- Simple Gabor analysis using a standard Gaussian window. ----


Setup parameters for a Discrete Gabor Transform.
Time shift:

299
300 CHAPTER 12. LTFAT - DEMOS

Figure 12.2: Gabor coefficients of the ’bat’ signal.


The figure show a set of Gabor coefficients for the ’bat’ signal, computed using a DGT with a Gaussian window. The
coefficients contains all the information to reconstruct the signal, even though there a far fewer coefficients than the
spectrogram contains.

Figure 12.3: Real-valued Gabor analysis


This figure shows only the coefficients for the positive frequencies. As the signal is real-value, these coefficients contain
all the necessary information. Compare to the shape of the spectrogram shown on Figure 1.

a =

20

Number of frequency channels.

M =

40
12.1. BASIC DEMOS 301

Figure 12.4: DGT coefficients on a spectrogram


This figure shows how the coefficients from DGTREAL can be picked from the coefficients computed by a full Short-
time Fourier transform, as visualized by a spectrogram.

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

---- Real valued Gabor analysis. ----

---- Perfect reconstruction. ----


Reconstruction error using IDGT: 5.384302e-16
Reconstruction error using IDGTREAL: 5.664802e-16

12.1.2 DEMO_GABFIR - Working with FIR windows


This demo demonstrates how to work with FIR windows in Gabor systems.
FIR windows are the windows traditionally used in signal processing. They are short, much shorter
than the signal, and this is used to make effecient algorithms. They are also the only choice for applications
involving streaming data.
It is very easy to compute a spectrogram or Gabor coefficients using a FIR window. The hard part is
302 CHAPTER 12. LTFAT - DEMOS

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.

Figure 12.5: Hanning FIR window


This figure shows the a Hanning window in the time domain and its magnitude response.

Figure 12.6: Kaiser-Bessel FIR window


This figure shows a Kaiser Bessel window and its magnitude response, and the same two plots for the canonical dual of
the window.
12.1. BASIC DEMOS 303

Figure 12.7: Gaussian FIR window for low redundancy


This figure shows a truncated Gaussian window and its magnitude response. The same two plots are show for the
truncated canonical dual window.

Figure 12.8: Almost tight Gaussian FIR window


This figure shows a tight Gaussian window that has been truncated and its magnitude response.

Output

Reconstruction error using itersine window, should be close to zero:

ans =

0.500000000000000

Reconstruction error canonical dual of Kaiser window, should be close to zero:

ans =

6.401998278383549e-17
304 CHAPTER 12. LTFAT - DEMOS

Reconstruction error using cutted dual window.

recerr =

0.001762485642153

or expressed in dB:

ans =

-27.538744122424180

Reconstruction error using cutted tight window.

recerr =

9.858293436835774e-04

or expressed in dB:

ans =

-30.061982590052025

12.1.3 DEMO_WAVELETS - Wavelet filter banks


This demo exemplifies the use of the wavelet filter bank trees. All representations use "least asymmetric"
Daubechies wavelet orthonormal filters ’sym8’ (8-regular, length 16).

Figure 12.9: DWT representation


The filter bank tree consists of 11 levels of iterated 2-band basic wavelet filter bank, where only the low-pass output is
further decomposed. This results in 12 bands with octave resolution.

Output
12.2. COMPRESSION 305

Figure 12.10: 8-band DWT representation


The filter bank tree (effectively) consists of 3 levels of iterated 8-band basic wavelet filter bank resulting in 22 bands.
Only the low-pass output is decomposed at each level.

Figure 12.11: Full Wavelet filter bank tree representation


The filter bank tree depth is 8 and it is fully decomposed meaning both outputs (low-pass and high-pass) of the basic
filter bank is plot further. This results in 256 bands linearly covering the frequency axis.

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

Figure 12.12: Full Wavelet filter bank tree representation


The same case as before, but symmetric nearly orthogonal basic filter bank is used.

Figure 12.13: Full Dual-tree Wavelet filter bank representation


This is a 2 times redundant representation using Q-shift dual-tree wavelet filters.

12.2.2 DEMO_AUDIOCOMPRESSION - Audio compression using N-term approx


This demos shows how to do audio compression using best N-term approximation of an wmdct transform.
The signal is transformed using an orthonormal wmdct transform. Then approximations with a fixed
number N of coefficients are obtained by:

∙ Linear approximation: The N coefficients with lowest frequency index are kept.

∙ Non-linear approximation: The N largest coefficients (in magnitude) are kept.

The corresponding approximated signal can be computed using iwmdct.


Note: The inverse WMDCT is not needed for computing computing SNRs. Instead Parseval theorem
states that the norm of a signal equals the norm of the sequence of its wmdct coefficients.
12.3. DENOISING 307

Figure 12.14: Wilson and WMDCT basis


This right figure shows the image compressed using a dwilt basis with 8 channels. This corresponds quite closely to
JPEG compression, except that the borders between neigbouring blocs are smoother, since the dwilt uses a windowing
function.
The left figure shows the same, now using a MDCT basis. The MDCT produces more visible artifacts, as the slowest
changing frequency in each block has a half-wave modulation. This is visible on otherwise smooth backgrounds.

Figure 12.15: Wavelet


The Wavelet used is the DB6 with J = 5 levels. On the right figure the standard layout has been used, on the left the
tensor layout was used.

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

Figure 12.16: Rate-distorition plot


The figure shows the output Signal to Noise Ratio (SNR) as a function of the number of retained coefficients.

The signal is transformed using an orthonormal WMDCT transform followed by a thresholding. Then
the signal is reconstructed and compared with the original.

Figure 12.17: Denoising


The figure shows the original signal, the noisy signal and denoised signals using hard and soft threshholding applied to
the WMDCT of the noise signal.

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.

Some simplifications used to make this demo simple:

∙ We assume that the whole spectrum is available for transmission.


∙ The window and its dual have full length support. This is not practical, because all data
would have to be processed at once. Instead, an FIR should be used, with both the window
and its dual having a short length.
∙ The window is periodic. The data at the very end interferes with the data at the very
beginning. A simple way to solve this is to transmit zeros at the beginning and at the end,
to flush the system properly.

Figure 12.18: Received coefficients.


This figure shows the distribution in the complex plane of the received coefficients. If the channel was perfect, all the
points should appear at the complex roots of unity (1,i,-1 and -i). This demo is random, so everytime it is run it produces
a new plot, and the error rate may vary.

Output
Type "help demo_ofdm" to see a description of how this demo works.

Number of faulty bits:


310 CHAPTER 12. LTFAT - DEMOS

faulty =

Error rate:

ans =

12.4.2 DEMO_AUDIOSHRINK - Decomposition into tonal and transient parts


This demos shows how to do audio coding and "tonal + transient" decomposition using group lasso shrink-
age of two wmdct transforms with different time-frequency resolutions.
The signal is transformed using two orthonormal wmdct bases. Then group lasso shrinkage is applied
to the two transforms in order to:

∙ 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.

Figure 12.19: Plots and time-frequency images


The upper plots in the figure show the tonal parts of the signal, the lower plots show the transients. The TF-plots on the
left are the corresponding wmdct coefficients found by appropriate group lasso shrinkage

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

12.4.3 DEMO_GABMULAPPR - Approximate a slowly time variant system by a


Gabor multiplier
This script construct a slowly time variant system and performs the best approximation by a Gabor mul-
tiplier with specified parameters (a and L see below). Then it shows the action of the slowly time variant
system (A) as well as of the best approximation of (A) by a Gabor multiplier (B) on a sinusoids and an
exponential sweep.

Figure 12.20: Spectrogram of signals


The figure shows the spectogram of the output of the two systems applied on a sinusoid (left) and an exponential sweep.

Output
Type "help demo_gabmulappr" to see a description of how this demo works.

12.4.4 DEMO_BPFRAMEMUL - Frame multiplier acting as a time-varying band-


pass filter
This demo demonstrates creation and effect of a Gabor multiplier. The multiplier performs a time-varying
bandpass filtering. The band-pass filter with center frequency changing over time is explicitly created but
it is treated as a "black box" system. The symbol is identified by "probing" the system with a white noise
and dividing DGT of the output by DGT of the input element-wise. The symbol is smoothed out by a 5x5
median filter.

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);

12.4.5 DEMO_FRSYNABS - Construction of a signal with a given spectrogram


This demo demonstrates iterative reconstruction of a spectrogram.
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.

Output
312 CHAPTER 12. LTFAT - DEMOS

Figure 12.21: The symbol of the multiplier.


This figure shows a symbol used in the Gabor multiplier.

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.

12.4.6 DEMO_FILTERBANKSYNCHROSQUEEZE - Filterbank synchrosqueez-


ing and inversion
The demo shows that the synchrosqueezed filterbank representation can be directly used to reconstruct the
original signal. Since we do not work with a filterbank which forms a tight frame (its filterbankresponse is
not constant) the direct reconstruction (mere summing all the channels) does not work well. We can fix that
by filtering (equalizing) the result by the inverse of the overall analysis filterbank frequency response.
References: [44]

Output
Direct reconstruction MSE:
From the coefficients: 2.176541e-03
From the synchrosqueezed coefficients: 2.176541e-03
12.5. ASPECTS OF PARTICULAR FUNCTIONS 313

Figure 12.23: Original spectrogram


This figure shows the target spectrogram

Figure 12.24: Linear reconstruction


This figure shows a spectrogram of a linear reconstruction of the target spectrogram.

Equalized reconstruction MSE:


From the coefficients: 8.587864e-16
From the synchrosqueezed coefficients: 7.161705e-16

12.5 Aspects of particular functions


12.5.1 DEMO_NSDGT - Non-stationary Gabor transform demo
This script sets up a non-stationary Gabor frame with the specified parameters, computes windows and
corresponding canonical dual windows and a test signal, and plots the windows and the energy of the
coefficients.
314 CHAPTER 12. LTFAT - DEMOS

Figure 12.25: Iterative reconstruction using the Griffin-Lim method.


This figure shows a spectrogram of an iterative reconstruction of the target spectrogram using the Griffin-Lim projection
method.

Figure 12.26: Iterative reconstruction using the BFGS method.


This figure shows a spectrogram of an iterative reconstruction of the target spectrogram using the BFGS method.

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

12.5.2 DEMO_PGAUSS - How to use PGAUSS


This script illustrates various properties of the Gaussian function.

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.

Figure 12.28: Errors of the direct and the equalized reconstructions


There is still a small DC offset of the signal obtained by the direct summation.

ans =

2.481524897647706e-15

The function is WP even. The following should be 1.

ans =

Therefore, its DFT is real.


316 CHAPTER 12. LTFAT - DEMOS

Figure 12.29: Windows + dual windows


This figure shows the window functions used and the corresponding canonical dual windows.

Figure 12.30: Spectrogram (absolute value of coefficients in dB)


This figure shows a (colour-coded) image of the nsdgt coefficient modulus.

The norm of the imaginary part should be close to zero.

ans =

1.501312721600895e-15

12.5.3 DEMO_PBSPLINE - How to use PBSPLINE


This script illustrates various properties of the pbspline function.

Output
Type "help demo_pbspline" to see a description of how this demo works.
12.5. ASPECTS OF PARTICULAR FUNCTIONS 317

Figure 12.31: Window+Dual+Tight


This figure shows an optimally centered Gaussian for a given Gabor system, its canonical dual and tight windows and
the DFTs of these windows.

Figure 12.32: Three first splines


This figure shows the three first splines (order 0,1 and 2) and their dual windows.
Note that they are calculated for an even number of the parameter a, meaning that they are not exactly splines, but a
slightly smoother construction, that still form a partition of unity.

Length of the generated window:

ntaps =

19

Norm of imaginary part. Should be close to zero.

ans =

4.035410778421974e-16
318 CHAPTER 12. LTFAT - DEMOS

Window is whole point even. Should be 1.

ans =

Length of g after cutting.

ans =

19

difference between original g, and gextend.


Should be close to zero.

ans =

6.204997459932044e-16

12.5.4 DEMO_GABMIXDUAL - How to use GABMIXDUAL


This script illustrates how one can produce dual windows using GABMIXDUAL
The demo constructs a dual window that is more concentrated in the time domain by mixing the original
Gabor window by one that is extremely well concentrated. The result is somewhat in the middle of these
two.
The lower framebound of the mixing Gabor system is horrible, but this does not carry over to the
gabmixdual.

Figure 12.33: Gabmixdual of two Gaussians.


The first row of the figure shows the canonical dual window of the input window, which is a Gaussian function perfectly
localized in the time and frequency domains.
The second row shows the canonical dual window of the window we will be mixing with: This is a Gaussian that is 10
times more concentrated in the time domain than in the frequency domain. The resulting canonical dual window has
rapid decay in the time domain.
The last row shows the gabmixdual of these two. This is a non-canonical dual window of the first Gaussian, with decay
resembling that of the second.
12.5. ASPECTS OF PARTICULAR FUNCTIONS 319

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

Framebounds of mixing Gabor system:

A2 =

2.024110119704336e-05

B2 =

4.898979421758012

Framebounds of gabmixdual Gabor system:

Am =

0.004131003699532

Bm =

0.011463008168063

12.5.5 DEMO_FRAMEMUL - Time-frequency localization by a Gabor multiplier


This script creates several different time-frequency symbols and demonstrate their effect on a random, real
input signal.

Output
Type "help demo_framemul" to see a description of how this demo works.

12.5.6 DEMO_PHASEPLOT - Give demos of nice phaseplots


This script creates a synthetic signal and then uses phaseplot on it, using several of the possible options.
For real-life signal only small parts should be analyzed. In the chosen demo the fundamental frequency
of the speaker can be nicely seen.
References: [21], [20], [41]

Output
Type "help demo_phaseplot" to see a description of how this demo works.
320 CHAPTER 12. LTFAT - DEMOS

Figure 12.34: Cut a circle in the TF-plane


This figure shows the symbol (top plot, only the positive frequencies are displayed), the input random signal (bottom)
and the output signal (middle).

Figure 12.35: Keep low frequencies (low-pass)


This figure shows the symbol (top plot, only the positive frequencies are displayed), the input random signal (bottom)
and the output signal (middle).

12.5.7 DEMO_PHASERET - Phase retrieval and phase difference


This demo demonstrates iterative reconstruction of a spectrogram and the phase difference.

Output

12.5.8 DEMO_NEXTFASTFFT - Next fast FFT number


This demo shows the behaviour of the nextfastfft function.
12.5. ASPECTS OF PARTICULAR FUNCTIONS 321

Figure 12.36: Keep middle frequencies (band-pass)


This figure shows the symbol (top plot, only the positive frequencies are displayed), the input random signal (bottom)
and the output signal (middle).

Figure 12.37: Synthetic signal


Compare this to the pictures in reference 2 and 3. In the first two figures a synthetic signal is analyzed. It consists of
a sinusoid, a small Delta peak, a periodic triangular function and a Gaussian. In the time-invariant version in the first
part the periodicity of the sinusoid can be nicely seen also in the phase coefficients. Also the points of discontinuities
can be seen as asymptotic lines approached by parabolic shapes. In the third part both properties, periodicity and
discontinuities can be nicely seen. A comparison to the spectogram shows that the rectangular part in the middle of the
signal can be seen by the phase plot, but not by the spectogram.
In the frequency-invariant version, the fundamental frequency of the sinusoid can still be guessed as the position of an
horizontal asymptotic line.

Output

ans =

1.007891912889226
322 CHAPTER 12. LTFAT - DEMOS

Figure 12.38: Synthetic signal, thresholded.


This figure shows the same as Figure 1, except that values with low magnitude has been removed.

Figure 12.39: Speech signal.


The figure shows a part of the ’linus’ signal. The fundamental frequency of the speaker can be nicely seen.

12.5.9 DEMO_FILTERBANKS - CQT, ERBLET and AUDLET filterbanks


This demo shows CQT (Constant Quality Transform), ERBLET (Equivalent Rectangular Bandwidth -let
transform), and AUDLET (Auditory -let) representations acting as filterbanks with high and low redun-
dancies. Note that ERBLET and AUDLET are similar concepts. The main difference is that ERBlet uses
only the perceptual ERB scale while AUDlet allows for various perceptual scales like Bark or Mel scales.
In short, ERBFILTERS is a wrapper of AUDFILTERS for the ERB scale. Filterbanks are build such that
the painless condition is always satisfied. Real input signal and filters covering only the positive frequency
range are used. The redundancy is calculated as a ratio of the number of (complex) coefficients and the
input length times two to account for the storage requirements of complex numbers.

∙ 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

Figure 12.40: Original spectrogram


This figure shows the target spectrogram of an excerpt of the gspi signal

Figure 12.41: Phase difference


This figure shows a difference between the original phase and the reconstructed using 100 iterations of a Fast Griffin-
Lim algorithm. Note: The figure in the LTFAT 2.0 paper differs slightly because it is genarated using 1000 iterations.

∙ 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

ERBLET high redundancy 133.33, low redundany 2.85.


CQT high redundancy 50.91, low redundany 2.02.
BARKLET redundancy 6.09
MELLET redundancy 7.27
324 CHAPTER 12. LTFAT - DEMOS

Figure 12.42: Benchmark of the FFT routine


The figure shows the sizes returned by the nextfastfft function compared to using nextpow2. As can be seen, the
nextfastfft approach gives FFT sizes that are much closer to the input size.

Figure 12.43: Efficiency of the table


The figure show the highest output/input ratio for varying input sizes. As can be seen, the efficiency is better for larger
input values, where the output size is at most a few percent larger than the input size.

12.6 Auditory scales and filters


12.6.1 DEMO_AUDSCALES - Plot of the different auditory scales
This demos generates a simple figure that shows the behaviour of the different audiory scales in the fre-
quency range from 0 to 8000 Hz.

Output

Type "help demo_audscales" to see a description of how this demo works.


12.6. AUDITORY SCALES AND FILTERS 325

Figure 12.44: ERBLET representations


The high-redundany plot (top) consists of 400 channels (~9 filters per ERB) and low-redundany plot (bottom) consists
of 44 channels (1 filter per ERB).

Figure 12.45: CQT representations


Both representations consist of 280 channels (32 channels per octave, frequency range 50Hz-20kHz). The high-
redundany represention is on the top and the low-redundancy repr. is on the bottom.

12.6.2 DEMO_AUDITORYFILTERBANK - Construct an auditory filterbank

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

Figure 12.46: AUDLET representations


The first representation consists of 72 channels BARKlet FB (3 filters per Bark in the frequency range 100Hz-16kHz
using fractional subsampling. The second representation consists of 40 channels MELlet FB using uniform subsampling
and triangular windows.

Figure 12.47: Auditory scales


The figure shows the behaviour of the audiory scales on a normalized frequency plot.

Output

Frame bound ratio for gammatone filterbank, should be close to 1 if the filters are ch

ans =

1.598850055103133

Relative error in reconstruction, should be close to zero.

ans =
12.6. AUDITORY SCALES AND FILTERS 327

Figure 12.48: Classic spectrogram


A classic spectrogram of the spoken sentense. The dynamic range has been set to 50 dB, to highlight the most important
features.

Figure 12.49: Auditory filterbank representation


Auditory filterbank representation of the spoken sentense using gammatone filters on an Erb scale. The dynamic range
has been set to 50 dB, to highlight the most important features.

6.351688463338187e-05

Relative error in interative reconstruction, should be close to zero.

ans =

1.883372347722060e-10
328 CHAPTER 12. LTFAT - DEMOS

12.6.3 DEMO_WFBT - Auditory filterbanks built using filterbank tree structures


This demo shows two specific constructions of wavelet filterbank trees using several M-band filterbanks
with possibly different M (making the thee non-homogenous) in order to approximate auditory frequency
bands and a musical scale respectively. Both wavelet trees produce perfectly reconstructable non-redundant
representations.
The constructions are the following:

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.50: Frequency responses of the auditory filterbank.


Both axes are in logarithmic scale.

Figure 12.51: TF plot of the test signal using the auditory filterbank.
12.6. AUDITORY SCALES AND FILTERS 329

Figure 12.52: Frequency responses of the musical filterbank.


Both axes are in logarithmic scale.

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

The reconstruction should be close to zero:

ans =

8.871444670941919e-14
330 CHAPTER 12. LTFAT - DEMOS

12.7 Block-processing demos


12.7.1 DEMO_BLOCKPROC_BASICLOOP - Basic real-time audio manipulation
Usage
demo_blockproc_basicloop(’gspi.wav’)

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:

demo_blockproc_basicloop(’gspi.wav’) to play gspi.wav (any wav file will do).


demo_blockproc_basicloop(’dialog’) to choose the wav file via file chooser dialog GUI.
demo_blockproc_basicloop(f,’fs’,fs) to play from a column vector f using sampling freq
demo_blockproc_basicloop(’playrec’) to record from a mic and play simultaneously.

Avalable input and output devices can be listed by |blockdevices|.


Particular device can be chosen by passing additional key-value pair ’devid’,devid.
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

12.7.2 DEMO_BLOCKPROC_PARAMEQUALIZER - Real-time equalizer demon-


stration
Usage
demo_blockproc_paramequalizer(’gspi.wav’)

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:

demo_blockproc_paramequalizer(’gspi.wav’) to play gspi.wav (any wav file will do).


demo_blockproc_paramequalizer(’dialog’) to choose the wav file via file chooser dialog
demo_blockproc_paramequalizer(f,’fs’,fs) to play from a column vector f using sampling
demo_blockproc_paramequalizer(’playrec’) to record from a mic and play simultaneously.

Avalable input and output devices can be listed by |blockdevices|.


Particular device can be chosen by passing additional key-value pair ’devid’,devid.
12.7. BLOCK-PROCESSING DEMOS 331

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

12.7.3 DEMO_BLOCKPROC_DENOISING - Variable coefficients thresholding


Usage
demo_blockproc_denoising(’gspi.wav’)

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:

demo_blockproc_denoising(’gspi.wav’) to play gspi.wav (any wav file will do).


demo_blockproc_denoising(’dialog’) to choose the wav file via file chooser dialog GUI.
demo_blockproc_denoising(f,’fs’,fs) to play from a column vector f using sampling freq
demo_blockproc_denoising(’playrec’) to record from a mic and play simultaneously.

Avalable input and output devices can be listed by |blockdevices|.


Particular device can be chosen by passing additional key-value pair ’devid’,devid.
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

12.7.4 DEMO_BLOCKPROC_SLIDINGSGRAM - Basic real-time rolling spec-


trogram visualization
Usage
demo_blockproc_slidingsgram(’gspi.wav’)

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_slidingsgram(’gspi.wav’) to play gspi.wav (any wav file will do).


demo_blockproc_slidingsgram(’dialog’) to choose the wav file via file chooser dialog G
demo_blockproc_slidingsgram(f,’fs’,fs) to play from a column vector f using sampling f
demo_blockproc_slidingsgram(’playrec’) to record from a mic and play simultaneously.

Avalable input and output devices can be listed by |blockdevices|.


Particular device can be chosen by passing additional key-value pair ’devid’,devid.
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
332 CHAPTER 12. LTFAT - DEMOS

12.7.5 DEMO_BLOCKPROC_SLIDINGCQT - Basic real-time rolling CQT-spectrogram


visualization
Usage

demo_blockproc_slidingcqt(’gspi.wav’)

Description

For additional help call demo_blockproc_slidingcqt without arguments.


This demo shows a simple rolling CQT-spectrogram of whatever is specified in source.

Output

DEMO_BLOCKPROC_SLIDINGCQT:
To run the demo, use one of the following:

demo_blockproc_slidingcqt(’gspi.wav’) to play gspi.wav (any wav file will do).


demo_blockproc_slidingcqt(’dialog’) to choose the wav file via file chooser dialog GUI
demo_blockproc_slidingcqt(f,’fs’,fs) to play from a column vector f using sampling fre
demo_blockproc_slidingcqt(’playrec’) to record from a mic and play simultaneously.

Avalable input and output devices can be listed by |blockdevices|.


Particular device can be chosen by passing additional key-value pair ’devid’,devid.
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

12.7.6 DEMO_BLOCKPROC_SLIDINGERBLETS - Basic real-time rolling erblet-


spectrogram visualization
Usage

demo_blockproc_slidingerblets(’gspi.wav’)

Description

For additional help call demo_blockproc_slidingerblets without arguments.


This demo shows a simple rolling erblet-spectrogram of whatever is specified in source.

Output

DEMO_BLOCKPROC_SLIDINGERBLETS:
To run the demo, use one of the following:

demo_blockproc_slidingerblets(’gspi.wav’) to play gspi.wav (any wav file will do).


demo_blockproc_slidingerblets(’dialog’) to choose the wav file via file chooser dialog
demo_blockproc_slidingerblets(f,’fs’,fs) to play from a column vector f using sampling
demo_blockproc_slidingerblets(’playrec’) to record from a mic and play simultaneously.

Avalable input and output devices can be listed by |blockdevices|.


Particular device can be chosen by passing additional key-value pair ’devid’,devid.
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
12.7. BLOCK-PROCESSING DEMOS 333

12.7.7 DEMO_BLOCKPROC_DGTEQUALIZER - Real-time audio manipulation


in the transform domain
Usage

demo_blockproc_dgtequalizer(’gspi.wav’)

Description

For additional help call demo_blockproc_dgtequalizer without arguments.


This script demonstrates a real-time Gabor coefficient manipulation. Frequency bands of Gabor coeffi-
cients are multiplied (weighted) by values taken from sliders having a similar effect as a octave equalizer.
The shown spectrogram is a result of a re-analysis of the synthetized block to show a frequency content of
what is actually played.

Output

DEMO_BLOCKPROC_DGTEQUALIZER:
To run the demo, use one of the following:

demo_blockproc_dgtequalizer(’gspi.wav’) to play gspi.wav (any wav file will do).


demo_blockproc_dgtequalizer(’dialog’) to choose the wav file via file chooser dialog G
demo_blockproc_dgtequalizer(f,’fs’,fs) to play from a column vector f using sampling f
demo_blockproc_dgtequalizer(’playrec’) to record from a mic and play simultaneously.

Avalable input and output devices can be listed by |blockdevices|.


Particular device can be chosen by passing additional key-value pair ’devid’,devid.
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

12.7.8 DEMO_BLOCKPROC_EFFECTS - Various vocoder effects using DGT


Usage

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:

1) Robotization effect: Achieved by doing DGT reconstruction using absolute values


of coefficients only.
2) Whisperization effect: Achieved by randomizing phase of DGT coefficients.
3) Pitch shifting effect: Achieved by stretching/compressing coefficients along fre-
quency axis.
4) Audio morphing: Input is morphed with a background sound such that the phase
of DGT coefficients is substituted by phase of DGT coefficients of the background
signal. File beat.wav (at 44,1kHz) (any sound will do) is expected to be in the search
path, oherwise the effect will be disabled.

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:

demo_blockproc_effects(’gspi.wav’) to play gspi.wav (any wav file will do).


demo_blockproc_effects(’dialog’) to choose the wav file via file chooser dialog GUI.
demo_blockproc_effects(f,’fs’,fs) to play from a column vector f using sampling freque
demo_blockproc_effects(’playrec’) to record from a mic and play simultaneously.

Avalable input and output devices can be listed by |blockdevices|.


Particular device can be chosen by passing additional key-value pair ’devid’,devid.
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
Bibliography

[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.

[9] F. Auger, E. Chassande-Mottin, and P. Flandrin. On phase-magnitude relationships in the short-time


fourier transform. Signal Processing Letters, IEEE, 19(5):267–270, May 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.

[14] H. Bölcskei, H. G. Feichtinger, K. Gröchenig, and F. Hlawatsch. Discrete-time Wilson expansions.


In Proc. IEEE-SP 1996 Int. Sympos. Time-Frequency Time-Scale Analysis, june 1996.

[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

[17] H. Bölcskei, F. Hlawatsch, and H. G. Feichtinger. Frame-theoretic analysis of oversampled filter


banks. Signal Processing, IEEE Transactions on, 46(12):3256–3268, 2002.

[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.

[22] E. Chassande-Mottin, I. Daubechies, F. Auger, and P. Flandrin. Differential reassignment. Signal


Processing Letters, IEEE, 4(10):293–294, 1997.

[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.

[31] H. G. Feichtinger, M. Hazewinkel, N. Kaiblinger, E. Matusiak, and M. Neuhauser. Metaplectic


operators on cn . The Quarterly Journal of Mathematics, 59(1):15–28, 2008.

[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.

[40] K. Gröchenig. Foundations of Time-Frequency Analysis. Birkhäuser, 2001.

[41] A. Grossmann, M. Holschneider, R. Kronland-Martinet, and J. Morlet. Detection of abrupt changes


in sound signals with the help of wavelet transforms. Inverse Problem, pages 281–306, 1987.

[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.

[46] M. Holschneider, R. Kronland-Martinet, J. Morlet, and P. Tchamitchian. A real-time algorithm for


signal analysis with the help of the wavelet transform. In Wavelets. Time-Frequency Methods and
Phase Space, volume 1, page 286, 1989.

[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.

You might also like