Image Analysis - Lecture 2

Document Sample
Image Analysis - Lecture 2 Powered By Docstoc
					Review of Linear algebra
      Fourier transform




Image Analysis - Lecture 2

                Fredrik Kahl


           4 September 2009




            Fredrik Kahl   Image Analysis - Lecture 2
                    Review of Linear algebra
                          Fourier transform



Lecture 2


  Contents
    ◮   Linear Algebra
          ◮   Linear spaces, bases
          ◮   Scalar product, orthogonality, ON-bases
          ◮   Sub-spaces, projections
    ◮   The Fourier transform
          ◮   Definition, examples, 1D and 2D
          ◮   Discrete Fourier Transform, Fast Fourier Transform
          ◮   Application to Images
    ◮   Master thesis proposal of the day



                                Fredrik Kahl   Image Analysis - Lecture 2
                                               Linear space, basis
                    Review of Linear algebra
                                               Scalar product
                          Fourier transform
                                               Orthogonal projection


Linear algebra: Linear spaces


   The following linear spaces are well-known:
                                      
                                      x1
         n : all n × 1-matrices, x =  .  ,
     ◮ R                             .
                                       .     xi ∈ R
                                        xn
                                        
                                        x1
           n : all n × 1-matrices, x =  .  ,
     ◮   C                             .
                                         .                   xi ∈ C
                                        xn




                                Fredrik Kahl   Image Analysis - Lecture 2
                                               Linear space, basis
                    Review of Linear algebra
                                               Scalar product
                          Fourier transform
                                               Orthogonal projection


Basis

  Definition
  e1 , . . . en ∈ Rn is a basis in Rn if
    ◮   they are linearly independent
    ◮   they span Rn .


  Example (3D space)
  e1 , e2 , e3 ∈ R3 is a basis in R3 if they are not located in the
  same plane.




                                Fredrik Kahl   Image Analysis - Lecture 2
                                                 Linear space, basis
                  Review of Linear algebra
                                                 Scalar product
                        Fourier transform
                                                 Orthogonal projection


Canonical Basis

  Example (canonical basis)
                                                                   
                  1                  0                                 0
                 0                1                               0
                                                                   
            e1 =  .  ,       e2 =  .  ,             ...      en =  . 
                 .
                   .                .
                                      .                               .
                                                                        .
                    0                        0                                1
  is called the canonical basis in Rn .
                        
                         x1
                       .
                   x =  .  = x1 e1 . . . + xn en .
                          .
                         xn


                              Fredrik Kahl       Image Analysis - Lecture 2
                                                  Linear space, basis
                   Review of Linear algebra
                                                  Scalar product
                         Fourier transform
                                                  Orthogonal projection


Coordinates



  Let e1 , e2 , . . . , en be a basis. Then for every x there is a unique
  set of scalars ξi such that
                                              n
                                   x=             ξi e i .
                                          i=1

  These scalars are called the coordinates for x in the basis
  e1 , e2 , . . . , en .




                               Fredrik Kahl       Image Analysis - Lecture 2
                                               Linear space, basis
                    Review of Linear algebra
                                               Scalar product
                          Fourier transform
                                               Orthogonal projection


Image matrix



  An M × N image, f , is described by the matrix
                                             
             f (0, 0)     ...    f (0, N − 1)
                .        ..            .     
      f =       .
                 .           .          .
                                        .     ,                            f (i, j) ∈ C
              f (M − 1, 0) . . . f (M − 1, N − 1)

  f (i, ·)=i:th row, f (·, j)=j:th column.




                                Fredrik Kahl   Image Analysis - Lecture 2
                                               Linear space, basis
                    Review of Linear algebra
                                               Scalar product
                          Fourier transform
                                               Orthogonal projection


Row-stacking

  Row-stacking:
                                              
                                 f T (0, ·)
                                f T (1, ·)    
                    ˜=
                    f                .
                                               
                                                ∈ RMN (CMN )
                                     .
                                      .        
                              f T (M − 1, ·)

  Properties:
                                    f + g = ˜+ g
                                            f ˜
                                 λf = λ˜,
                                       f        λ∈R
  A linear space!


                                Fredrik Kahl   Image Analysis - Lecture 2
                                              Linear space, basis
                 Review of Linear algebra
                                              Scalar product
                       Fourier transform
                                              Orthogonal projection


