Dig
ital S
ign
al a
nd
Imag
e P
rocessin
gu
sing
MA
TLA
B®
Géra
rd B
lan
ch
et
Mau
rice C
harb
it
www.iste.co.uk Z(7ib8e8-CBGEBJ(
Volume 2 of the second edition of the fully revised and updatedDigital Signal and Image Processing using MATLAB® isessentially a collection of examples and exercises which alsopresents applications of digital signal- or image processing, andtechniques which were not touched upon in the previous volume.It will be of particular benefit to readers who already possess agood knowledge of MATLAB®, a command of the fundamentalelements of digital signal processing and who are familiar withboth the fundamentals of continuous-spectrum spectral analysisand who have a certain mathematical knowledge concerningHilbert spaces.
More than 200 programs and functions are provided in theMATLAB® language, with useful comments and guidance, toenable numerical experiments to be carried out, thus allowingreaders to develop a deeper understanding of both thetheoretical and practical aspects of this subject.
Gérard Blanchet is Professor at Ecole Nationale Supérieure desTélécommunications, Paris, France. In addition to his research,teaching and consulting activities, he is the author of severalbooks on automatic control systems, digital signal processingand computer architecture. He also develops tools andmethodologies to improve knowledge acquisition in variousfields.
Maurice Charbit is Professor at Ecole Nationale Supérieure desTélécommunications, Paris, France, where he teaches severalcourses in signal processing and digital communications. Hisresearch interests include statistics, speech and imageprocessing.
Digital Signaland Image Processing
using MATLAB®
2nd Edition Revised and UpdatedVolume 2 – Advances and Applications
The Deterministic Case
Gérard Blanchet and Maurice Charbit
DIGITAL SIGNAL AND IMAGE PROCESSING SERIES
W641-Blanchet.qxp_Layout 1 29/12/2014 17:06 Page 1
Digital Signal and Image Processing using MATLAB®
Revised and Updated 2nd Edition
Digital Signal and Image Processing using MATLAB®
Volume 2 Advances and Applications:
The Deterministic Case
Gérard Blanchet Maurice Charbit
First published 2015 in Great Britain and the United States by ISTE Ltd and John Wiley & Sons, Inc.
Apart from any fair dealing for the purposes of research or private study, or criticism or review, as permitted under the Copyright, Designs and Patents Act 1988, this publication may only be reproduced, stored or transmitted, in any form or by any means, with the prior permission in writing of the publishers, or in the case of reprographic reproduction in accordance with the terms and licenses issued by the CLA. Enquiries concerning reproduction outside these terms should be sent to the publishers at the undermentioned address:
ISTE Ltd John Wiley & Sons, Inc. 27-37 St George’s Road 111 River Street London SW19 4EU Hoboken, NJ 07030 UK USA
www.iste.co.uk www.wiley.com
© ISTE Ltd 2015 The rights of Gérard Blanchet and Maurice Charbit to be identified as the authors of this work have been asserted by them in accordance with the Copyright, Designs and Patents Act 1988.
Library of Congress Control Number: 2014958256 British Library Cataloguing-in-Publication Data A CIP record for this book is available from the British Library ISBN 978-1-84821-641-9
MATLAB®is a trademark of The MathWorks, Inc. and is used with permission. The MathWorks does not warrant the accuracy of the text or exercises in this book. This book’s use or discussion of MATLAB®
software does not constitute endorsement or sponsorship by The MathWorks of a particular pedagogical approach or use of the MATLAB® software.
Contents
Foreword ix
Notations and Abbreviations xi
Chapter 1 Recap on Digital Signal Processing 11.1 The sampling theorem . . . . . . . . . . . . . . . . . . . . . . . 21.2 Spectral contents . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2.1 Discrete-time Fourier transform (DTFT) . . . . . . . . . 71.2.2 Discrete Fourier transform (DFT) . . . . . . . . . . . . 8
1.3 Case of random signals . . . . . . . . . . . . . . . . . . . . . . . 101.4 Example of the Dual Tone Multi-Frequency (DTMF) . . . . . . 11
Chapter 2 Additional Information About Filtering 152.1 Filter implementation . . . . . . . . . . . . . . . . . . . . . . . 15
2.1.1 Examples of filter structures . . . . . . . . . . . . . . . . 162.1.2 Distributing the calculation load in an FIR filter . . . . 202.1.3 FIR block filtering . . . . . . . . . . . . . . . . . . . . . 212.1.4 FFT filtering . . . . . . . . . . . . . . . . . . . . . . . . 23
2.2 Filter banks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292.2.1 Decimation and expansion . . . . . . . . . . . . . . . . . 302.2.2 Filter banks . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.3 Ripple control . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422.3.1 Principle . . . . . . . . . . . . . . . . . . . . . . . . . . 422.3.2 Programming . . . . . . . . . . . . . . . . . . . . . . . . 44
Chapter 3 Image Processing 513.1 A little geometry . . . . . . . . . . . . . . . . . . . . . . . . . . 51
3.1.1 3D object . . . . . . . . . . . . . . . . . . . . . . . . . . 513.1.2 Calibration of cameras . . . . . . . . . . . . . . . . . . . 53
3.2 Pyramidal decompositions . . . . . . . . . . . . . . . . . . . . . 623.2.1 Pyramidal decomposition given by Burt and
Adelson . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
vi Digital Signal and Image Processing using MATLAB®
3.2.2 Pyramidal decomposition using a Haar tranformation . 653.2.3 Stepwise decomposition (lifting scheme) . . . . . . . . . 66
Chapter 4 Numerical Calculus and Simulation 714.1 Simulation of continuous-time systems . . . . . . . . . . . . . . 71
4.1.1 Simulation by approximation . . . . . . . . . . . . . . . 714.1.2 Exact model simulation . . . . . . . . . . . . . . . . . . 72
4.2 Solving of ordinary differential equations(ODEs) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 764.2.1 Conversion from continuous to discrete time . . . . . . . 764.2.2 Linear case, continuous-time solution . . . . . . . . . . . 784.2.3 Remarks on the Runge–Kutta methods . . . . . . . . . 81
4.3 Systems of equations and zero-seeking . . . . . . . . . . . . . . 884.3.1 Zeros of a function using the Newton method . . . . . . 884.3.2 Roots of a polynomial with the Newton–Raphson method 894.3.3 Systems of nonlinear equations . . . . . . . . . . . . . . 90
4.4 Interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 914.4.1 Thiele’s interpolation . . . . . . . . . . . . . . . . . . . 924.4.2 Another decomposition in continuous fractions . . . . . 954.4.3 Natural cubic splines . . . . . . . . . . . . . . . . . . . . 96
4.5 Solving of linear systems . . . . . . . . . . . . . . . . . . . . . . 1004.5.1 Jacobi method . . . . . . . . . . . . . . . . . . . . . . . 1004.5.2 Relaxation method . . . . . . . . . . . . . . . . . . . . . 1014.5.3 Cholesky factorization . . . . . . . . . . . . . . . . . . . 102
Chapter 5 Speech Processing 1055.1 A speech signal model . . . . . . . . . . . . . . . . . . . . . . . 105
5.1.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . 1055.1.2 A typology of vocal sounds . . . . . . . . . . . . . . . . 1065.1.3 The AR model of speech production . . . . . . . . . . . 1075.1.4 Compressing a speech signal . . . . . . . . . . . . . . . . 113
5.2 Dynamic Time Warping . . . . . . . . . . . . . . . . . . . . . . 1165.2.1 The DTW algorithm . . . . . . . . . . . . . . . . . . . . 1175.2.2 Examples of pathfinding rules . . . . . . . . . . . . . . . 1185.2.3 Cepstral coefficients . . . . . . . . . . . . . . . . . . . . 119
5.3 Modifying the duration of an audio signal . . . . . . . . . . . . 1205.3.1 PSOLA . . . . . . . . . . . . . . . . . . . . . . . . . . . 1215.3.2 Phase vocoder . . . . . . . . . . . . . . . . . . . . . . . 123
5.4 Eliminating the impulse noise . . . . . . . . . . . . . . . . . . . 1245.4.1 The signal model . . . . . . . . . . . . . . . . . . . . . . 1255.4.2 Click detection . . . . . . . . . . . . . . . . . . . . . . . 1265.4.3 Restoration . . . . . . . . . . . . . . . . . . . . . . . . . 128
Contents vii
Chapter 6 Selected Topics 1316.1 Tracking the cardiac rhythm of the fetus . . . . . . . . . . . . . 131
6.1.1 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . 1316.1.2 Separating the EKG signals . . . . . . . . . . . . . . . . 1326.1.3 Estimating cardiac rhythms . . . . . . . . . . . . . . . . 136
6.2 Extracting the contour of a coin . . . . . . . . . . . . . . . . . 1426.3 Constrained optimization and Lagrange
multipliers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1466.3.1 Equality-constrained optimization . . . . . . . . . . . . 1466.3.2 Quadratic problem with linear inequality constraints . . 1496.3.3 Portfolio optimization . . . . . . . . . . . . . . . . . . . 153
6.4 Principal Component Analysis (PCA) . . . . . . . . . . . . . . 1636.4.1 Determining the principal components . . . . . . . . . . 1646.4.2 2-Dimension PCA . . . . . . . . . . . . . . . . . . . . . 1686.4.3 Linear Discriminant Analysis . . . . . . . . . . . . . . . 170
6.5 GPS positioning . . . . . . . . . . . . . . . . . . . . . . . . . . 1756.6 The Viterbi algorithm . . . . . . . . . . . . . . . . . . . . . . . 178
6.6.1 Convolutional non-recursive encoder . . . . . . . . . . . 1796.6.2 Decoding and hard decision . . . . . . . . . . . . . . . . 181
Chapter 7 Hints and Solutions 187H1 Reminders on digital signal-processing . . . . . . . . . . . . . . 187H2 Additional information on filtering . . . . . . . . . . . . . . . . 189H3 Image Processing . . . . . . . . . . . . . . . . . . . . . . . . . . 194H4 Numerical calculus . . . . . . . . . . . . . . . . . . . . . . . . . 197H5 Speech processing . . . . . . . . . . . . . . . . . . . . . . . . . . 215H6 Selected topics . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
Chapter 8 Appendix 243A1 A few properties of a matrix . . . . . . . . . . . . . . . . . . . . 243A2 A few relations for matrices . . . . . . . . . . . . . . . . . . . . 246
Bibliography 247
Index 251
Foreword
This book represents the continuation to Digital Signal and Image Process-ing: Fundamentals. It is assumed that the reader possesses a good knowledgeof the programming language MATLAB® and a command of the fundamen-tal elements of digital signal processing: the usual transforms (the DiscreteTime Fourier Transform (DTFT), the Discrete Fourier Transform and thez-Transform), the properties of deterministic and random signals, and digi-tal filtering. Readers will also need to be familiar with the fundamentals ofcontinuous-spectrum spectral analysis and have a certain amount of mathe-matical knowledge concerning vector spaces.
In order to prevent the reading becoming a penance, we will offer a fewreminders of the basics wherever necessary. This book is essentially a collectionof examples, exercises and case studies. It also presents applications of digitalsignal- or image processing, and techniques which were not touched upon inthe previous volume.
Recap on digital signal processing
This section is devoted to the definitions and properties of the fundamentaltransforms used in digital signal processing: Fourier transform, discrete timeFourier transform and discrete Fourier transform. It concludes with a classicexample which enables us to put some known results into practice.
Filter implementation
This section deals with the structures of filters, the introduction of parallelisminto the filtering operations (block filtering and filter banks) and, by way of anexample, the Parks–McClellan method for FIR filter synthesis (finite impulseresponse).
Image processing
The section given over to images offers a few geometrical concepts relating tothe representation of 3D objects in a 2D space. Therein, we deal with problems
x Digital Signal and Image Processing using MATLAB®
of calibration of cameras. In addition, image compression is also discussed, withthe use of examples (pyramidal decompositions, lifting scheme).
Digital calculus and simulation
This section deals with the algorithms used in most domains in digital process-ing, and therefore far beyond mere signal processing. It only touches on thedomain using a few examples of methods applied to problems of simulation,resolution of differential equations, zero-seeking, interpolation and iterativemethods for solving linear systems.
Speech processing
After a brief introduction to speech production, we will discuss the represen-tation of a speech signal by an autoregressive model, and its application tocompression. Next we will give the descriptions of the techniques widely usedin this field (Dynamic Time Warping and PSOLA) and, finally, an example ofapplication with “decrackling” for audio recordings.
Selected topics
This last chapter presents case studies that go a little further in depth thanthe examples described in the previous sections. “Tracking the cardiac rhythmof the fetus” and “Extracting the contour of a coin” are classic examples ofthe application of the least squares method. Principal component analysis andlinear discriminant analysis are basic methods for the classification of objects(in a very broad sense).
The section devoted to optimization under constraints could have been partof the section on numerical methods. The method of Lagrange multipliers isencountered in a multitude of applications. In terms of applications, we presentthe case of optimization of a stock portfolio.
We conclude with the example of the Viterbi algorithm for the hard de-coding of convolutional codes. This algorithm is, in fact, a particular case forsearching for the shortest possible path in a lattice.
Notations andAbbreviations
∅ empty set∑k,n =
∑k
∑n
rectT (t) =
{1 when |t| < T/20 otherwise
sinc(x) = sin(πx)πx
1(x ∈ A) =
{1 when x ∈ A
0 otherwise(indicator function of A)
(a, b] = {x : a < x ≤ b}
δ(t)
{Dirac distribution when t ∈ RKronecker symbol when t ∈ Z
Re(z) real part of zIm(z) imaginary part of z
⌊x⌋ integer part of xi or j =
√−1
x(t) ⇌ X(f) Fourier transform(x ⋆ y)(t) continuous time convolution
=∫R x(u)y(t− u)du
(x ⋆ y)(t) discrete time convolution=
∑u∈Z x(u)y(t− u) =
∑u∈Z x(t− u)y(u)
y(n)(t) = dny(t)dtn
,nth order derivative
xii Digital Signal and Image Processing using MATLAB®
x or x vector x
IN (N ×N)-dimension identity matrixA∗ complex conjugate of A
AT transpose of A
AH transpose-conjugate of A
A−1 inverse matrix of A
A# pseudo-inverse matrix of A
P {X ∈ A} probability that X ∈ A
E {X} expectation value of XXc = X − E {X} zero-mean random variable
var {X} = E{
|Xc|2}
variance of XE {X|Y } conditional expectation of X given Y
ADC Analog to Digital ConverterADPCM Adaptive Differential PCM
AR AutoregressiveARMA AR and MA
BER Bit Error Ratebps Bits per secondcdf Cumulative distribution functionCF Clipping Factor
CZT Causal z-TransformDAC Digital to Analog ConverterDCT Discrete Cosine Transform
d.e./de Difference equationDFT Discrete Fourier Transform
DTFT Discrete Time Fourier TransformDTMF Dual Tone Multi-Frequency
dsp Digital signal processing/processore.s.d./esd Energy spectral density
FIR Finite Impulse ResponseFFT Fast Fourier TransformFT Continuous Time Fourier Transform
Notations and Abbreviations xiii
IDFT Inverse Discrete Fourier Transformi.i.d./iid Independent and Identically Distributed
IIR Infinite Impulse ResponseISI InterSymbol Interference
LDA Linear discriminant analysislms Least mean squaresMA Moving Average
MAC Multiplication ACcumulationOTF Optical Transfer FunctionPAM Pulse Amplitude ModulationPCA Principal Component Analysisp.d. Probability Distributionppi Points per Inch
p.s.d./PSD Power Spectral DensityPSF Point Spread FunctionPSK Phase Shift KeyingQAM Quadrature Amplitude Modulation
rls Recursive least squaresrms Root mean square
r.p./rp Random processSNR Signal to Noise Ratio
r.v./rv Random variableSTFT Short Term Fourier Transform
TF Transfer FunctionWSS Wide (Weak) Sense Stationary (Second Order) ProcessZOH Zero-Order HoldZT z-Transform