Ch5 Mitra DSP 2p
Ch5 Mitra DSP 2p
Chapter 5
                                     Finite-Length Discrete
                                           Transforms
                                              
                                            cwlin@ee.nthu.edu.tw
                                                 03-5731152                          4-1-1
Original PowerPoint slides prepared by S. K. Mitra
                                                          The McGraw-Hill Companies, Inc., 2007
0 k N 1
       Note: X[k]
               [ ] is also a length-N
                                g     sequence
                                        q      in the frequency
                                                         q    y
        domain
       The sequence X[k] is called the Discrete Fourier
        Transform (DFT) of the sequence x[n]
                                                                                                          1
                                                                                               2008/4/22
       Making
             g use of the identity
                                 y
                                                                                                      2
                                                                                                  2008/4/22
       We get                                       , 0  k  N 1
Original PowerPoint slides prepared by S. K. Mitra                                  4-1-6
                                                         The McGraw-Hill Companies, Inc., 2007
                                                                                                         3
                                                                                               2008/4/22
                                      Matrix Relation
     The DFT samples defined by
                                      Matrix Relation
     Likewise, the IDFT relation given by
Note:
                                                                                                      4
                                                                                                      2008/4/22
                                                                                                             5
                                                                                                           2008/4/22
   Or, equivalently
                                        S rS = (1 r)S =1 rN
   Hence
    H
                                                                                                                  6
                                                                                               2008/4/22
                                                                                                      7
                                                                                               2008/4/22
                                                                                                      8
                                                                                               2008/4/22
Then
                                                                                                      9
                                                                                                                   2008/4/22
                                      DFT 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
                                                                                                                         10
                                                                                               2008/4/22
                                                                                                     11
                                                                                                               2008/4/22
                              Circular Convolution
     This operation is analogous to linear convolution, but with a
      subtle difference
     Consider two length-N
                     length N sequences,
                              sequences g[n] and h[n].
                                                  h[n] Their linear
      convolution results in a length-(2N1) sequence yL[n]:
                                                                                                                     12
                                                                                               2008/4/22
                              Circular 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
      reversal,
     Resulting operation, called a circular convolution, is
      defined by:
                              Circular Convolution
     Example - Determine the 4-point circular convolution of the
      two length-4 sequences
                  {g[n]} = {1 2 0 1}, {h[n]} = {2 2 1 1}
                                                                                                     13
                                                                                               2008/4/22
                              Circular 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] = 6
         yC[3] = g[0]h[3] + g[1]h[2] + g[2]h[1] + g[3]h[0] = 5
                              Circular Convolution
     Example - Consider the two length-4 sequences repeated
      below for convenience:
                                                                                                     14
                                                                                               2008/4/22
                              Circular Convolution
     The two 4-point DFTs can also be computed using the
      matrix relation given earlier
                              Circular Convolution
     A 4-point IDFT of YC[k] yields
                                                                                                     15
                                                                                               2008/4/22
                              Circular Convolution
     Example - Extend the two length-4 sequences to length 7 by
      appending each with three zero-valued samples, i.e.
                              Circular Convolution
     The N-point circular convolution can be written in matrix
      form as
                                                                                                     16
                                                                                               2008/4/22
     The partial products generated in the 2nd, 3rd, and 4th rows
      are circularly shifted to the left as indicated above  4-1-33
Original PowerPoint slides prepared by S. K. Mitra
                                                      The McGraw-Hill Companies, Inc., 2007
                                                                                                     17
                                                                                               2008/4/22
                                                                                                     18
                                                                                               2008/4/22
   That is
Original PowerPoint slides prepared by S. K. Mitra                             4-1-37
                                                      The McGraw-Hill Companies, Inc., 2007
    S
     Substituting the values off the 4-point DFTs G[k]
                                                  G and H[k],
     we can obtain V[k]
                                                                                                     19
                                                                                               2008/4/22
Then
                                                                                                     20
                                                                                               2008/4/22
                              Overlap-Add Method
    We first segment x[n], assumed to be a causal sequence
     here without any loss of generality, into a set of contiguous
     finite-length
     finite length subsequences of length N each:
