The Fourier Transform CS/BIOEN 4640: Image Processing Basics March 20, 2012 Why Study Spectral Methods? I Is often more efficient method for filtering than convolution I Helps us understand image sampling, filtering, and aliasing I Used in image compression I Important for solving PDEs in image processing I Fourier transform used in MRI Harmonic Analysis I I Decompose a function into basic waves called “harmonics” 0 1 1/2 1/3 Any signal can be written as a summation of harmonics 1/4 1/5 I Think of sound waves and music: harmonics are pure tones 1/6 1/7 Sine and Cosine Functions 1.0 Harmonics are given by sine and cosine functions −1.0 −0.5 0.0 0.5 sin cos 0 1 2 3 4 5 6 7 1.0 Wave Properties: Frequency Frequency is how many times a wave repeats. 0.0 0.5 sin(t) sin(2t) sin(3t) sin(ωx) −0.5 cos(ωx) and −1.0 ω is the frequency 0 1 2 3 4 5 6 3 Wave Properties: Amplitude 2 sin(t) 2 sin(t) 3 sin(t) 0 1 Amplitude is the height of the wave. −1 a·cos(x) and a·sin(x) −3 −2 a is the amplitude 0 1 2 3 4 5 6 1.0 Wave Properties: Phase sin(t) sin(t − pi/4) sin(t − pi/2) 0.0 0.5 Phase is the horizontal shift of the wave. −0.5 cos(x−φ) and sin(x−φ) −1.0 φ is the phase shift 0 1 2 3 4 5 6 Who’s This Guy? While studying heat conduction, Fourier discovered that functions could be decomposed into summations of cosine waves with different amplitudes and frequencies. Jean Baptiste Joseph de Fourier (1768 - 1830) Trivia fact: Fourier also first described the greenhouse effect! Fourier Series Definition Consider a function g(x) that is periodic on [0, 2π ω ] 0 It’s Fourier series is given as g(x) = ∞ X [ Ak cos(kω0 x) + Bk sin(kω0 x)] , k=0 where Ak , Bk are constants called the Fourier coefficients. Complex Numbers Definition A complex number is an ordered pair of real numbers, z = (a, b), with a the real part and b the imaginary part. Also written as where i = √ z = a + ib, −1 is the imaginary unit. The set of complex numbers is denoted C. Complex Numbers as 2D Coordinates Im b a+bi The real and imaginary parts of z = a + ib are the coordinates: Re{z} = a Im{z} = b 0 a Re Complex Number Arithmetic Take two complex numbers z1 = (a1 , b1 ) and z2 = (a2 , b2 ). I Addition z1 + z2 = (a1 + a2 , b1 + b2 ) I Multiplication z1 · z2 = (a1 + ib1 ) · (a2 + ib2 ) = (a1 a2 − b1 b2 ) + i(a1 b2 + a2 b1 ) Conjugation and Absolute Value Consider a complex number z = (a, b) I Conjugation: Simply negate the imaginary part: z∗ = a − ib I Absolute value: Same as 2D vector length: p |z| = a2 + b2 √ Also given by |z| = z · z∗ Euler’s Representation of Complex Numbers Im r φ 0 Re I A complex number can be given as an angle φ and a radius r I Think 2D polar coordinates I Exponential form: reiφ = r cos(φ) + i (r sin(φ)) Operations in Euler’s Notation Take z1 = r1 eiθ1 and z2 = r2 eiθ2 . I Multiplication: z1 · z2 = r1 r2 ei(θ1 +θ2 ) I Conjugation: z∗1 = r1 e−iθ1 I Absolute value: |z1 | = r1 Fourier Integral For periodic functions we have the Fourier series: g(x) = ∞ X [ Ak cos(kω0 x) + Bk sin(kω0 x)] , k=0 But for nonperiodic functions we need a continuum of frequencies. So, our Fourier series becomes an integral: Z g(x) = ∞ Aω cos(ωx) + Bω sin(ωx) dω 0 Computing Fourier Coefficients Fourier coefficients describe how much a particular frequency ω contributes to the function g. They are computed by just multiplying and integrating with cos/sin waves: Z 1 ∞ g(x) · cos(ωx) dx Aω = A(ω) = π −∞ Z 1 ∞ Bω = B(ω) = g(x) · sin(ωx) dx π −∞ Fourier Transform Now, let’s put the B coefficient (the sine part) into the imaginary part of a complex number r h i π G(ω) = A(ω) − i · B(ω) 2 Z ∞ h i 1 √ = g(x) · cos(ωx) − i · sin(ωx) dx 2π Z−∞ ∞ 1 =√ g(x) · e−iωx dx 2π −∞