Fast Fourier Transform December 8, 2016 FFT
JPEG RGB Y C B C R (luma (brightness), chroma 2 (color)) chroma resolution is reduced image is split in blocks 8 8 pixels
JPEG RGB Y C B C R (luma (brightness), chroma 2 (color)) chroma resolution is reduced image is split in blocks 8 8 pixels DCT - Discrete Cosine Transform (1974) 2D spatial domain frequency domain Functions can be decomposed into sums of sines and cosines (i.e. waves or harmonics) of various frequencies.
JPEG RGB Y C B C R (luma (brightness), chroma 2 (color)) chroma resolution is reduced image is split in blocks 8 8 pixels DCT - Discrete Cosine Transform (1974) 2D spatial domain frequency domain Functions can be decomposed into sums of sines and cosines (i.e. waves or harmonics) of various frequencies. quantization (irreversible): discard high-frequency info (human eye is more sensitive to small variations in color or brightness over large areas than to the strength of high-frequency brightness variations) further compression with lossless algorithm
2D spatial domain frequency domain DCT - Discrete Cosine Transform, acts on the sample x k DFT - Discrete Fourier Transform, acts on the sample x k Fourier Transform, f (x) nonrepetitive signal, -period, f = Fourier series, f (x) repetitive signal, oscillation, 2π-period f (x)...... k=0
Spatial domain frequency domain Source: Wikipedia
History and Motivation 3rd century BC: empiric model of planetary motions, based on deferents and epicycles
History and Motivation 3rd century BC: empiric model of planetary motions, based on deferents and epicycles 1747 - d Alembert: wave equation - string oscillations Bernoulli: general solution of wave equation as harmonic series 1775 - Leonard Euler: relation between the coeffecient of the series and parameters of the string
History and Motivation 3rd century BC: empiric model of planetary motions, based on deferents and epicycles 1747 - d Alembert: wave equation - string oscillations Bernoulli: general solution of wave equation as harmonic series 1775 - Leonard Euler: relation between the coeffecient of the series and parameters of the string 1807 - Jean-Baptiste Joseph Fourier: solutions of the heat equation in a metal plate as a superposition (linear combination) of simple sine and cosine function Tomson, Michelson: mechanical harmonic analysor for tides predictions and optics Dirichlet and Riemann: math precision
Fourier Series Any 2π-periodic function f (x) can be expanded in Fourier series f (x) a 0 2 + a n cos(nx) + b n sin(nx) n=1
Fourier Series Any 2π-periodic function f (x) can be expanded in Fourier series f (x) a 0 2 + a n cos(nx) + b n sin(nx) n=1 = a 0 2 + a 1 cos x + b 1 sin x + a 2 cos(2x) + b 2 sin(2x) +... + a N cos(nx) + b N sin(nx) +...
Fourier Series Any 2π-periodic function f (x) can be expanded in Fourier series f (x) a 0 2 + a n cos(nx) + b n sin(nx) n=1 = a 0 2 + a 1 cos x + b 1 sin x + a 2 cos(2x) + b 2 sin(2x) +... + a N cos(nx) + b N sin(nx) +... where a 0 = 1 π a n = 1 π π π π π f (x) dx, f (x) cos(nx) dx, b n = 1 π π π f (x) sin(nx) dx
Example f (x) = 1 1 + x 2 cos 2 (x) on [0, π]
Example N = 0: f (x) 0.6332
Example N = 1: f (x) 0.6332 + 0.3926 cos x
Example N = 2: f (x) 0.6332 + 0.3926 cos x 0.1931 cos(2x)
Example N = 3: f (x) 0.6332 + 0.3926 cos x 0.1931 cos(2x) + 0.0531 cos(3x)
Example N = 4: f (x) + 0.1292 cos(4x)
Example N = 5: f (x) 0.0054 cos(5x)
Example N = 6: f (x) 0.0306 cos(6x)
Example N = 7: f (x) + 0.0153 cos(7x)
Example N = 8: f (x) + 0.0110 cos(8x)
Example N = 9: f (x) 0.0052 cos(9x)
Generalization to complex-valued functions: where f (x) = n= c n e inx c n = 1 π f (x)e inx dx 2π π Fourier series converges at each point x for piecewise smooth functions!! FFT
Nonperiodic Functions: Fourier Transform: time (sec) > frequency (hertz) For f (x) integrable on (, ) f (ξ) = f (x)e 2πixξ dx Inverse Fourier Transform f (x) = f (ξ)e 2πixξ dξ FFT
Discrete Fourier Transform Sequence of N complex numbers x 0, x 1,..., x N 1 is transformed into N-periodic sequence of complex numbers X k = N 1 n=0 Thus the domain in k [0, N 1] x k e 2πikn/N, k Z FFT
Discrete Fourier Transform - Linear C n C n Euler s formula gives X k = N 1 n=0 x n (cos( 2πk n N ) + i sin( 2πk n N )), k Z Inverse Fourier Transform: x n = 1 N N 1 k=0 X k (cos(2πk n N ) + i sin(2πk n N )), n Z N = number of time samples we have n = current sample we re considering (0,..., N 1) x n = value of the signal at time n k = current frequency we re considering (0 Hertz up to N 1 Hertz) X k = amount of frequency k in the signal (Amplitude and Phase, a complex number) FFT
Direct computation - Fourier Matrix 1 1 1 1 1 1 ω ω 2 ω 3 ω N 1 W N = 1 1 ω 2 ω 4 ω 6 ω 2(N 1) N 1 ω 3 ω 6 ω 9 ω 3(N 1),........ 1 ω N 1 ω 2(N 1) ω 3(N 1) ω (N 1)(N 1) Notice W N = W T N, complex number ω = ei2π/n, so ω N = 1 (N-th root of unity) Then Fourier transform X = W N x FFT
Example for N = 4 ω 0 ω 0 ω 0 ω 0 1 1 1 1 W 4 = ω 0 ω 1 ω 2 ω 3 ω 0 ω 2 ω 0 ω 2 = 1 i 1 i 1 1 1 1 ω 0 ω 3 ω 2 ω 1 1 i 1 i where ω = e πi 2 = iω = e πi 2 = i. Property: 1 4 W H 4 W 4 = I (so called hermitian trasnform) FFT
Example Single impulse at time 0 is x = [1 0 0 0] T DFT (x = X = W 4 x = 1 1 1 1 1 i 1 i 1 1 1 1 1 i 1 i 1 0 0 0 = 1 1 1 1 Meaning: A single impulse has all frequencies in equal amounts. Get back, inverse transform 1 1 1 1 1 i 1 i 1 1 1 1 1 i 1 i 1 1 1 1 = 4 0 0 0 = 4 1 0 0 0 FFT
Problem Direct computation X = W N x requires N 2 multiplications and N(N 1) additions. That s A LOT!!! Hence: FFT - Fast Fourier Transform: J.W. Cooley (IBM) and J.W. Tukey (Princeton) in 1960s Idea may be traced back to Gauss. FFT
The discrete Fourier transform (DFT): X k = N 1 n=0 x n e 2πi N nk, where 0 k N 1. For N as power of 2, N = 2 l, calculate separately ( decimation in time ) (x 2m = x 0, x 2,..., x N 2 ) (x 2m+1 = x 1, x 3,..., x N 1 ) Recursively: runtime O(N log N) FFT
Split: X k = = N/2 1 m=0 N/2 1 x 2m e 2πi N (2m)k + N/2 1 m=0 x 2m e 2πi N/2 mk m=0 }{{} DFT of even indexed part of x m x 2m+1 e 2πi N (2m+1)k + e 2πi N k N/2 1 m=0 x 2m+1 e 2πi N/2 mk }{{} DFT of odd indexed part of x m = EVEN k + e 2πi N k ODD k. Periodicity: and E k+ N 2 O k+ N 2 = E k = O k. FFT
For 0 k N/2: size-2 DFT ( butterfly ) X k = E k + e 2πi N k O k 0, 1,..., N/2 1 X k+ N 2 = E k e 2πi N k O k N/2, N/2 + 1,..., N 1 Recursive procedure: split even and odd x[2n] and x[2n + 1] compute DFT split divide and conquer algorithm - multi-branched recursion FFT
FFT
Fourier unit pulse FFT