Canonical basis

                                         
                             0 ... 0 ... 0
                               .
                                . 1 . .   
                  χ(i, j) =    .     .   ,
                             0 ... 0 ... 0
  with the 1 at position (i, j).
  Using this canonical basis we can write

                           f =           f (i, j)χ(i, j) .
                                   i,j

  Idea for image transform:
  Choose another basis that is more suitable in some sense.
  Image matrices can thus be seen as vectors in a linear space.

                             Fredrik Kahl     Image Analysis - Lecture 2
                                               Linear space, basis
                  Review of Linear algebra
                                               Scalar product
                        Fourier transform
                                               Orthogonal projection


Scalar product

   Definition
   Let A be a (complex) matrix. Introduce
                                         ¯
                                   A∗ = (A)T .



   Definition
   Let x and y be two vectors in Rn (Cn ). The scalar product of x
   and y is defined as

                          x ·y =             ¯
                                             xi yi = x ∗ y .



                              Fredrik Kahl     Image Analysis - Lecture 2
                                              Linear space, basis
                   Review of Linear algebra
                                              Scalar product
                         Fourier transform
                                              Orthogonal projection


Orthogonality
   Definition
   The scalar product of two matrices (images) is defined as
                                  M−1 N−1
                       f ·g =                 ¯(i, j)g(i, j) .
                                              f
                                   i=0 j=0

   x, y ∈ R(C) are orthogonal if x · y = 0. This is often written

                           x⊥y         ⇔      x ·y =0 .

   The length or the norm of x is defined as

                     ||x|| =              |xi |2 = (x ∗ x)1/2 .


                               Fredrik Kahl   Image Analysis - Lecture 2
                                            Linear space, basis
               Review of Linear algebra
                                            Scalar product
                     Fourier transform
                                            Orthogonal projection

Coordinates:


                       ξ2                         x

                       e2

                                  e1             ξ1
Norm:
                        x2                            x = (x1 , x2 )

                                    ||x||



                                                      x1
                           Fredrik Kahl     Image Analysis - Lecture 2
                                              Linear space, basis
                   Review of Linear algebra
                                              Scalar product
                         Fourier transform
                                              Orthogonal projection


Orthogonal basis (ON-basis)



  Definition
  {e1 , . . . , en } is an orthonormal (ON-) basis in Rn (Cn ) if

                                              0 i=j
                              ei · ej =
                                              1 i=j




                               Fredrik Kahl   Image Analysis - Lecture 2
                                                 Linear space, basis
                  Review of Linear algebra
                                                 Scalar product
                        Fourier transform
                                                 Orthogonal projection


Coordinates in ON-basis


  Theorem
  Assume that {e1 , . . . , en } is orthonormal (ON) basis and
                                             n
                                  x=             ξi e i .
                                         i=1

  Then
                                                                n
                 ξi = ei · x = ei∗ x,            ||x||2 =           |ξi |2
                                                              i=1




                              Fredrik Kahl       Image Analysis - Lecture 2
                                           Linear space, basis
               Review of Linear algebra
                                           Scalar product
                     Fourier transform
                                           Orthogonal projection


Illustration




                       e2 · x                          x

                         e2


                                          e1        e1 · x




                           Fredrik Kahl    Image Analysis - Lecture 2
                                                   Linear space, basis
                    Review of Linear algebra
                                                   Scalar product
                          Fourier transform
                                                   Orthogonal projection


Orthogonal projection


   Definition
   Let {a1 , . . . , ak } ∈ Rn , k ≤ n, span a linear subspace, π, in Rn ,
   i.e.:
                                               k
                     π = {w |w =                   xi ai , xi ∈ R} .
                                           i=1

   The orthogonal projection of u ∈ Rn on π is a linear mapping
   P, such that uπ = Pu and defined by

                         min ||u − w || = ||u − uπ || .
                         w ∈π




                                Fredrik Kahl       Image Analysis - Lecture 2
                                              Linear space, basis
                  Review of Linear algebra
                                              Scalar product
                        Fourier transform
                                              Orthogonal projection


Orthogonal projection (ctd.)


   The orthogonal projection is characterized by
    1. uπ ∈ π
    2. u − uπ ⊥w for every w ∈ π

                                         u
                                                   u − uπ


                                π            uπ




                              Fredrik Kahl    Image Analysis - Lecture 2
                                            Linear space, basis
                 Review of Linear algebra
                                            Scalar product
                       Fourier transform
                                            Orthogonal projection


Example: Matrix-basis

  What is the orthogonal projection of f
                                        
                               1 2 3
                         f = 4 5 6
                               7 7 7

  onto the space spanned by (e1 , e2 , e3 )
                                                            
           1 1 1                1       1   1              1 0 −1
        1                 1                             1
  e1 = 1 1 1 , e2 = √  0             0   0  , e3 = √ 1 0 −1
        3                  6 −1 −1 −1                    6 1 0 −1
           1 1 1




                             Fredrik Kahl   Image Analysis - Lecture 2
                                             Linear space, basis
                  Review of Linear algebra
                                             Scalar product
                        Fourier transform
                                             Orthogonal projection