where
where
                              Overlap-Add Method
    The desired linear convolution y[n] = h[n] x[n] is broken up
     into a sum of infinite number of short-length linear
     convolutions of length N + M 11 each: ym[n] = h[n] xm[n]
    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) points
                                                                                                     21
                                                                                               2008/4/22
                              Overlap-Add Method
    In general, there will be an overlap of M 1 samples
     between the samples of the short convolutions h[n] xr-1[n]
     and h[n] xm[n] for (r 1)N
                              1)N  n  rN + M  2
Overlap-Add Method
                                                                                                     22
                                                                                               2008/4/22
                              Overlap-Add Method
    The above procedure is called the overlap-add method
     since the results of the short linear convolutions overlap and
     the overlapped portions are added to get the correct final
     result
    The MATLAB function fftfilt can be used to implement the
     above method
    The following illustrates an example of filtering of a noise-
     corrupted signal using a length-3 moving average filter:
                             Overlap-Save Method
    In implementing the overlap-add method using the DFT, we
     need to compute two (N + M 1)-point DFTs and one (N + M
     1)-point
       1) point IDFT for each short linear convolution
    It is possible to implement the overall linear convolution by
     performing instead circular convolution of length shorter than
     (N + M 1)
    To this end, it is necessary to segment x[n] into
     overlapping blocks xm[n], keep the terms of the circular
     convolution of h[n] with that corresponds to the terms
     obtained by a linear convolution of h[n] and xm[n], and throw
     away the other parts of the circular convolution
                                                                                                     23
                                                                                               2008/4/22
                             Overlap-Save Method
    To understand the correspondence between the linear and
     circular convolutions, consider a length-4 sequence x[n] and
     a length-3
       length 3 sequence h[n]
    Let yL[n] denote the result of a linear convolution of x[n] with
     h[n]
    The six samples of yL[n] are given by
           yL[0] = h[0]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]
           yL[3] = h[0]x[3] + h[1]x[2] + h[2]x[1]
           yL[4] = h[1]x[3] + h[2]x[2]
           yL[5] = h[2]x[3]
Original PowerPoint slides prepared by S. K. Mitra                             4-1-47
                                                      The McGraw-Hill Companies, Inc., 2007
                             Overlap-Save Method
    If we append h[n] with a single zero-valued sample and
     convert it into a length-4 sequence he[n], the 4-point circular
     convolution yC[n] of he[n] and x[n] is given by
           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]
           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 with
     those of yC[n],
                 [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
     terms of yC[n] are precisely the same as the 3rd and 4th
     terms of yL[n], i.e.
         yL[0]  yC[0], yL[1]  yC[1], yL[2] = yC[2], yL[3] = yC[3]
Original PowerPoint slides prepared by S. K. Mitra                             4-1-48
                                                      The McGraw-Hill Companies, Inc., 2007
                                                                                                     24
                                                                                               2008/4/22
                             Overlap-Save Method
    General case: N-point circular convolution of a length-M
     sequence h[n] with a length-N sequence x[n] with N > M
    First M  1 samples of the circular convolution are incorrect
     and are rejected
    Remaining N  M + 1 samples correspond to the correct
     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)
     overlapping
          l   i sequences xm[n]  [ ] as xm[n]
                                          [ ] = x[n
                                                 [ + 2m],
                                                     2 ] 0  n  3,
                                                                 3
     0m
    Next, form
                          wm[n] = h[n] xm[n]
Original PowerPoint slides prepared by S. K. Mitra                             4-1-49
                                                      The McGraw-Hill Companies, Inc., 2007
                             Overlap-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]
          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]
    Computing the above for m = 0, 1, 2, 3, . . . , and substituting
     the values of xm[n] we arrive at
          w0[0] = h[0]x[0] + h[1]x[3] + h[2]x[2]            Reject
          w0[1] = h[0]x[1]
                  h[0] [1] + h[1]x[0]
                             h[1] [0] + h[2]x[3]
                                        h[2] [3]            Reject
                                                              R j
          w0[2] = h[0]x[2] + h[1]x[1] + h[2]x[0] = y[2]     Save
          w0[3] = h[0]x[3] + h[1]x[2] + h[2]x[1] = y[3]     Save
                                                                                                     25
                                                                                                 2008/4/22
                             Overlap-Save Method
                 w1[0] = h[0]x[2] + h[1]x[5] + h[2]x[4]                     Reject
                 w1[1] = h[0]x[3] + h[1]x[2] + h[2]x[5]                     Reject
                 w1[2] = h[0]x[4] + h[1]x[3] + h[2]x[2] = y[4]              Save
                 w1[3] = h[0]x[5] + h[1]x[4] + h[2]x[3] = y[5]              Save
                             Overlap-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 by
         xm[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]
    If ym[n] denotes the saved portion of wm[n], i.e.,
                                                           1
       Then yL[n + m(N  M + 1)] = ym[n], M  1  n  N  1
