mestrado em ciência de computadores

43
Mestrado em Ciência de Computadores Mestrado Integrado em Engenharia de Redes e Sistemas Informáticos VC 14/15 – TP6 Frequency Space Miguel Tavares Coimbra

Upload: maxima

Post on 05-Jan-2016

20 views

Category:

Documents


1 download

DESCRIPTION

VC 14/15 – TP6 Frequency Space. Mestrado em Ciência de Computadores Mestrado Integrado em Engenharia de Redes e Sistemas Informáticos. Miguel Tavares Coimbra. Outline. Fourier Transform Frequency Space Spatial Convolution. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Mestrado em Ciência de Computadores

Mestrado em Ciência de Computadores

Mestrado Integrado em Engenharia de Redes e Sistemas Informáticos

VC 14/15 – TP6Frequency Space

Miguel Tavares Coimbra

Page 2: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

Outline

• Fourier Transform

• Frequency Space

• Spatial Convolution

Acknowledgements: Most of this course is based on the excellent courses offered by Prof. Shree Nayar at Columbia University, USA and by Prof. Srinivasa Narasimhan at CMU, USA. Please acknowledge the original source when reusing these slides for academic purposes.

Page 3: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

Topic: Fourier Transform

• Fourier Transform

• Frequency Space

• Spatial Convolution

Page 4: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

How to Represent Signals?

• Option 1: Taylor series represents any function using polynomials.

• Polynomials are not the best - unstable and not very physically meaningful.

• Easier to talk about “signals” in terms of its “frequencies”

(how fast/often signals change, etc).

Page 5: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

Jean Baptiste Joseph Fourier (1768-1830)

• Had a crazy idea (1807):• Any periodic function

can be rewritten as a weighted sum of Sines and Cosines of different frequencies.

• Don’t believe it? – Neither did Lagrange,

Laplace, Poisson and other big wigs

– Not translated into English until 1878!

• But it’s true!– called Fourier Series– Possibly the greatest tool used in Engineering

Page 6: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

A Sum of Sinusoids

• Our building block:

• Add enough of them to get any signal f(x) you want!

• How many degrees of freedom?

• What does each control?

• Which one encodes the coarse vs. fine structure of the signal?

xAsin(

Page 7: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

• We want to understand the frequency of our signal. So, let’s reparametrize the signal by instead of x:

• For every from 0 to inf, F() holds the amplitude A and phase of the corresponding sine

– How can F hold both? Complex number trick!

Fourier Transform

xAsin(

f(x) F()Fourier Transform

)()()( iIRF

22 )()( IRA )(

)(tan 1

R

I

Page 8: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

Time and Frequency

• example : g(t) = sin(2pf t) + (1/3)sin(2p(3f) t)

Page 9: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

Time and Frequency

• example : g(t) = sin(2pf t) + (1/3)sin(2p(3f) t)

= +

Page 10: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

Frequency Spectra

• example : g(t) = sin(2pf t) + (1/3)sin(2p(3f) t)

= +

Page 11: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

Frequency Spectra

• Usually, frequency is more interesting than the phase

Page 12: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

= +

=

Frequency Spectra

Page 13: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

= +

=

Frequency Spectra

Page 14: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

= +

=

Frequency Spectra

Page 15: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

= +

=

Frequency Spectra

Page 16: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

= +

=

Frequency Spectra

Page 17: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

= 1

1sin(2 )

k

A ktk

Frequency Spectra

Page 18: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

Fourier Transform – more formally

Arbitrary function Single Analytic Expression

Spatial Domain (x) Frequency Domain (u)

Represent the signal as an infinite weighted sum of an infinite number of sinusoids

dxexfuF uxi 2

(Frequency Spectrum F(u))

1sincos ikikeikNote:

Inverse Fourier Transform (IFT)

dxeuFxf uxi 2

Page 19: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

Fourier Transform

• Also, defined as:

dxexfuF iux

1sincos ikikeikNote:

• Inverse Fourier Transform (IFT)

dxeuFxf iux

2

1

Page 20: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

Properties of Fourier Transform

SpatialDomain

FrequencyDomain

Linearity xgcxfc 21 uGcuFc 21

Scaling axf

a

uF

a

1

Shifting 0xxf uFe uxi 02

Symmetry xF uf

Conjugation xf uF

Convolution xgxf uGuF

Differentiation n

n

dx

xfd uFui n2

Page 21: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

Topic: Frequency Space

• Fourier Transform

• Frequency Space

• Spatial Convolution

Page 22: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

How does this apply to images?

• We have defined the Fourier Transform as

• But images are:– Discrete.– Two-dimensional.

What a computer sees

dxexfuF iux

Page 23: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

2D Discrete FT

• In a 2-variable case, the discrete FT pair is:

1

0

1

0

)]//(2exp[),(1

),(M

x

N

y

NvyMuxjyxfMN

vuF

1

0

1

0

)]//(2exp[),(),(M