Example: Matrix-basis (ctd.)


   Since (e1 , e2 , e3 ) is orthonormal the coordinates are
                                          √                 √
   x1 = f · e1 = 14, x2 = f · e2 = −15/ 6, x3 = f · e3 = −4/ 6.
   The orthogonal√                is
                      projection√ then
   ˆ = 14e1 − 15/ 6e2 − 4/ 6e3
   f
                                     1                        5
                    1 2 3         1.5 2 6                       26
               f = 4 5 6 , ˆ =  4 4 3
                             f          2
                                                                53 ,
                                                                 1

                    7 7 7               1                        5
                                  6.5 7 6                       76




                              Fredrik Kahl   Image Analysis - Lecture 2
                                             Linear space, basis
                  Review of Linear algebra
                                             Scalar product
                        Fourier transform
                                             Orthogonal projection


Example: ’Face’-basis
  What is the orthogonal projection of f




  onto the space spanned by (e1 , e2 , e3 )




                              Fredrik Kahl   Image Analysis - Lecture 2
                                            Linear space, basis
                 Review of Linear algebra
                                            Scalar product
                       Fourier transform
                                            Orthogonal projection


Example: ’Face’-basis (ctd.)

   Since (e1 , e2 , e3 ) is orthonormal, the coordinates are
   x1 = f · e1 = −2457, x2 = f · e2 = 303, x3 = f · e3 = −603.
   The orthogonal projection is then ˆ = −2457e1 + 303e2 − 603e3
                                         f




                             Fredrik Kahl   Image Analysis - Lecture 2
                                              Linear space, basis
                  Review of Linear algebra
                                              Scalar product
                        Fourier transform
                                              Orthogonal projection


Uniqueness of the projection



   Let a ∈ π and b ∈ π be two solutions to the minimisation
   problem. Set
                                                          2
                     f (t) = u − ta − (1 − t)b                = ...
                 2
       = u−b         + t2 a − b       2
                                          − 2t(a − b) · (u − b),           t ∈ R.
   This is a second degree polynomial with minimum in t = 0 and
   t = 1 ⇒ f (t) is a constant function and thus ⇒ a = b.




                              Fredrik Kahl    Image Analysis - Lecture 2
                                             Linear space, basis
                  Review of Linear algebra
                                             Scalar product
                        Fourier transform
                                             Orthogonal projection


Characterization of the projection


   Let f (t) = u − uπ + ta 2 , where a ∈ π. It follows that
   f ′ (0) = 2(u − uπ ) · a = 0, i.e. (u − uπ ) ⊥ a.
   Conversely: Assume w ∈ π. The property that (u − uπ ) ⊥ a, for
   every a ∈ π gives that
                              2                                 2
                  u −w            = u − uπ + uπ − w                  =
                             2                  2                    2
                 u − uπ           + uπ − w          ≥ u − uπ              ,
   i.e. uπ solves the minimization problem.




                              Fredrik Kahl   Image Analysis - Lecture 2
                                               Linear space, basis
                    Review of Linear algebra
                                               Scalar product
                          Fourier transform
                                               Orthogonal projection


An important result


   Let A = [a1 . . . ak ] be a n × k matrix and

                         π = {w |w = Ax, xi ∈ Rn }

   Lemma
   If {a1 , . . . , ak } are linearly independent Rn then A∗ A is
   invertible.
   Proof:    Do it on your own. (Use SVD if you are familiar with it.)




                                Fredrik Kahl   Image Analysis - Lecture 2
                                            Linear space, basis
                 Review of Linear algebra
                                            Scalar product
                       Fourier transform
                                            Orthogonal projection


Projection onto the subspace spanned by A

  Theorem
  if the columns of A are linearly independent, then the projection
  of u on π is given by

           uπ = x1 a1 + . . . + xk ak ,        x = (A∗ A)−1 A∗ u .

  Proof:   Use the characterization of the projection (above).

                           a∗ (u − uπ ) = 0
                            i                        ⇒

                          A∗ (u − Ax) = 0             ⇒
               A∗ u = A∗ Ax           ⇒     x = (A∗ A)−1 A∗ u


                             Fredrik Kahl   Image Analysis - Lecture 2
                                              Linear space, basis
                   Review of Linear algebra
                                              Scalar product
                         Fourier transform
                                              Orthogonal projection


