Top Banner
Fourier Transform and Frequency Domain 16-385 Computer Vision Spring 2018, Lecture 3 (part 2) http://www.cs.cmu.edu/~16385/
91

Fourier Transform and Frequency Domain

Mar 24, 2022

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Fourier Transform and Frequency Domain

Fourier Transform and Frequency Domain

16-385 Computer VisionSpring 2018, Lecture 3 (part 2)http://www.cs.cmu.edu/~16385/

Page 2: Fourier Transform and Frequency Domain

Overview of today’s lecture

• Some history.

• Fourier series.

• Frequency domain.

• Fourier transform.

• Frequency-domain filtering.

• Revisiting sampling.

Page 3: Fourier Transform and Frequency Domain

Slide credits

Most of these slides were adapted from:

• Kris Kitani (15-463, Fall 2016).

Some slides were inspired or taken from:

• Fredo Durand (MIT).• James Hays (Georgia Tech).

Page 4: Fourier Transform and Frequency Domain

Some history

Page 5: Fourier Transform and Frequency Domain

Who is this guy?

Page 6: Fourier Transform and Frequency Domain

What is he famous for?

Jean Baptiste Joseph Fourier (1768-1830)

Page 7: Fourier Transform and Frequency Domain

What is he famous for?

Jean Baptiste Joseph Fourier (1768-1830)

‘Any univariate function can be rewritten as a weighted sum of sines and cosines of different frequencies.’

The Fourier series claim (1807):

… and apparently also for the discovery of the greenhouse effect

Page 8: Fourier Transform and Frequency Domain

Is this claim true?

Jean Baptiste Joseph Fourier (1768-1830)

‘Any univariate function can be rewritten as a weighted sum of sines and cosines of different frequencies.’

The Fourier series claim (1807):

Page 9: Fourier Transform and Frequency Domain

Is this claim true?

Jean Baptiste Joseph Fourier (1768-1830)

‘Any univariate function can be rewritten as a weighted sum of sines and cosines of different frequencies.’

The Fourier series claim (1807):

Well, almost.• The theorem requires additional conditions.• Close enough to be named after him.• Very surprising result at the time.

Page 10: Fourier Transform and Frequency Domain

Is this claim true?

Jean Baptiste Joseph Fourier (1768-1830)

‘Any univariate function can be rewritten as a weighted sum of sines and cosines of different frequencies.’

The Fourier series claim (1807):

Well, almost.• The theorem requires additional conditions.• Close enough to be named after him.• Very surprising result at the time.

Malus Lagrange Legendre Laplace

The committee examining his paper

had expressed skepticism, in part due

to not so rigorous proofs

Page 11: Fourier Transform and Frequency Domain

Amusing aside

1820 watercolor caricatures of French mathematicians Adrien-Marie Legendre (left) and Joseph Fourier (right) by French artist Julien-Leopold Boilly

Only known portrait of Adrien-Marie Legendre

For two hundred years, people were misidentifying this

portrait as him

Louis Legendre(same last name, different person)

Page 12: Fourier Transform and Frequency Domain

Fourier series

Page 13: Fourier Transform and Frequency Domain

Fourier’s claim: Add enough of these to get any periodic signal you want!

Basic building block

Page 14: Fourier Transform and Frequency Domain

Fourier’s claim: Add enough of these to get any periodic signal you want!

amplitude

angularfrequency

variablephase

sinusoid

Basic building block

Page 15: Fourier Transform and Frequency Domain

How would you generate this function?

Examples

= +? ?

Page 16: Fourier Transform and Frequency Domain

How would you generate this function?

Examples

= +? ?

Page 17: Fourier Transform and Frequency Domain

How would you generate this function?

Examples

= +? ?

Page 18: Fourier Transform and Frequency Domain

How would you generate this function?

Examples

+? ?

square wave

=

Page 19: Fourier Transform and Frequency Domain

How would you generate this function?

Examples

=

+? ?

square wave

Page 20: Fourier Transform and Frequency Domain

How would you generate this function?

Examples

=

+? ?

square wave

