1 ft intrositus.biomachina.org/hn06/talks/wriggers/1_ft_intro_new.pdf · periodic signals on a grid...

38
Fourier Theory Willy Wriggers School of Health Information Sciences & Institute of Molecular Medicine University of Texas Houston

Upload: others

Post on 05-Aug-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

Fourier TheoryWilly Wriggers

School of Health Information Sciences & Institute of Molecular MedicineUniversity of Texas – Houston

Page 2: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

Frequency Analysis

© http://www.cs.sfu.ca/~hamarneh/courses/cmpt340_04_1© http://www.physics.gatech.edu/gcuo/UltrafastOptics/PhysicalOptics/

Here, we write a square wave as a sum of sine waves:

Page 3: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

Transforms with FunctionsJust as we transformed vectors, we can also transform functions:

Inverse

Transform

Basis Functions {ek(t)}Basis Vectors {ēk[j]}

∑ ⋅=⋅=j

kkk jejveva ][][

∑=k

kkeav

*( ) ( )k k ka f e f t e t dt∞

−∞

= ⋅ = ∫

)()( teatfk

kk∑=

Page 4: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

The Fourier TransformMost tasks need an infinite number of basis functions (frequencies), each with their own weight F(s): Harmonics {ei2πst}

Inverse

Transform

Fourier TransformFourier Series

∫∞

∞−

−=

⋅=

dtetf

efsF

sti

sti

π

π

2

2

)(

)(

2( ) ( ) i stf t F s e dsπ∞

−∞

= ∫

∫∞

∞−

−=

⋅=

dtetf

efa

tsi

tsik

k

k

π

π

2

2

)(

∑=k

tsik

keatf π2)(

Page 5: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

The Fourier TransformTo get the weights (amount of each frequency):F

To convert weights back into a signal (invert the transform):

F(s) is the Fourier Transform of f(t): F(f(t)) = F(s)

f(t) is the Inverse Fourier Transform of F(s): F-1(F(s)) = f(t)

∫∞

∞−

−= dtetfsF sti π2)()(

∫∞

∞−

= dsesFtf sti π2)()(

Page 6: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

How to Interpret the Weights F(s)The weights F(s) are complex numbers:

How much of a sinusoid of frequency s you need

What phase that sinusoid needs to be

Magnitude

Phase

How much of a cosine of frequency s you need

How much of a sine of frequency s you need

Real part

Imaginary part

Real

Imaginary

1-1

i

-i

i

Page 7: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

Euler’s Formula• Any complex number can be represented using Euler’s formula:

z = |z|eiφ (z) = |z|cos(φ ) + |z|sin(φ )i = a + bi

Real

Imaginary

1-1

i

-i

b

a = |z|cos(φ )b = |z|sin(φ )

Page 8: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

Magnitude and PhaseRemember: complex numbers can be thought of in two ways: (real, imaginary) or (magnitude, phase)

Magnitude:

Phase:

22 )()( FFF ℑ+ℜ=

⎟⎟⎠

⎞⎜⎜⎝

⎛ℑℜ

=)()(arctan)(

FFFφ

© www.dai.ed.ac.uk/HIPR2/ fourier.htm

image |F| ɸ (F)

Page 9: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

Periodic Signals on a Grid• Periodic signals with period N:

Underlying frequencies must also repeat over the period NEach component frequency must be a multiple of the frequency of the periodic signal itself:

• If the signal is discrete:Highest frequency is one unit: period repeats after a single sample

No more than N components

,3 ,2 ,1NNN

NN

NNN ,3 ,2 ,1

Page 10: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

Discrete Fourier Transform (DFT)If we treat a discrete signal with N samples as one period of an infinite periodic signal, then

and

Note: For a periodic function, the discrete Fourier transform is the same as the continuous transform

We give up nothing in going from a continuous to a discrete transform as long as the function is periodicComputational complexity: O(N2)

∑−

=

π−=

1

0

2][1][

N

t

Nsti

etfN

sF

∑−

=

π=

1

0

2][][

N

s

Nsti

esFtf

Page 11: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

Fast Fourier Transform

If we let

the Discrete Fourier Transform can be written

If N is a multiple of 2, N = 2M for some positive integer M, substituting 2M for N gives

Ni

N eWπ−

=2

∑−

=⋅=

1

0][1][

N

t

stNWtf

NsF

∑−

=⋅=

12

02][

21][

M

t

stMWtf

MsF

developed by Tukey and Cooley in 1965

Page 12: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

Fast Fourier Transform

Separating even and odd terms:

Can be written as

We can use this for the first M terms of the Fourier transform of 2M items, then we can re-use these values to compute the last Mterms as follows:

⎪⎭

⎪⎬⎫

⎪⎩

⎪⎨⎧

⋅++⋅= ∑ ∑−

=

=

1

0

1

02]12[1]2[1

21][

M

t

M

t

sM

stM

stM WWtf

MWtf

MsF

{ }sModdeven WsFsFsF 2)()(

21][ +=

{ }sModdeven WsFsFMsF 2)()(

21][ −=+

Page 13: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

Fast Fourier TransformIf M is itself a multiple of 2, do it again!

If N is a power of 2, recursively subdivide until you have one element, which is its own Fourier Transform

ComplexSignal FFT(ComplexSignal f) {if (length(f) == 1) return f;

M = length(f) / 2;W_2M = e^(-I * 2 * Pi / M) // A complex value.

even = FFT(EvenTerms(f));odd = FFT(OddTerms(f));

for (s = 0; s < M; s++) {result[s ] = even[s] + W_2M^s * odd[s];result[s+M] = even[s] – W_2M^s * odd[s];

}}

Page 14: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

Fast Fourier TransformComputational Complexity:

Remember: The FFT is just a faster algorithm for computing the DFT — it does not produce a different result

O(N log N)Fast Fourier Transform

O(N2)Discrete Fourier Transform

Page 15: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

ImpulsesOne way of probing what a system does is to test it on a single input point (a single spike in the signal, a single point of light, etc.)

Mathematically, a perfect single-point input is written as:

δ(t) =

and

δ(t)dt = 1

This is called the Dirac delta function

⎧⎨⎩

∞ if t = 00 otherwise

⌠⌡-∞

Page 16: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

Delta Function and its FT

1δ (t)

Frequency DomainF(s)

Spatial Domainf(t)

© http://www.cis.rit.edu/htbooks/nmr/chap-5/chap-5.htm

Page 17: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

Sinusoids

½[δ(s + ω) + δ(s – ω)]

½[δ(s + ω) - δ(s – ω)]i

cos(2πωt)

sin(2πωt)

Frequency DomainF(s)

Spatial Domainf(t)

Page 18: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

Constant Functions

δ (s)

a δ (s)

1

a

Frequency DomainF(s)

Spatial Domainf(t)

© http://www.cis.rit.edu/htbooks/nmr/chap-5/chap-5.htm

Page 19: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

Square Pulse

Πa(t)

Frequency DomainF(s)

Spatial Domainf(t)

sin(2 )2 sinc(2 ) asa assπ

π=

Adapted from http://www.med.harvard.edu/JPNM/physics/didactics/improc/intro/fourier3.html

Page 20: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

Triangle

a sinc2(as)Λa(t)

Frequency DomainF(s)

Spatial Domainf(t)

t0

1/ 2 ( )t∆1

1/2-1/2 s0

21/2 sinc ( / 2)s0.5

Page 21: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

Comb (Shah) Function

δ (t mod 1/h)combh(t) = δ (t mod h)

Frequency DomainF(s)

Spatial Domainf(t)

© http://www.cis.rit.edu/htbooks/nmr/chap-5/chap-5.htm

Page 22: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

Gaussian

http://www.med.harvard.edu/JPNM/physics/didactics/improc/intro/fourier3.html

( )2se π σ−2t

σ⎛ ⎞− ⎜ ⎟⎝ ⎠

Page 23: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

2D and 3D FTsThe 2D Fourier Transform is linearly separable: the Fourier Transform of a 2D image is the 1D Fourier Transform of the rows followed by the 1D Fourier Transforms of the resulting columns:

MvyiM

y

N

x

Nuxi

MvyiN

x

M

y

Nuxi

N

x

M

y

MvyNuxi

eeyxfNM

eeyxfNM

eyxfNM

vuF

/21

0

1

0

/2

/21

0

1

0

/2

1

0

1

0

)//(2

],[1 1

],[ 1

],[ 1],[

ππ

ππ

π

−−

=

=

−−

=

=

=

=

+−

∑ ∑

∑ ∑

∑ ∑

⎥⎥⎦

⎢⎢⎣

=

=

Similar for 3D!

Page 24: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

FT Properties: Addition TheoremAdding two functions together adds their Fourier Transforms:

F(f + g) = F(f) + F(g)

Multiplying a function by a scalar constant multiplies its Fourier Transform by the same constant:

F(a f) = aF(f)

Consequence: Fourier Transform is a linear transformation!

Page 25: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

FT Properties: Shift TheoremTranslating (shifting) a function leaves the magnitude unchanged and adds a constant to the phase

If f2(t) = f1(t – a)

F1 = F(f1) F2 = F(f2)

then|F2| = |F1|

φ (F2) = φ (F1) - 2πsa

Intuition: magnitude tells you “how much”,phase tells you “where”

Page 26: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

FT Properties: Scaling TheoremScaling a function’s abscissa (domain or horizontal axis) inversely scales the both magnitude and abscissa of the Fourier transform.

If f2(t) = f1(a t)

F1 = F(f1) F2 = F(f2)

thenF2(s) = (1/|a|) F1(s / a)

Page 27: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

FT Properties: RotationRotating a 2-D function rotates it’s Fourier Transform

Iff2 = rotateθ(f1)

= f1(x cos(θ) – y sin(θ), x sin(θ) + y cos(θ))

F1 = F(f1)

F2 = F(f2)

thenF2(s) = F1(x cos(θ) – y sin(θ), x sin(θ) + y cos(θ))

i.e., the Fourier Transform is rotationally invariant.

Page 28: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

Rotation Invariance (sort of)

© http://mail.udlap.mx/~oldwall/docencia/IMAGENES/chapter2/image_232_IS548.html

needsmoreboundarypadding!

Page 29: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

Convolution

( ) ( ) ( )f t g t f g t dτ ( τ) τ∞

−∞

∗ = −∫

Page 30: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

FT Properties: Convolution TheoremConvolution

f (t) * g(t) ↔ F(s) G(s)

Correlation

f (t) * g(-t) ↔ F(s) G*(s)

Page 31: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

FT Properties: Convolution TheoremLet F, G, and H denote the Fourier Transforms of signals f, g, and h respectively

g = f(t) * h(t) implies G = F(s) H(s)

g = f(t) h(t) implies G = F(s) * H(s)

g = f(t) * h(-t) implies G = F(s) H* (s)

g = f(t) h(-t) implies G = F(s) * H*(s)

Convolution in one domain is multiplication in the other and vice versa

Page 32: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

Template “Convolution”

•Actually, is a correlation method•Goal: maximize correlation between target and probe image•Here: only translations allowed but rotations also possible

target probe

© http://www.reindeergraphics.com/tutorial/chap4/fourier11.html

Page 33: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

Particle Picking

•Use spherical, or rotationally averaged probes•Goal: maximize correlation between target and probe image

target probe

microscope image of latex spheres

© http://www.reindeergraphics.com/tutorial/chap4/fourier11.html

Page 34: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

Power SpectrumThe power spectrum of a signal is the Fourier Transform of its autocorrelation function:

P(s) = F(f (t) * f (-t))

= F(s) F*(s)

= |F(s)|2

It is also the squared magnitude of the Fourier transform of thefunction

It is entirely real (no imaginary part).

Useful for detecting periodic patterns / texture in the image.

Page 35: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

Use of Power Spectrum in Filtering

Original with noise patterns Power spectrum showing noise spikes

Mask to remove periodic noise Inverse FT with periodic noise removed© http://www.reindeergraphics.com/tutorial/chap4/fourier13.html

Page 36: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

FT Properties: Rayleigh’s Theorem

Total sum of squares is the same in either domain:

2 2( ) ( ) ( ) f t dt F s ds P s ds∞ ∞ ∞

−∞ −∞ −∞

= =∫ ∫ ∫

Page 37: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

Figure and Text Credits

Text and figures for this lecture were adapted in part from the following source, in agreement with the listed copyright statements:

http://web.engr.oregonstate.edu/~enm/cs519© 2003 School of Electrical Engineering and Computer Science, Oregon State University, Dearborn Hall, Corvallis, Oregon, 97331

Page 38: 1 ft intrositus.biomachina.org/hn06/talks/Wriggers/1_ft_intro_new.pdf · Periodic Signals on a Grid • Periodic signals with period N: Underlying frequencies must also repeat over

Resources

Textbooks:Kenneth R. Castleman, Digital Image Processing, Chapter 10John C. Russ, The Image Processing Handbook, Chapter 5