The pseudo-inverse


  Definition
  A+ = (A∗ A)−1 A∗ is called the pseudo-inverse of A.

  Observe that if A is quadratic and invertible then A+ = A−1 .
  Theorem
  If {a1 , . . . , ak } are orthonormal, then the projection of u on π is
  given by
                       uπ = y1 a1 + . . . + yk ak , yi = a∗ u .
                                                          i

  Proof:    This follows from A∗ A = I.



                               Fredrik Kahl   Image Analysis - Lecture 2
                                          Linear space, basis
               Review of Linear algebra
                                          Scalar product
                     Fourier transform
                                          Orthogonal projection


Illustration


                                                     u




                           y2 a2                   uπ
                                                   y1 a1
                       π




                           Fredrik Kahl   Image Analysis - Lecture 2
                                               Continuous Fourier transform
                  Review of Linear algebra
                                               Discrete Fourier Transform (DFT,FFT)
                        Fourier transform
                                               Two-dimensional Fourier Transform


Fourier transform

   Definition
   Let f be a function from R to R. The Fourier transformen of f is
   defined as
                                              +∞
               (Ff )(u) = F (u) =                  e−i2πxu f (x)dx .
                                             −∞




   Theorem
   Under the right assumptions on f , the following inversion
   formula
                                     +∞
                      f (x) =                ei2πux F (u)du
                                    −∞

   holds.
                              Fredrik Kahl     Image Analysis - Lecture 2
                                        Continuous Fourier transform
             Review of Linear algebra
                                        Discrete Fourier Transform (DFT,FFT)
                   Fourier transform
                                        Two-dimensional Fourier Transform


Examples




  Example

               δ(x) → 1(u)
                        sin(2πu)
            rect(x) → 2          = 2 sinc(2πu)
                           2πu




                         Fredrik Kahl   Image Analysis - Lecture 2
                                            Continuous Fourier transform
                 Review of Linear algebra
                                            Discrete Fourier Transform (DFT,FFT)
                       Fourier transform
                                            Two-dimensional Fourier Transform


Illustrations

                                        F
                                                              1


                                   x                                       u
                                        F
                     1                                        2


            −1              1      x                                       u

                             Fredrik Kahl   Image Analysis - Lecture 2
                                              Continuous Fourier transform
                   Review of Linear algebra
                                              Discrete Fourier Transform (DFT,FFT)
                         Fourier transform
                                              Two-dimensional Fourier Transform


Properties


      c1 f1 (x) + c2 f2 (x) → c1 F1 (u) + c2 F2 (u) (linearity)
                               1     u
                   f (λx) →       F( )              (scaling)
                              |λ| λ
                f (x − a) → e−i2πua F (u)                    (translation)
            e−i2πxa f (x) → F (u + a)                        (modulation)
                  f (x) → F (−u)                             (conjugation)
                     df
                        → 2πiuF (u)                          (differentiation I)
                    dx
                          dF
             −2πixf (x) →                                    (differentiation II)
                          du
   Example: δ(x − 1) → e−i2πu
                               Fredrik Kahl   Image Analysis - Lecture 2
                                                Continuous Fourier transform
                   Review of Linear algebra
                                                Discrete Fourier Transform (DFT,FFT)
                         Fourier transform
                                                Two-dimensional Fourier Transform


Review of Distributions

                          ∞
   Test functions: ϕ ∈ C0 .
   A distribution u is a functional (with certain constraints) acting
   on the space of test functions. This action is written

                                        (u, ϕ).

   E.g. (δ, ϕ) = ϕ(0), Dirac delta function. Had u been a ordinary
   function, then
                          (u, ϕ) =            u(x)ϕ(x)dx,

   i.e. the scalar product.



                               Fredrik Kahl     Image Analysis - Lecture 2
                                                 Continuous Fourier transform
                      Review of Linear algebra
                                                 Discrete Fourier Transform (DFT,FFT)
                            Fourier transform
                                                 Two-dimensional Fourier Transform


Properties of Distributions

   Properties
    ◮   Differentiation: (u ′ , ϕ) = −(u, ϕ′ ).
    ◮   Convolution: u ∗ ϕ(x) = (u, ϕ(x − ·)).
        E.g. δ ∗ ϕ(x) = (u, ϕ(x − ·)) = ϕ(x).
    ◮                        ˆ           ˆ
        Fourier transform: (u , ϕ) = (u, ϕ).
        E.g.
                            ˆ          ˆ     ˆ
                          (δ, ϕ) = (δ, ϕ) = ϕ(0) =

                                         ϕ(x)dx = (1, ϕ)

             ˆ
        i.e. δ = 1.


                                  Fredrik Kahl   Image Analysis - Lecture 2
                                               Continuous Fourier transform
                    Review of Linear algebra
                                               Discrete Fourier Transform (DFT,FFT)
                          Fourier transform
                                               Two-dimensional Fourier Transform


