70
Chapter 5 Chapter 5 Finite-Length Discrete Transforms Transforms 清大電機系林嘉文 [email protected] 03 5731152 © The McGraw-Hill Companies, Inc., 2007 Original PowerPoint slides prepared by S. K. Mitra 4-1-1 03-5731152

Chapter 5Chapter 5 Finite-Length Discrete Transformscwlin/courses/dsp/notes/ch5_Mitra...DFT Computation Using MATLABDFT Computation Using MATLAB • The functions to compute the DFT

Embed Size (px)

Citation preview

  • Chapter 5Chapter 5

    Finite-Length Discrete TransformsTransforms

    [email protected] 5731152

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-1

    03-5731152

  • Digital Fourier TransformDigital Fourier Transform Definition - The simplest relation between a length-N e t o e s p est e at o bet ee a e gt

    sequence x[n], defined for 0 n N 1, and its DTFT X(ej) is obtained by uniformly sampling X(ej) on the -axis between 0 < 2 at k = 2k/ N, 0 k N 1

    From the definition of the DTFT we thus have

    0 k N 1

    Note: X[k] is also a length-N sequence in the frequency domain

    The sequence X[k] is called the Discrete Fourier Transform (DFT) of the sequence x[n]

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-2

  • Digital Fourier TransformDigital Fourier Transform Using the notation WN = ej2/N the DFT is usually Us g t e otat o N e t e s usua y

    expressed as:

    The Inverse Discrete Fourier Transform (IDFT) is ( )given by

    To verify the above expression we multiply both sides of the above equation by and sum the result from n = 0 to n = N 1

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-3

  • Digital Fourier TransformDigital Fourier Transform This results in:s esu ts

    Making use of the identity

    we observe the RHS of the last equation is equal to X[l] Hence

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-4

  • Digital Fourier TransformDigital Fourier Transform Example - Consider the length-N sequencea p e Co s de t e e gt seque ce

    Its N-point DFT is given by

    0 k N 1

    Example - Consider the length-N sequence

    , 0 k N 1

    Example - Consider the length-N sequence

    Its N-point DFT is given by

    0 k N 1

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-5

    , 0 k N 1

  • Digital Fourier TransformDigital Fourier Transform Example - Consider the length-N sequence defined for

    0 n N 1g[n] = cos(2rn/ N), 0 r N 1

    Using a trigonometric identity we can write

    The N-point DFT of g[n] is thus given by

    0 k N 1

    Making use of the identity

    0 k N 1

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-6

    We get , 0 k N 1

  • Matrix RelationMatrix Relation The DFT samples defined by

    can be expressed in matrix form ascan be expressed in matrix form asX = DNx

    whereX = [X[0] X[1] ..... X[N 1]]Tx = [x[0] x[1] ..... x[N 1]]T

    and DN is the N N DFT matrix given by

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-7

  • Matrix RelationMatrix Relation Likewise the IDFT relation given by Likewise, the IDFT relation given by

    can be expressed in matrix form as

    where is the IDFT matrixwhere is the IDFT matrix

    Note:

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-8

  • DFT Computation Using MATLABDFT Computation Using MATLAB The functions to compute the DFT and the IDFT are fft and

    ifft These functions make use of FFT algorithms which are

    computationally highly efficient compared to the direct computation

    The DFT and DTFT of the following function is shown below The DFT and DTFT of the following function is shown below

    x[n] = cos(6n/16), 0 n 15

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-9

  • DTFT from DFT by InterpolationDTFT from DFT by Interpolation The DFT X[k] of a length-N sequence x[n] is simply the freq.

    samples of its DTFT X(ej) evaluated at N uniformly spaced frequency points = k = 2k/N, 0 k N 1

    Compared to the direct computation, these functions are computationally highly efficient due to the use of FFTGi th N i t DFT X[k] f l th N [ ] it Given the N-point DFT X[k] of a length-N sequence x[n], its DTFT X(ej) can be uniquely determined from X[k]

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-10

  • DTFT from DFT by InterpolationDTFT from DFT by Interpolation To develop a compact expression for the sum S, let

    r = ej(2k/N)

    Then

    Or, equivalentlyS rS = (1 r)S =1 rNS rS = (1 r)S =1 r

    Hence

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-11

  • DTFT from DFT by InterpolationDTFT from DFT by Interpolation Therefore

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-12

  • Sampling the DTFTSampling the DTFT Consider a sequence x[n] with a DTFT X(ej) We sample X(ej) at N equally spaced points k = 2k/N, 0

    k N 1 developing the N frequency samples These N frequency samples can be considered as an N-point

    DFT Y[k] whose N-point IDFT is a length-N sequence y[n] Now

    Taking IDFT of Y[k] yields

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-13

  • Sampling the DTFTSampling the DTFT That is

    Making use of the identity

    we arrive at the desired relationwe arrive at the desired relation

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-14

  • Sampling the DTFTSampling the DTFT Thus y[n] is obtained from x[n] by adding an infinite number

    of shifted replicas of x[n], with each replica shifted by an integer multiple of N sampling instants, and observing the

    l f th i t lsum only for the interval To apply

    t fi it l th th t th lto finite-length sequences, we assume that the samples outside the specified range are zerosThus if x[n] is a length M sequence with M N then y[n] = Thus if x[n] is a length-M sequence with M N then y[n] = x[n] for 0 n N 1

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-15

  • Sampling the DTFTSampling the DTFT Example Let {x[n]} = {0 1 2 3 4 5} By sampling its DTFT X(ej) at k = 2k/4, 0 k 3 and then

    applying a 4-point IDFT to these samples, we arrive at the sequence y[n] given by

    y[n] = x[n] + x[n + 4] + x[n 4] 0 n 3i.e.,

    {y[n]} = {4 6 2 3} {x[n]} cannot be recovered from {y[n]}

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-16

  • Numerical Computation of the DTFT Using DFT

    A practical approach to the numerical computation of the A practical approach to the numerical computation of the DTFT of a finite-length sequence

    Let X(ej) be the DTFT of a length-N sequence x[n]Let X(e ) be the DTFT of a length N sequence x[n] We wish to evaluate X(ej) at a dense grid of frequencies k = 2k/M, 0 k M 1, where M >> N:k , ,

    Define a new sequence

    Then

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-17

  • Numerical Computation of the DTFT Using DFT

    Thus X(ej) is essentially an M-point DFT X [k] of the Thus X(ej ) is essentially an M-point DFT Xe[k] of the length-M sequence xe[n]

    The DFT Xe[k] can be computed very efficiently using theThe DFT Xe[k] can be computed very efficiently using the FFT algorithm if M is an integer power of 2

    The function freqz employs this approach to evaluate the q p y ppfrequency response at a prescribed set of frequencies of a DTFT expressed as a rational function in ej

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-18

  • DFT PropertiesDFT Properties Like the DTFT, the DFT also satisfies a number of

    properties that are useful in signal processing applications Some of these properties are essentially identical to those

    of the DTFT, while some others are somewhat different

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-19x[n] is a complex sequence

  • Symmetry Relations of DFTSymmetry Relations of DFT

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-20x[n] is a real sequence

  • General Properties of DFTGeneral Properties of DFT

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-21

  • Circular Shift of a SequenceCircular Shift of a Sequence This property is analogous to the time-shifting property of

    the DTFT, but with a subtle difference Consider length-N sequences defined for 0 n N 1.

    Sample values of such sequences are equal to zero for values of n < 0 and n NIf [ ] i h th f bit i t If x[n] is such a sequence, then for any arbitrary integer , the shifted sequence

    x [n] = x[n n ]x1[n] = x[n no]is no longer defined for the range 0 n N 1We thus need to define another type of a shift that will We thus need to define another type of a shift that will always keep the shifted sequence in the range 0 n N 1

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-22

  • Circular Shift of a SequenceCircular Shift of a Sequence The desired shift, called the circular shift, is defined using

    a modulo operation:xc[n] = x[ n no N]

    For no > 0 (right circular shift), the above equation implies

    x[ n 1 ] x[ n 4 ]

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-23

    x[ n 1 6]= x[ n + 5 6]

    x[ n 4 6]= x[ n + 2 6]

  • Circular ConvolutionCircular Convolution This operation is analogous to linear convolution, but with a

    subtle difference Consider two length-N sequences, g[n] and h[n]. Their linear

    convolution results in a length-(2N1) sequence yL[n]:

    In computing yL[n] we assume that both length-N sequences h b dd d t t d th i l th t 2N 1have been zero-padded to extend their lengths to 2N1

    The longer form of yL[n] results from the time-reversal of the sequence h[n] and its linear shift to the rightsequence h[n] and its linear shift to the right

    The first nonzero value of yL[n] is yL[0] = g[0]h[0] , and the last nonzero value is y [2N2] = g[N1]h[N1]

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-24

    last nonzero value is yL[2N2] = g[N1]h[N1]

  • Circular ConvolutionCircular Convolution To develop a convolution-like operation resulting in a length-

    N sequence yC[n], we need to define a circular time-reversal, and then apply a circular time-shift R lti ti ll d i l l ti i Resulting operation, called a circular convolution, is defined by:

    Since the operation defined involves two length-N p gsequences, it is often referred to as an N-point circular convolution, denoted as

    The circular convolution is commutative, i.e.

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-25

  • Circular ConvolutionCircular Convolution Example - Determine the 4-point circular convolution of the

    t l th 4two length-4 sequences {g[n]} = {1 2 0 1}, {h[n]} = {2 2 1 1}

    The result is a length-4 sequence yC[n] given by

    From above, we observe

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-26

  • Circular ConvolutionCircular Convolution Likewise

    yC[1] = g[0]h[1] + g[1]h[0] + g[2]h[3] + g[3]h[2] = 7

    yC[2] = g[0]h[2] + g[1]h[1] + g[2]h[0] + g[3]h[3] = 6yC[2] g[0]h[2] g[1]h[1] g[2]h[0] g[3]h[3] 6

    yC[3] = g[0]h[3] + g[1]h[2] + g[2]h[1] + g[3]h[0] = 5

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-27

  • Circular ConvolutionCircular Convolution Example - Consider the two length-4 sequences repeated

    b l f ibelow for convenience:

    The 4-point DFT G[k] of g[n] is given byG[k] = g[0] + g[1] ej2k/4 + g[2] ej4k/4 + g[3] ej6k/4

    = 1 + 2ejk/2 + ej3k/2 , 0 k 3 Therefore G[0] = 4, G[1] = 1 j, G[2] = 2, G[3] = 1+ j Likely

    H[k] = 2 + 2ejk/2 + ejk + ej3k/2 , 0 k 3

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-28

  • Circular ConvolutionCircular Convolution The two 4-point DFTs can also be computed using the

    t i l ti i limatrix relation given earlier

    If YC[k] denotes the 4-point DFT of yC[n], YC[k] = G[k]H[k]

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-29

  • Circular ConvolutionCircular Convolution A 4-point IDFT of YC[k] yields

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-30

  • Circular ConvolutionCircular Convolution Example - Extend the two length-4 sequences to length 7 by

    di h ith th l d l iappending each with three zero-valued samples, i.e.

    We next determine the 7-point circular convolution of ge[n]and he[n]

    From the above, we can obtain y[0] ~ y[6]y[ ] y[ ] y[n] is precisely the sequence yL[n] obtained

    by a linear convolution of g[n] and h[n]

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-31

  • Circular ConvolutionCircular Convolution The N-point circular convolution can be written in matrix

    fform as

    Note: The elements of each diagonal of the matrix are equal Such a matrix is called a circulant matrix

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-32

  • Circular Convolution Using Tabular Method

    Consider the evaluation of y[n] = h[n] g[n] where {g[n]} Co s de e e a ua o o y[n] h[n] g[ ] e e {g[ ]}and {h[n]} are length-4 sequences

    First, the samples of the two sequences are multiplied using p q p gthe conventional multiplication method as shown below

    The partial products generated in the 2nd, 3rd, and 4th rows

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-33

    p p gare circularly shifted to the left as indicated above

  • Circular Convolution Using Tabular Method

    The modified table after circular shifting is shown belowe od ed tab e a te c cu a s t g s s o be o

    The samples of the sequence yC[n] are obtained by adding the 4 partial products in the column above of each sample

    yC[0] = g[0]h[0] + g[3]h[1] + g[2]h[2] + g[1]h[3] = 7yC[1] = g[1]h[0] + g[0]h[1] + g[3]h[2] + g[2]h[3] = 6yC[2] = g[2]h[0] + g[1]h[1] + g[0]h[2] + g[3]h[3] = 5

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-34

    yC[3] = g[3]h[0] + g[2]h[1] + g[1]h[2] + g[0]h[3] = 5

  • N-Point DFTs of Two Length-N Real Sequences

    Let g[n] and h[n] be two length-N real sequences with G[k] et g[ ] a d [ ] be t o e gt ea seque ces t G[ ]and H[k] denoting their respective N-point DFTs

    These two N-point DFTs can be computed efficiently using a p p y gsingle N-point DFT

    Define a complex length-N sequencex[n] = g[n] + j h[n]

    Let X[k] denote the N-point DFT of x[n]

    Note that for 0 k N 1,

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-35

  • N-Point DFTs of Two Length-N Real Sequences

    Example - We compute the 4-point DFTs of the two real a p e e co pute t e po t s o t e t o easequences g[n] and h[n] given below

    {g[n]} = {1 2 0 1}, {h[n]} = {2 2 1 1}{g[ ]} { } { [ ]} { } Then {x[n]} = {g[n]}+ j{h[n]} = {1+j2 2+j2 j 1+j} Its DFT X[k] is[ ]

    From the aboveX*[k] = [4j6 2 2 j2], X*[ 4k 4] = [4j6 j2 2 2]

    Therefore

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-36

    {G[k]} = {4 1j 2 1+j}, {H[k]} = {6 1j 0 1+j}

  • 2N-Point DFTs of a Real Sequences Using an N-Point DFT

    Let v[n] be a length-N real sequence with a 2N-point DFT V[k]et [ ] be a e gt ea seque ce t a po t [ ] Define two length-N real sequences g[n] and h[n] as follows:

    g[n] = v[2n], h[n] = v[2n +1], 0 n Ng[n] v[2n], h[n] v[2n 1], 0 n N Let G[k] and H[k] denote their respective N-point DFTs Define a length-N complex sequenceDefine a length N complex sequence

    {x[n]} = {g[n]}+ j{h[n]}with an N-point DFT X[k]with an N point DFT X[k]

    Now

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-37 That is

  • 2N-Point DFTs of a Real Sequences Using an N-Point DFT

    Example - Let us determine the 8-point DFT V[k] of the a p e et us dete e t e 8 po t [ ] o t elength-8 real sequence

    {v[n]} = {1 2 2 2 0 1 1 1}{ [ ]} { } We form two length-4 real sequences as follows

    g[n] = v[2n] = {1 2 0 1}, h[n] = v[2n +1] = {2 2 1 1}g[ ] [ ] { }, [ ] [ ] { } Now

    Substituting the values of the 4-point DFTs G[k] and H[k], we can obtain V[k]we can obtain V[k]

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-38

  • Linear Convolution Using DFTLinear Convolution Using DFT Since a DFT can be efficiently implemented using FFT S ce a ca be e c e t y p e e ted us g

    algorithms, it is of interest to develop methods for the implementation of linear convolution using the DFT

    Let g[n] and h[n] be two finite-length sequences of length N and M, respectively

    Define two length-L (L = N + M 1) sequences

    Then

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-39

  • Linear Convolution Using DFTLinear Convolution Using DFT The corresponding implementation scheme is illustrated e co espo d g p e e tat o sc e e s ust ated

    below

    We next consider the DFT-based implementation ofp

    where h[n] is a finite-length sequence of length M and x[n] is an infinite length (or a finite length sequence of length much

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-40

    g ( g q ggreater than M)

  • Overlap Add MethodOverlap-Add Method We first segment x[n], assumed to be a causal sequence

    h ith t l f lit i t t f tihere without any loss of generality, into a set of contiguous finite-length subsequences of length N each:

    wherewhere

    Thus we can writeThus we can write

    wherewhere

    Since h[n] is of length M and is of length N, ym[n] is of length

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-41

    [ ] g g ym[ ] gN + M 1

  • Overlap Add MethodOverlap-Add Method The desired linear convolution y[n] = h[n] x[n] is broken up

    i t f i fi it b f h t l th liinto a sum of infinite number of short-length linear convolutions of length N + M 1 each: ym[n] = h[n] xm[n]Consider implementing the follo ing con ol tions sing the Consider implementing the following convolutions using the DFT-based method, where now the DFTs (and the IDFT) are computed on the basis of (N + M 1) pointsare computed on the basis of (N M 1) points

    Th fi l i i h b [ ] h[ ] [ ] i The first convolution in the above sum, y0[n] = h[n] x0[n], is of length N + M 1 and is defined for 0 n N + M 2Th d h t l ti [ ] h[ ] [ ] i l f The second short convolution y1[n] = h[n] x1[n], is also of length N + M 1 but is defined for N n 3N + M 2There is an overlap of samples between these two short

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-42

    There is an overlap of samples between these two short linear convolutions

  • Overlap Add MethodOverlap-Add Method In general, there will be an overlap of M 1 samples

    b t th l f th h t l ti h[ ] [ ]between the samples of the short convolutions h[n] xr-1[n] and h[n] xm[n] for (r 1)N n rN + M 2

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-43

  • Overlap Add MethodOverlap-Add Method

    Therefore, y[n] obtained by a linear convolution of x[n] and h[n] is given by

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-44

  • Overlap Add MethodOverlap-Add Method The above procedure is called the overlap-add method

    i th lt f th h t li l ti l dsince the results of the short linear convolutions overlap and the overlapped portions are added to get the correct final resultresult

    The MATLAB function fftfilt can be used to implement the above methodabove method

    The following illustrates an example of filtering of a noise-corrupted signal using a length-3 moving average filter:p g g g g g

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-45

  • Overlap Save MethodOverlap-Save Method In implementing the overlap-add method using the DFT, we

    d t t t (N M 1) i t DFT d (N Mneed to compute two (N + M 1)-point DFTs and one (N + M1)-point IDFT for each short linear convolutionIt is possible to implement the o erall linear con ol tion b It is possible to implement the overall linear convolution by performing instead circular convolution of length shorter than (N + M 1)(N M 1)

    To this end, it is necessary to segment x[n] into overlapping blocks xm[n], keep the terms of the circular pp g m[ ], pconvolution of h[n] with that corresponds to the terms obtained by a linear convolution of h[n] and xm[n], and throw

    faway the other parts of the circular convolution

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-46

  • Overlap Save MethodOverlap-Save Method To understand the correspondence between the linear and

    i l l ti id l th 4 [ ] dcircular convolutions, consider a length-4 sequence x[n] and a length-3 sequence h[n]Let [n] denote the res lt of a linear con ol tion of [n] ith Let yL[n] denote the result of a linear convolution of x[n] with h[n]

    The six samples of y [n] are given by The six samples of yL[n] are given byyL[0] = h[0]x[0]y [1] = h[0]x[1] + h[1]x[0]yL[1] = h[0]x[1] + h[1]x[0]yL[2] = h[0]x[2] + h[1]x[1] + h[2]x[0]y [3] = h[0]x[3] + h[1]x[2] + h[2]x[1]yL[3] = h[0]x[3] + h[1]x[2] + h[2]x[1]yL[4] = h[1]x[3] + h[2]x[2]

    [5] h[2] [3]

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-47

    yL[5] = h[2]x[3]

  • Overlap Save MethodOverlap-Save Method If we append h[n] with a single zero-valued sample and

    t it i t l th 4 h [ ] th 4 i t i lconvert it into a length-4 sequence he[n], the 4-point circular convolution yC[n] of he[n] and x[n] is given by

    y [0] = h[0]x[0] + h[1]x[3] + h[2]x[2]yC[0] = h[0]x[0] + h[1]x[3] + h[2]x[2]yC[1] = h[0]x[1] + h[1]x[0] + h[2]x[3]y [2] = h[0]x[2] + h[1]x[1] + h[2]x[0]yC[2] = h[0]x[2] + h[1]x[1] + h[2]x[0]yC[3] = h[0]x[3] + h[1]x[2] + h[2]x[1]

    If we compare the expressions for the samples yL[n] of withIf we compare the expressions for the samples yL[n] of with those of yC[n], we observe that the first 2 terms of yC[n] do not correspond to the first 2 terms of yL[n], whereas the last 2 Lterms of yC[n] are precisely the same as the 3rd and 4th terms of yL[n], i.e.

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-48

    yL[0] yC[0], yL[1] yC[1], yL[2] = yC[2], yL[3] = yC[3]

  • Overlap Save MethodOverlap-Save Method General case: N-point circular convolution of a length-M

    h[ ] ith l th N [ ] ith N Msequence h[n] with a length-N sequence x[n] with N > M First M 1 samples of the circular convolution are incorrect

    and are rejectedand are rejected Remaining N M + 1 samples correspond to the correct

    samples of the linear convolution of h[n] with x[n]samples of the linear convolution of h[n] with x[n] Now, consider an infinitely long or very long sequence x[n] Break it up as a collection of smaller length (length 4) Break it up as a collection of smaller length (length-4)

    overlapping sequences xm[n] as xm[n] = x[n + 2m], 0 n 3, 0 m 0 m

    Next, formwm[n] = h[n] xm[n]

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-49

    wm[n] h[n] xm[n]

  • Overlap Save MethodOverlap-Save Method Or, equivalently,

    wm[0] = h[0]xm[0] + h[1]xm[3] + h[2]xm[2]wm[1] = h[0]xm[1] + h[1]xm[0] + h[2]xm[3]

    [2] h[0] [2] h[1] [1] h[2] [0]wm[2] = h[0]xm[2] + h[1]xm[1] + h[2]xm[0]wm[3] = h[0]xm[3] + h[1]xm[2] + h[2]xm[1]

    C ti th b f 0 1 2 3 d b tit ti Computing the above for m = 0, 1, 2, 3, . . . , and substituting the values of xm[n] we arrive at

    w [0] = h[0]x[0] + h[1]x[3] + h[2]x[2] Rejectw0[0] = h[0]x[0] + h[1]x[3] + h[2]x[2] Rejectw0[1] = h[0]x[1] + h[1]x[0] + h[2]x[3] Rejectw0[2] = h[0]x[2] + h[1]x[1] + h[2]x[0] = y[2] Savew0[2] h[0]x[2] + h[1]x[1] + h[2]x[0] y[2] Savew0[3] = h[0]x[3] + h[1]x[2] + h[2]x[1] = y[3] Save

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-50

  • Overlap Save MethodOverlap-Save Methodw1[0] = h[0]x[2] + h[1]x[5] + h[2]x[4] Rejectw1[1] = h[0]x[3] + h[1]x[2] + h[2]x[5] Rejectw1[2] = h[0]x[4] + h[1]x[3] + h[2]x[2] = y[4] Save

    [3] h[0] [5] h[1] [4] h[2] [3] [5] Sw1[3] = h[0]x[5] + h[1]x[4] + h[2]x[3] = y[5] Save

    w [0] = h[0]x[4] + h[1]x[5] + h[2]x[6] Rejectw2[0] = h[0]x[4] + h[1]x[5] + h[2]x[6] Rejectw2[1] = h[0]x[5] + h[1]x[4] + h[2]x[7] Rejectw2[2] = h[0]x[6] + h[1]x[5] + h[2]x[4] = y[6] Savew2[2] = h[0]x[6] + h[1]x[5] + h[2]x[4] = y[6] Savew2[3] = h[0]x[7] + h[1]x[6] + h[2]x[5] = y[7] Save

    It should be noted that to determine y[0] and y[1] we need toIt should be noted that to determine y[0] and y[1], we need to form x1[n]: x1[0] = 0, x1[1] = 0, x1[2] = x[0] , x1[3] = x[1]and compute w1[n] = h[n] x1[n] for 0 n 3, reject w1[0]

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-51

    a d co pu e 1[ ] [ ] 1[ ] o 0 3, ejec 1[0]and w1[1], and save w1[2] = y[0], and w1[3] = y[1]

  • Overlap Save MethodOverlap-Save Method General Case: Let h[n] be a length-N sequence Let xm[n] denote the m-th section of an infinitely long

    sequence x[n] of length N and defined byxm[n] = x[n + m(N M + 1)], 0 n N 1 with M < N

    Let wm[n] = h[n] xm[n] Then, we reject the first M 1 samples of wm[n] and abut

    the remaining M M + 1 samples of wm[n] to form yL[n], the linear convolution of h[n] and x[n]linear convolution of h[n] and x[n]

    If ym[n] denotes the saved portion of wm[n], i.e.,

    Th [ + (N M + 1)] [ ] M 1 N 1

    1

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-52

    Then yL[n + m(N M + 1)] = ym[n], M 1 n N 1

  • Overlap Save MethodOverlap-Save Method The approach is called overlap-save method since the

    i t i t d i t l i ti d t f thinput is segmented into overlapping sections and parts of the results of the circular convolutions are saved and abutted to determine the linear convolution resultdetermine the linear convolution result

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-53

  • Overlap Save MethodOverlap-Save Method

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-54

  • Signal TransformSignal Transform Motivation:Motivation:

    Represent a vector (e.g. a block of image samples) as the superposition of some typical vectors (block patterns)

    +t1 t2 t3 t4

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-55

  • Transform Coding of a ImageTransform Coding of a Image

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-56

  • 1 D 16 Pont DFT Basis Vectors1-D 16-Pont DFT Basis Vectors

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-57

  • Disadvantages of DFT in Signal Coding

    Fourier Transform of a real function results inou e a s o o a ea u ct o esu tscomplex numbers

    May result in artifacts due to discontinuityat the block boundary

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-58

    Discontinuities (high freq. components)

  • From DFT to DCTFrom DFT to DCT DFT of any real and symmetric sequence contains only

    l ffi i t di t th i t freal coefficients corresponding to the cosine terms of the series

    Construct a new symmetric sequence y(n) of length 2N Construct a new symmetric sequence y(n) of length 2N out of x(n) of length N

    ( ) ( ) 0 1= =

    ( ) ( ),0 1,( ) (2 1 ), 2 1.

    y n x n n Ny n x N n N n N

    Y(n) is symmetrical about n = N - (1/2)

    ( ) ( ),y

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-59

  • From DFT to DCTFrom DFT to DCT DCT has a higher compression ration than DFT

    DCT avoids the generation of spurious spectral components

    No discontinuities

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-60

  • From DFT to DCTFrom DFT to DCT +

    = 12 1 ( )2( ) ( )

    N n kY k y n W

    =

    + +

    =

    = +

    20

    1 11 2 1( ) ( )2 2

    ( ) ( ) ,

    ( ) ( )

    Nn

    N Nn k n k

    Y k y n W

    y n W y n W= =

    = + 2 20

    ( ) ( )N Nn n N

    y n W y n W

    + +

    1 11 2 1( ) ( )N Nn k n k+ +

    = =

    + +

    = +

    ( ) ( )2 2

    2 20

    1 11 1( ) [ 2 ( ) ]

    ( ) ( 2 1 )n k n k

    N Nn n N

    N Nn k N n k

    x n W x N n W

    + +

    = =

    = +

    +

    ( ) [ 2 ( ) ]2 2

    2 20 01

    ( ) ( )

    ( 2 1)

    n k N n k

    N Nn n

    N

    x n W x n W

    n k

    =

    +=

    02

    ( 2 1)2 ( ) c o s ,2n

    j

    n kx nN

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-61

    = 220 2 1, j

    NNk N a n d W e

  • 1 D N Point DCT1-D N-Point DCT +

    1 ( 2 1)( ) ( ) ( ) c o s

    N n kF k C k f n=

    = =

    0

    ( ) ( ) ( ) c o s ,2

    0 ,1, , 1,n

    F k C k f nN

    k N + =

    1

    0 ,1, , 1,( 2 1)( ) ( ) ( ) c o s ,

    2

    N

    k Nn kf n C k F k

    N= =

    0 20 ,1, , 1,

    k Nn N

    1 2

    where

    = = = 1 2(0) , ( ) , 1,2, , 1C C k k NN N

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-62

    The constants are often defined differently

  • 1 D N Point DCT1-D N-Point DCT

    ( )cos (2 1)0 /16n + ( )cos (2 1)2 /16n + ( )cos (2 1)4 /16n + ( )cos (2 1)6 /16n +

    ( )cos (2 1)1 /16n + ( )cos (2 1)3 /16n + ( )cos (2 1)5 /16n + ( )cos (2 1)7 /16n +

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-63

  • Example of 1 D DCTExample of 1-D DCTRow 256 of Lena 2500 00

    160 00

    200.00Row 256 of Lena

    2000.00

    2500.00

    absolute DCT values of Lena row 256

    120.00

    160.00

    1500.00

    80.00 1000.00

    40.00 500.00

    0.00 200.00 400.00 600.00

    0.00

    0.00 200.00 400.00 600.00

    0.00

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-64

  • Illustration of Image CodingUsing 2-D DCT

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-65

  • DCT-Based Image Coding with Different Quantization Levels

    DCT di i h i i l i i bl k i 8 8 DCT coding with increasingly coarse quantization, block size 8x8

    quantizer step-size for AC coefficient:

    quantizer step-size for AC coefficient:

    quantizer step-size for AC coefficient:

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-66

    25 100 200

  • Image Coding with Different Numbers of DCT Coefficients

    with 16/64 original coefficients

    with 8/64 coefficients

    with 4/64 coefficients

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-67

  • Comparison of Basis Vectors of Different Transform (1-D)

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-68

  • Comparison of Basis Vectors of Different Transform (2-D)

    Cosine Sine

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-69Haar 69

  • DCT Based Coding: JPEGDCT-Based Coding: JPEG8x8 blocks Compressed

    i dDC

    Entropyencoder

    image dataQ

    DPCMZigzagscan

    DCTAC

    C

    Quantizationtable

    Tablespecification

    Sourceimage data

    specification

    Compressed8x8 blocks

    DC

    Entropydecoder

    image dataIQ

    DPCMZigzagscanIDCT

    AC

    Quantization Table

    Reconstructedimage data

    The McGraw-Hill Companies, Inc., 2007Original PowerPoint slides prepared by S. K. Mitra 4-1-70

    table specification