Page 21: Fourier Transform and Frequency Domain

How would you generate this function?

Examples

=

+? ?

square wave

Page 22: Fourier Transform and Frequency Domain

How would you generate this function?

Examples

=

+? ?

square wave

Page 23: Fourier Transform and Frequency Domain

How would you generate this function?

Examples

=

+? ?

square wave

How would you express this mathematically?

Page 24: Fourier Transform and Frequency Domain

Examples

square wave

=

infinite sum of sine waves

How would could you visualize this in the frequency domain?

Page 25: Fourier Transform and Frequency Domain

Examples

square wave

=

infinite sum of sine waves

magnitude

frequency

Page 26: Fourier Transform and Frequency Domain

Frequency domain

Page 27: Fourier Transform and Frequency Domain

frequency

amplitude

Visualizing the frequency spectrum

Page 28: Fourier Transform and Frequency Domain

frequency

amplitude

Visualizing the frequency spectrumRecall the temporal domain visualization

+=

Page 29: Fourier Transform and Frequency Domain

frequency

amplitude

Visualizing the frequency spectrumRecall the temporal domain visualization

+=

How do we plot ...

Page 30: Fourier Transform and Frequency Domain

frequency

amplitude

Visualizing the frequency spectrumRecall the temporal domain visualization

+=

Page 31: Fourier Transform and Frequency Domain

frequency

amplitude

Visualizing the frequency spectrumRecall the temporal domain visualization

+=

Page 32: Fourier Transform and Frequency Domain

not visualizing the symmetric negative part

Need to understand this to understand the 2D version!

frequency

amplitude

Visualizing the frequency spectrum

What is at zero frequency?

Recall the temporal domain visualization

+=

Page 33: Fourier Transform and Frequency Domain

not visualizing the symmetric negative part

Need to understand this to understand the 2D version!

frequency

amplitude

Visualizing the frequency spectrum

signal average (zero for a sine wave with

no offset)

Recall the temporal domain visualization

+=

Page 34: Fourier Transform and Frequency Domain

Spatial domain visualization Frequency domain visualization

1D

2D

Examples

?

Page 35: Fourier Transform and Frequency Domain

Spatial domain visualization Frequency domain visualization

1D

2D

Examples

What do the three dots correspond to?

Page 36: Fourier Transform and Frequency Domain

Spatial domain visualization Frequency domain visualization

Examples

?

Page 37: Fourier Transform and Frequency Domain

Spatial domain visualization Frequency domain visualization

Examples

Page 38: Fourier Transform and Frequency Domain

How would you generate this image with sine waves?

Examples

Page 39: Fourier Transform and Frequency Domain

How would you generate this image with sine waves?

Examples

Has both an x and y components

Page 40: Fourier Transform and Frequency Domain

Examples

=+ ?

Page 41: Fourier Transform and Frequency Domain

Examples

=+

?

Page 42: Fourier Transform and Frequency Domain

Examples

=+

Page 43: Fourier Transform and Frequency Domain

Fourier’s claim: Add enough of these to get any periodic signal you want!

amplitude

angularfrequency

variablephase

sinusoid

Basic building block

What about non-periodic signals?

Page 44: Fourier Transform and Frequency Domain

Fourier transform

Page 45: Fourier Transform and Frequency Domain

Recalling some basics

rectangularcoordinates

Complex numbers have two parts:

what‘s this? what‘s this?

Page 46: Fourier Transform and Frequency Domain

Recalling some basics

rectangularcoordinates

Complex numbers have two parts:

real imaginary

Page 47: Fourier Transform and Frequency Domain

Recalling some basics

rectangularcoordinates

polar coordinates

Complex numbers have two parts:

real imaginary

Alternative reparameterization:

how do we compute these?

polar transform

Page 48: Fourier Transform and Frequency Domain

Recalling some basics

rectangularcoordinates

polar coordinates

Complex numbers have two parts:

real imaginary

Alternative reparameterization:

polar transform

polar transform

Page 49: Fourier Transform and Frequency Domain

Recalling some basics

rectangularcoordinates

polar coordinates