The discrete Fourier transform (DFT)
   Sample f (x) and F (u).




                                      x                                   u
              0                     N −1 0                              N −1
                       ∆x                                  ∆u
                                 N−1
                  F (n∆u ) ∼             e−i2πk ∆x n∆u f (k∆x )∆x ,
                                  k =0
                                 N−1
                  f (k∆x ) ∼             ei2πk ∆x n∆u F (n∆u )∆u .
                                  n=0

                                Fredrik Kahl   Image Analysis - Lecture 2
                                                Continuous Fourier transform
                  Review of Linear algebra
                                                Discrete Fourier Transform (DFT,FFT)
                        Fourier transform
                                                Two-dimensional Fourier Transform


The discrete Fourier transform (DFT) (ctd.)

                                                        1
   This works particularly well if ∆x ∆u =              N:

                                       N−1
                 1
                    F (n∆u ) ∼                 e−i2πkn/N f (k∆x ),
                 ∆x
                                       k =0

                                   N−1
                               1                        1
                 f (k∆x ) ∼                  ei2πkn/N      F (n∆u ).
                               N                        ∆x
                                    n=0

   F and f are extended to periodic functions with periods N∆u
   and N∆x respectively.



                              Fredrik Kahl      Image Analysis - Lecture 2
                                               Continuous Fourier transform
                    Review of Linear algebra
                                               Discrete Fourier Transform (DFT,FFT)
                          Fourier transform
                                               Two-dimensional Fourier Transform


Definition of the discrete Fourier transform
   Let the vector
                         (f (0), f (1), . . . , f (N − 1)) .
   represent the discretized version of f (x).
   Definition
   The discrete Fourier Transformen (DFT) of f is
                           N−1
                                         ku
                F (u) =            f (k)ωN , u = 0, . . . , N − 1 ,
                            k =0

   where ωN = e−i2π/N .
   Represent the sequence F (u) with the vector

                       (F (0), F (1), . . . , F (N − 1)) .

                                Fredrik Kahl   Image Analysis - Lecture 2
                                           Continuous Fourier transform
                Review of Linear algebra
                                           Discrete Fourier Transform (DFT,FFT)
                      Fourier transform
                                           Two-dimensional Fourier Transform


Important assumption



  All sequences are assumed to be period with period N.
                                           0 N −1
                                   21
                                  3




                            Fredrik Kahl   Image Analysis - Lecture 2
                                                 Continuous Fourier transform
                      Review of Linear algebra
                                                 Discrete Fourier Transform (DFT,FFT)
                            Fourier transform
                                                 Two-dimensional Fourier Transform


Properties of DFT
  There are similar formulas for the discrete Fourier Transform
  (as compared to that of the continuous Fourier Transform), e.g.
      (f (−k0 ), f (1 − k0 ), . . . , f (N − 1 − k0 )) →
           N−1
       →           f (k − k0 )ω ku = [l = k − k0 ]
           k =0
           N−1−k0
       =             f (l)ω (l+k0 )u =
           l=−k0
                   N−1−k0                                                N−1
            k0 u                    lu                            k0 u
       =ω                   f (l)ω = [f periodic] = ω                          f (l)ω lu =
                    l=−k0                                                l=0
            k0 u               −i2πk0 /N
       =ω          F (u) = e                F (u)

                                  Fredrik Kahl   Image Analysis - Lecture 2
                                               Continuous Fourier transform
                  Review of Linear algebra
                                               Discrete Fourier Transform (DFT,FFT)
                        Fourier transform
                                               Two-dimensional Fourier Transform


DFT in matrix form
   Let                                                              
                         f (0)                             F (0)
                           
                            .
                            .                               .
                                                             .    
               f =         ,
                            .                F =            .     .
                   f (N − 1)                             F (N − 1)
   Definition
   The Fourier Matrix FN is given by
                                                                            
                 1    1        1                  ...              1
               1 ω           ωN2                 ...         ωNN−1          
                      N                                                     
                      2        4                             2(N−1)         
         FN = 1 ωN
               .
                              ωN                  ...        ωN               .
                                                                             
               .     .
                      .        .
                               .                  ..             .
                                                                 .           
               .     .        .                     .           .           
                     N−1              2(N−1)                (N−1)(N−1)
                  1 ωN   ωN                       . . . ωN


                              Fredrik Kahl     Image Analysis - Lecture 2
                                           Continuous Fourier transform
                Review of Linear algebra
                                           Discrete Fourier Transform (DFT,FFT)
                      Fourier transform
                                           Two-dimensional Fourier Transform