u

N

v

NvyMuxjvuFyxf

For u=0,1,2,…,M-1 and v=0,1,2,…,N-1

For x=0,1,2,…,M-1 and y=0,1,2,…,N-1

AND:

New matrix with the

same size!

Page 24: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

Frequency Space

• Image Space– f(x,y)– Intuitive

• Frequency Space– F(u,v)– What does this mean?

Page 25: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

Power distribution

An image (500x500 pixels) and its Fourier spectrum. The super-imposed circles have radii values of 5, 15, 30, 80, and 230, which respectively enclose 92.0, 94.6, 96.4, 98.0, and 99.5% of the image power.

Page 26: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

Power distribution

• Most power is in low frequencies.

• Means we are using more of this:

And less of this:

To represent our signal.

• Why?

Page 27: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space What does this mean??

Page 28: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

Horizontal and Vertical Frequency

• Frequencies:– Horizontal frequencies

correspond to horizontal gradients.

– Vertical frequencies correspond to vertical gradients.

• What about diagonal lines?

Page 29: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

Page 30: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency SpaceIf I discard high-frequencies, I get a blurred image...Why?

Page 31: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

Why bother with FT?

• Great for filtering.

• Great for compression.

• In some situations: Much faster than operating in the spatial domain.

• Convolutions are simple multiplications in Frequency space!

• ...

Page 32: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

Topic: Spatial Convolution

• Fourier Transform

• Frequency Space

• Spatial Convolution

Page 33: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

Convolution

f

hfgdxhfxg

h

h

x

kernel h

Page 34: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

Convolution - Example

fg

gf Eric Weinstein’s Math World

Page 35: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

Convolution - Example

1 2-1-2

xc

-1 1

1

xb

-1 1

1 xa

bac

1

Page 36: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

Convolution Kernel – Impulse Response

• What h will give us g = f ?

f gh hfg

Dirac Delta Function (Unit Impulse)

x2

1

0

Page 37: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

Point Spread Function

• Ideally, the optical system should be a Dirac delta function.

• However, optical systems are never ideal.

• Point spread function of Human Eyes.

OpticalSystemscene image

x xPSFOpticalSystem

point source point spread function

x2

1

0

Page 38: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

Point Spread Function

normal vision myopia hyperopia

Images by Richmond Eye Associates

Page 39: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

Properties of Convolution

• Commutative

• Associative

• Cascade system

abba

cbacba

f g1h 2h

f g21 hh

f g12 hh

Page 40: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

Fourier Transform and Convolution

hfg

dxexguG uxi 2

dxdexhf uxi 2

dxexhdef xuiui 22

'' '22 dxexhdef uxiui

Let Then

uHuF

Convolution in spatial domain

Multiplication in frequency domain

Page 41: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

Fourier Transform and Convolution

hfg FHG fhg HFG

Spatial Domain (x) Frequency Domain (u)

So, we can find g(x) by Fourier transform

g f h

G F H

FT FTIFT

Page 42: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

Example use: Smoothing/Blurring

• We want a smoothed function of f(x)

xhxfxg

• Then

222

2

1exp uuH

uHuFuG

2

1

u

uH

2

2

2

1exp

2

1

x

xh

• Let us use a Gaussian kernel

xh

x

Page 43: Mestrado em Ciência de Computadores

VC 14/15 - TP6 - Frequency Space

Resources

• Russ – Chapter 6

• Gonzalez & Woods – Chapter 4