Complex numbers have two parts:

real imaginary

Alternative reparameterization:

polar transform

polar transform

How do you write these in exponential

form?

Page 50: Fourier Transform and Frequency Domain

Recalling some basics

rectangularcoordinates

polar coordinates

Complex numbers have two parts:

real imaginary

Alternative reparameterization:

or equivalentlypolar transform

exponential form

how did we get this?

Page 51: Fourier Transform and Frequency Domain

This will help us understand the Fourier transform equations

Recalling some basics

rectangularcoordinates

polar coordinates

Complex numbers have two parts:

real imaginary

Alternative reparameterization:

or equivalentlypolar transform

exponential form

Euler’s formula

Page 52: Fourier Transform and Frequency Domain

Fourier transform

Fourier transform

dis

cret

eco

nti

nu

ou

s

inverse Fourier transform

Where is the connection to the ‘summation of sine waves’ idea?

Page 53: Fourier Transform and Frequency Domain

Fourier transform

Fourier transform

dis

cret

eco

nti

nu

ou

s

inverse Fourier transform

Where is the connection to the ‘summation of sine waves’ idea?

Page 54: Fourier Transform and Frequency Domain

Where is the connection to the ‘summation of sine waves’ idea?

wave componentsscaling parameter

sum over frequencies

Euler’s formula

Fourier transform

Page 55: Fourier Transform and Frequency Domain

Fourier transform pairsspatial domain frequency domain

Note the symmetry: duality property of Fourier transform

Page 56: Fourier Transform and Frequency Domain

Computing the discrete Fourier transform (DFT)

Page 57: Fourier Transform and Frequency Domain

Computing the discrete Fourier transform (DFT)

is just a matrix multiplication:

In practice this is implemented using the fast Fourier transform (FFT) algorithm.

Page 58: Fourier Transform and Frequency Domain

Fourier transforms of natural images

original amplitude phase

Page 59: Fourier Transform and Frequency Domain

Fourier transforms of natural images

cheetah phase with zebra amplitude

Image phase matters!

zebra phase with cheetah amplitude

Page 60: Fourier Transform and Frequency Domain

Frequency-domain filtering

Page 61: Fourier Transform and Frequency Domain

Why do we care about all this?

Page 62: Fourier Transform and Frequency Domain

Convolution in spatial domain is equivalent to multiplication in frequency domain!

The convolution theorem

The Fourier transform of the convolution of two functions is the product of their Fourier transforms:

The inverse Fourier transform of the product of two Fourier transforms is the convolution of the two inverse Fourier transforms:

Page 63: Fourier Transform and Frequency Domain

What do we use convolution for?

Page 64: Fourier Transform and Frequency Domain

Convolution for 1D continuous signals

Definition of linear shift-invariant filtering as convolution:

filtered signal input signalfilter

Using the convolution theorem, we can interpret and implement all types of linear shift-invariant filtering as multiplication in frequency domain.

Why implement convolution in frequency domain?

Page 65: Fourier Transform and Frequency Domain

Filtering with fft:

im = double(imread(‘…'))/255;

im = rgb2gray(im); % “im” should be a gray-scale floating point image

[imh, imw] = size(im);

hs = 50; % filter half-size

fil = fspecial('gaussian', hs*2+1, 10);

fftsize = 1024; % should be order of 2 (for speed) and include padding

im_fft = fft2(im, fftsize, fftsize); % 1) fft im with

padding

fil_fft = fft2(fil, fftsize, fftsize); % 2) fft fil, pad to

same size as image

im_fil_fft = im_fft .* fil_fft; % 3) multiply fft

images

im_fil = ifft2(im_fil_fft); % 4) inverse fft2

im_fil = im_fil(1+hs:size(im,1)+hs, 1+hs:size(im, 2)+hs); % 5) remove padding

figure(1), imagesc(log(abs(fftshift(im_fft)))), axis image, colormap jet

Frequency-domain filtering in Matlab

Displaying with fft:

Page 66: Fourier Transform and Frequency Domain

=filter kernel

=

Spatial domain filtering