Computation of DFT



  Theorem

                                   F = FN f

  Proof: Use the definition of DFT and of the Fourier Matrix
  Consequence: DFT can be computed using matrix
  multiplication.




                            Fredrik Kahl   Image Analysis - Lecture 2
                                             Continuous Fourier transform
                  Review of Linear algebra
                                             Discrete Fourier Transform (DFT,FFT)
                        Fourier transform
                                             Two-dimensional Fourier Transform


Properties of the Fourier matrix


   Lemma

                                    −1                    1
                    F N FN = NI ⇐⇒ FN =                     FN
                                                          N

   Proof:   Multiply F N with FN and use
                                  N−1                   Np
                                          p        1 − ωN
               ωN ωN = 1,               (ωN )j =           =0 .
                                                   1 − ωN
                                  j=0




                              Fredrik Kahl   Image Analysis - Lecture 2
                                               Continuous Fourier transform
                   Review of Linear algebra
                                               Discrete Fourier Transform (DFT,FFT)
                         Fourier transform
                                               Two-dimensional Fourier Transform


The inversion formula

   This lemma gives us the following inversion formula
   Theorem

                                       N−1
            1                1                      −ku
     f =      F F ⇐⇒ f (k) =                  F (u)ωN ,          k = 0, . . . , N − 1
            N                N
                                       u=0


   Proof:
                                 1      1
                 F = Ff ⇒          F F = F Ff = If = f .
                                 N      N



                               Fredrik Kahl    Image Analysis - Lecture 2
                                            Continuous Fourier transform
               Review of Linear algebra
                                            Discrete Fourier Transform (DFT,FFT)
                     Fourier transform
                                            Two-dimensional Fourier Transform


Example



  Example
  N = 2, ω = −1:
                                          1 1
                           F2 =                       .
                                          1 −1
                              1                   4
                     f =            ⇒F =                     .
                              3                   −2




                           Fredrik Kahl     Image Analysis - Lecture 2
                                              Continuous Fourier transform
                   Review of Linear algebra
                                              Discrete Fourier Transform (DFT,FFT)
                         Fourier transform
                                              Two-dimensional Fourier Transform


Example



  Example
  N = 4, ω = −i:
                                      
                             1 1 1  1
                           1 −i −1 i 
                      F4 =            
                           1 −1 1 −1 .
                             1 i −1 −i




                               Fredrik Kahl   Image Analysis - Lecture 2
                                               Continuous Fourier transform
                  Review of Linear algebra
                                               Discrete Fourier Transform (DFT,FFT)
                        Fourier transform
                                               Two-dimensional Fourier Transform


Factorization of the Fourier matrix
   N = 22 = 4, ω = ω4 , τ = ω 2
                                                
                    1 1 1                    1
                  1 ω ω 2                   ω3
            F4 = 1 ω 2 ω 4
                                                 =
                                             ω6
                    1 ω3 ω6                  ω9
                                                                    
                    1 1 1                    1      1      0    0     0
                  1 ω 2 ω                     3 
                                             ω  0        0    1     0
                =1 ω 4 ω 2
                                                                       =
                                             ω 6  0      1    0     0
                    1 ω6 ω3                  ω9     0      0    0     1
                                                          
                       1 1                1 1
                   1 τ                   ω ωτ  
                =                              P
                   1 1                  −1 −1  4
                       1 τ               −ω −ωτ

                              Fredrik Kahl     Image Analysis - Lecture 2
                                             Continuous Fourier transform
                  Review of Linear algebra
                                             Discrete Fourier Transform (DFT,FFT)
                        Fourier transform
                                             Two-dimensional Fourier Transform


Factorization of the Fourier matrix (ctd.)


   P4 denotes a 4 × 4 permutation matrix (a matrix with zeros and
   ones, where each row and each column only contains one one).
                            
                   1 0
          F2      0 ω
                         F2 
                                                  F2 0
    F4 =                     P4 = I D2                    P4
                   1 0               I −D2       0 F2
           F2 −           F2
                    0 ω

   where
                              D2 = diag(1, ω) .




                              Fredrik Kahl   Image Analysis - Lecture 2
                                             Continuous Fourier transform
                  Review of Linear algebra
                                             Discrete Fourier Transform (DFT,FFT)
                        Fourier transform
                                             Two-dimensional Fourier Transform