Original PowerPoint slides prepared by S. K. Mitra                               4-1-52
                                                        The McGraw-Hill Companies, Inc., 2007
                                                                                                       26
                                                                                               2008/4/22
                             Overlap-Save Method
    The approach is called overlap-save method since the
     input is segmented into overlapping sections and parts of the
     results of the circular convolutions are saved and abutted to
     determine the linear convolution result
Overlap-Save Method
                                                                                                     27
                                                                                                             2008/4/22
                                    Signal Transform
     Motivation:
           Represent a vector (e.g. a block of image samples) as
            the
             h superposition
                        i i off some typical
                                          i l vectors (bl
                                                      (block
                                                           k
            patterns)
                                                          +
                               t1                    t2       t3        t4
                                                                                                                   28
                                                                                                               2008/4/22
                                                                                                                     29
                                                                                                               2008/4/22
                 y (n) = x(n),0  n  N  1,
                 y (n) = x(2N  1  n), N  n  2N  1.
       Y(n) is symmetrical about n = N - (1/2)
No discontinuities
                                                                                                                     30
                                                                                                                            2008/4/22
                  N 1                          1           2 N 1                          1
                                         (n +     )k                                 (n +     )k
              =   
                  n=0
                         y ( n )W       2N
                                                2
                                                       +    
                                                            n=N
                                                                     y ( n )W        2N
                                                                                            2
                  N 1                          1          2 N 1                                                  1
                                        (n +      )k                                                        (n +     )k
             =    
                  n=0
                         x ( n )W      2N
                                                2
                                                       +    
                                                            n=N
                                                                     x ( 2 N  1  n )W                     2N
                                                                                                                   2
                  N 1                          1          N 1                                    1
                                        (n +      )k                             [2N (n +           )k ]
             =    
                  n=0
                         x ( n )W      2N
                                                2
                                                       +   
                                                           n=0
                                                                  x ( n )W      2N
                                                                                                   2
                  N 1
                                                  ( 2 n + 1) k
             =    
                  n=0
                         2 x (n ) co s
                                                           2N
                                                                          ,
                                                                                     2
                                                                                j
            0  k  2 N  1, a n d W                              2N     = e         2N
                           1                         2
          C (0) =            , C (k ) =                , k = 1,2,", N  1
                           N                         N
      The constants are often defined differently
Original PowerPoint slides prepared by S. K. Mitra                                                                 4-1-62
                                                                                  The McGraw-Hill Companies, Inc., 2007
                                                                                                                                  31
                                                                                                                                  2008/4/22
cos ( (2n + 1)0 /16 ) cos ( (2n + 1)2 /16 ) cos ( (2n + 1)4 /16 ) cos ( (2n + 1)6 /16 )
cos ( (2n + 1)1 /16 ) cos ( (2n + 1)3 /16 ) cos ( (2n + 1)5 /16 ) cos ( (2n + 1)7 /16 )
      160.00
                                                          2000.00           absolute DCT values of Lena row 256
                                                          1500.00
      120.00
80.00 1000.00
40.00 500.00
       0.00                                                     0.00
               0.00         200.00          400.00             600.000.00            200.00          400.00           600.00
                                                                                                                                        32
                                                                                                             2008/4/22
                                                                                                                   33
                                                                                               2008/4/22
                                                                        with 16/64
      original                                                          coefficients
                                                                                                     34
                                                                                                                   2008/4/22
Cosine Sine
35