Frequency domain filtering

Fourier transform inverse Fourier transform

Page 67: Fourier Transform and Frequency Domain

Why does the Gaussian give a nice smooth image, but the square filter give edgy artifacts?

Gaussian filter

Box filter

Revisiting blurring

Page 68: Fourier Transform and Frequency Domain

Gaussian blur

Page 69: Fourier Transform and Frequency Domain

Box blur

Page 70: Fourier Transform and Frequency Domain

More filtering examples

?

?

filters shown in frequency-

domain

Page 71: Fourier Transform and Frequency Domain

More filtering exampleslow-pass

band-passfilters shown in frequency-

domain

Page 72: Fourier Transform and Frequency Domain

high-pass

?

More filtering examples

Page 73: Fourier Transform and Frequency Domain

high-pass

More filtering examples

Page 74: Fourier Transform and Frequency Domain

More filtering examples

frequency magnitude

original image low-pass filter

?

Page 75: Fourier Transform and Frequency Domain

More filtering examples

frequency magnitude

original image low-pass filter

Page 76: Fourier Transform and Frequency Domain

More filtering examples

frequency magnitude

original image high-pass filter

?

Page 77: Fourier Transform and Frequency Domain

More filtering examples

frequency magnitude

original image high-pass filter

Page 78: Fourier Transform and Frequency Domain

More filtering examples

frequency magnitude

original image band-pass filter

Page 79: Fourier Transform and Frequency Domain

More filtering examples

frequency magnitude

original image band-pass filter

Page 80: Fourier Transform and Frequency Domain

More filtering examples

frequency magnitude

original image band-pass filter

Page 81: Fourier Transform and Frequency Domain

More filtering examples

frequency magnitude

original image band-pass filter

Page 82: Fourier Transform and Frequency Domain

Revisiting sampling

Page 83: Fourier Transform and Frequency Domain

The Nyquist-Shannon sampling theorem

A continuous signal can be perfectly reconstructed from its discrete version using linear interpolation, if sampling occurred with frequency:

Equivalent reformulation: When downsampling, aliasing does not occur if samples are taken at the Nyquist frequency or higher.

This is called the Nyquist frequency

Page 84: Fourier Transform and Frequency Domain

How does the Nyquist-Shannon theorem relate to the Gaussian pyramid?

Gaussian pyramid

Page 85: Fourier Transform and Frequency Domain

How does the Nyquist-Shannon theorem relate to the Gaussian pyramid?

Gaussian pyramid

• Gaussian blurring is low-pass filtering.• By blurring we try to sufficiently decrease

the Nyquist frequency to avoid aliasing.

How large should the Gauss blur we use be?

Page 86: Fourier Transform and Frequency Domain

Gala Contemplating the Mediterranean Sea Which at Twenty Meters Becomes the Portrait of Abraham Lincoln (Homage to Rothko)

Salvador Dali, 1976

Frequency-domain filtering in human vision

Page 87: Fourier Transform and Frequency Domain

Low-pass filtered version

Frequency-domain filtering in human vision

Page 88: Fourier Transform and Frequency Domain

High-pass filtered version

Frequency-domain filtering in human vision

Page 89: Fourier Transform and Frequency Domain

Variable frequency sensitivity

Experiment: Where do you see the stripes?

frequency

con

tras

t

Page 90: Fourier Transform and Frequency Domain

Campbell-Robson contrast sensitivity curve

frequency

con

tras

t

Our eyes are sensitive to mid-range frequencies

Variable frequency sensitivity

• Early processing in humans filters for various orientations and scales of frequency

• Perceptual cues in the mid frequencies dominate perception

Page 91: Fourier Transform and Frequency Domain

References

Basic reading:• Szeliski textbook, Sections 3.4.

Additional reading:• Hubel and Wiesel, “Receptive fields, binocular interaction and functional architecture in the cat's visual

cortex,” The Journal of Physiology 1962a foundational paper describing information processing in the visual system, including the different types of filtering it performs; Hubel and Wiesel won the Nobel Prize in Medicine in 1981 for the discoveries described in this paper