The Fast Fourier Transform (FFT)

  Theorem
  The Fourier Matrix can be factorized as
                             I DN            FN        0
                F2N =                                         P2N ,
                             I −DN            0       FN

  where
                                     2             N−1
                 DN = diag(1, ω2N , ω2N , . . . , ω2N ) .
  and P2N is a permutation matrix of order 2N × 2N that maps

      (x(0), x(1), . . . , x(2N − 1)) −→
      (x(0), x(2), . . . , x(2N − 2), x(1), x(3), . . . , x(2N − 1)) .


                              Fredrik Kahl   Image Analysis - Lecture 2
                                              Continuous Fourier transform
                   Review of Linear algebra
                                              Discrete Fourier Transform (DFT,FFT)
                         Fourier transform
                                              Two-dimensional Fourier Transform


The Fast Fourier Transform (FFT) (ctd.)




   Corollary
   Calculation of FN f thus involves two calculations of FN/2 f ,
   which involves 4 calculations of FN/4 f , etc.
   This algorithm is called the Fast Fourier Transform.




                               Fredrik Kahl   Image Analysis - Lecture 2
                                              Continuous Fourier transform
                   Review of Linear algebra
                                              Discrete Fourier Transform (DFT,FFT)
                         Fourier transform
                                              Two-dimensional Fourier Transform


Calculational complexity
   Let µn be the number of multiplications needed for calculating
   DFT of order 2n . Factorization gives

                             µn = 2µn−1 + 2n−1 .
   A solution to this recursion formula is
                        n2n   N log2 N
                 µn =       =                      om N = 2n .
                         2        2

   Example
   N = 1024 = 210
     ◮   FFT gives µ ∼ 104 multiplications.
     ◮   DFT gives N 2 ∼ 106 multiplications.

                               Fredrik Kahl   Image Analysis - Lecture 2
                                                Continuous Fourier transform
                  Review of Linear algebra
                                                Discrete Fourier Transform (DFT,FFT)
                        Fourier transform
                                                Two-dimensional Fourier Transform


Two-dimensional Fourier Transform

  Definition
  Let f (x, y) be a function from R2 to R. The Fourier transform of
  f is defined as
                                         +∞
       Ff (u, v) = F (u, v) =                  e−i2π(ux+vy ) f (x, y)dxdy .
                                       −∞



  This can be written (using u = (u, v), x = (x, y)):
                                    +∞
                    F (u) =                  e−i2πu·xf (x)d x .
                                   −∞




                              Fredrik Kahl      Image Analysis - Lecture 2
                                              Continuous Fourier transform
                   Review of Linear algebra
                                              Discrete Fourier Transform (DFT,FFT)
                         Fourier transform
                                              Two-dimensional Fourier Transform


The inversion formula in 2D



   Theorem
   Under certain conditions on f , the following inversion formula
                                 +∞
               f (x, y) =             ei2π(ux+vy ) F (u, v)dudv
                               −∞

   holds.




                               Fredrik Kahl   Image Analysis - Lecture 2
                                               Continuous Fourier transform
                  Review of Linear algebra
                                               Discrete Fourier Transform (DFT,FFT)
                        Fourier transform
                                               Two-dimensional Fourier Transform


Properties of the 2D Fourier transformation
   Properties: (in addition to those for the 1-D Fourier Transform)

                f1 (x)f2 (y) → F1 (u)F2 (v) (separability)
                    f (Qx) → F (Qu)                  (rotation)

   where Q denotes an orthogonal matrix.
   Example

                 rect(x) rect(y) → 4 sinc(2πu) sinc(2πv)
                        δ(x)1(y) → 1(u)δ(v)
                    δ(x) rect(y) → 1(u)2 sinc(2πv)
            f (x − 1) + f (x + 1) → (e−i2πu + ei2πu )F (u) =
                                             = 2 cos(2πu)F (u)

                              Fredrik Kahl     Image Analysis - Lecture 2
                                              Continuous Fourier transform
                   Review of Linear algebra
                                              Discrete Fourier Transform (DFT,FFT)
                         Fourier transform
                                              Two-dimensional Fourier Transform


A useful fact



   If f real (usual case for images):
     ◮   even f → real F
     ◮   odd f → imaginary F
     ◮   F (u) = F (−u)
   Observe: F (u, v) is in general complex valued. It is common to
   illustrate the transform with |F (u, v)|.




                               Fredrik Kahl   Image Analysis - Lecture 2
                                               Continuous Fourier transform
                   Review of Linear algebra
                                               Discrete Fourier Transform (DFT,FFT)
                         Fourier transform
                                               Two-dimensional Fourier Transform


DFT and FFT in two dimensions
  The discrete Fourier Transform (DFT) of f is defined as
                   M−1 N−1
                                                   ux   vy
      F (u, v) =                f (x, y)e−i2π( M + N ) =
                   x=0 y =0
                   M−1 N−1
                                         ux vy
              =                 f (x, y)ωM ωN =
                   x=0 y =0
                                                                                     
                                                                             1
                                                                           ωNv       
                                                                                     
                   u               2u               (M−1)u                  2v
                                                                            ωN        
              = 1 ωM              ωM . . . ωM                    f                   ,
                                                                            .
                                                                             .        
                                                                            .        
                                                                            (N−1)v
                                                                       ωN
             x = 0, . . . , M − 1,            y = 0, . . . N − 1 .
                               Fredrik Kahl    Image Analysis - Lecture 2
                                             Continuous Fourier transform
                  Review of Linear algebra
                                             Discrete Fourier Transform (DFT,FFT)
                        Fourier transform
                                             Two-dimensional Fourier Transform


DFT in Matrix form


   Let the matrix F represent the Fourier transform of the image
   f (x, y):
                            F = FM f FN
   or
                              F = FM (FN f T )T .
   i.e. the DFT in two dimensions can be calculated by repeated
   use of the one-dimensional DFT, first for the rows, then for the
   columns.




                              Fredrik Kahl   Image Analysis - Lecture 2
                           Continuous Fourier transform
Review of Linear algebra
                           Discrete Fourier Transform (DFT,FFT)
      Fourier transform
                           Two-dimensional Fourier Transform


   f                   DFT




                                                           DFT




                                           F
            Fredrik Kahl   Image Analysis - Lecture 2
                                            Continuous Fourier transform
                 Review of Linear algebra
                                            Discrete Fourier Transform (DFT,FFT)
                       Fourier transform
                                            Two-dimensional Fourier Transform


FFT on images


  Let the M × N-matrix f represent an image f (x, y).
  Extend the image periodically




                             Fredrik Kahl   Image Analysis - Lecture 2
                                            Continuous Fourier transform
                 Review of Linear algebra
                                            Discrete Fourier Transform (DFT,FFT)
                       Fourier transform
                                            Two-dimensional Fourier Transform


FFT on images (ctd.)


  FFT gives a double periodic function



                                        fftshift




  It is common to move the origin to the middle of the image for
  illustration purposes.



                             Fredrik Kahl   Image Analysis - Lecture 2
                                              Continuous Fourier transform
                   Review of Linear algebra
                                              Discrete Fourier Transform (DFT,FFT)
                         Fourier transform
                                              Two-dimensional Fourier Transform


Interpretation of the Fourier Transform



    ◮   Usually, the gray-levels of the Fourier Transform images
        are scaled using c log(1 + |F (u, v)|).
    ◮   The middle of the Fourier image (after fftshift) corresponds
        to low frequencies.
    ◮   Outside the middle high components in F corresponds to
        higher frequencies and the direction corresponds to
        "edges"in the images with opposite orientation.




                               Fredrik Kahl   Image Analysis - Lecture 2
                                             Continuous Fourier transform
                  Review of Linear algebra
                                             Discrete Fourier Transform (DFT,FFT)
                        Fourier transform
                                             Two-dimensional Fourier Transform


Example

  What does the original image look like if this is the Fourier
  transform?




  Left: Magnitude, Right: Phase


                              Fredrik Kahl   Image Analysis - Lecture 2
                                    Continuous Fourier transform
         Review of Linear algebra
                                    Discrete Fourier Transform (DFT,FFT)
               Fourier transform
                                    Two-dimensional Fourier Transform


Answer




                     Fredrik Kahl   Image Analysis - Lecture 2
                                              Continuous Fourier transform
                   Review of Linear algebra
                                              Discrete Fourier Transform (DFT,FFT)
                         Fourier transform
                                              Two-dimensional Fourier Transform


Masters thesis suggestion of the day: Crossword
reader/solver




   Construct a system for automatic crossword scanning and
   solution. Idea: Take an image, find squares with text and
   without, interpret the text. Is it possible to solve crosswords
   automatically?




                               Fredrik Kahl   Image Analysis - Lecture 2
                                             Continuous Fourier transform
                  Review of Linear algebra
                                             Discrete Fourier Transform (DFT,FFT)
                        Fourier transform
                                             Two-dimensional Fourier Transform


Review - Lecture 2


    ◮   Linear Algebra
    ◮   Subspaces
    ◮   Projections, Pseudo-inverse
    ◮   Image matrix
    ◮   Fourier Transform in 1 and 2 dimensions
    ◮   Discrete Fourier Transform in 1 and 2 dimensions
    ◮   Fast Fourier Transform (FFT)




                              Fredrik Kahl   Image Analysis - Lecture 2