lecture 2: 2d fourier transforms and applications
TRANSCRIPT
![Page 1: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/1.jpg)
Lecture 2: 2D Fourier transforms and applications
B14 Image Analysis Michaelmas 2014 A. Zisserman
• Fourier transforms and spatial frequencies in 2D• Definition and meaning
• The Convolution Theorem• Applications to spatial filtering
• The Sampling Theorem and Aliasing
Much of this material is a straightforward generalization of the 1D Fourier analysis with which you are familiar.
![Page 2: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/2.jpg)
Reminder: 1D Fourier Series
Spatial frequency analysis of a step edge
Fourier decomposition
x
![Page 3: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/3.jpg)
Fourier series reminder
Example
= +
f(x) = sinx+1
3sin3x+ . . .
![Page 4: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/4.jpg)
=
Fourier series for a square wave
f(x) =X
n=1,3,5,...
1
nsinnx
![Page 5: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/5.jpg)
Fourier series: just a change of basis
.
.
.
. =
M f(x) = F()
![Page 6: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/6.jpg)
Inverse FT: Just a change of basis
.
.
.
. =
M-1 F() = f(x)
![Page 7: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/7.jpg)
1D Fourier Transform
Reminder transform pair - definition
Example
x u
![Page 8: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/8.jpg)
2D Fourier transforms
![Page 9: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/9.jpg)
2D Fourier transform
Definition
![Page 10: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/10.jpg)
Sinusoidal Waves
![Page 11: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/11.jpg)
To get some sense of what basis elements look like, we plot a basis element --- or rather, its real part ---as a function of x,y for some fixed u, v. We get a function that is constant when (ux+vy) is constant. The magnitude of the vector (u, v) gives a frequency, and its direction gives an orientation. The function is a sinusoid with this frequency along the direction, and constant perpendicular to the direction.
u
v
slide: B. Freeman
![Page 12: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/12.jpg)
Here u and v are larger than in the previous slide.
u
v
![Page 13: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/13.jpg)
And larger still...
u
v
![Page 14: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/14.jpg)
Some important Fourier Transform Pairs
![Page 15: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/15.jpg)
FT pair example 1
rectangle centred at origin with sides of length X and Y
|F(u,v)|
separability
f(x,y) |F(u,v)|
v
u
![Page 16: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/16.jpg)
FT pair example 2
Gaussian centred on origin
• FT of a Gaussian is a Gaussian
• Note inverse scale relation
f(x,y)
F(u,v)
![Page 17: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/17.jpg)
FT pair example 3
Circular disk unit height andradius a centred on origin
• rotational symmetry
• a ‘2D’ version of a sinc
f(x,y)
F(u,v)
![Page 18: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/18.jpg)
FT pairs example 4
f(x,y) F(u,v)
![Page 19: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/19.jpg)
= + + + …
f(x,y)
Summary
![Page 20: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/20.jpg)
Example: action of filters on a real image
f(x,y)
|F(u,v)|
low pass high passoriginal
![Page 21: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/21.jpg)
Example 2D Fourier transform
Image with periodic structure
f(x,y) |F(u,v)|
FT has peaks at spatial frequencies of repeated texture
![Page 22: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/22.jpg)
Example – Forensic application
Periodic background removed
|F(u,v)|
remove peaks
![Page 23: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/23.jpg)
Example – Image processingLunar orbital image (1966)
|F(u,v)| remove peaks
join lines removed
![Page 24: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/24.jpg)
Magnitude vs Phase
f(x,y)
|F(u,v)|
• |f(u,v)| generally decreases with higher spatial frequencies
• phase appears less informative
phase F(u,v)
cross-section
![Page 25: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/25.jpg)
The importance of phase
magnitudephase phase
![Page 26: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/26.jpg)
A second example
magnitudephase phase
![Page 27: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/27.jpg)
Transformations
As in the 1D case FTs have the following properties
• Linearity
• Similarity
• Shift
![Page 28: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/28.jpg)
f(x,y) |F(u,v)|
ExampleHow does F(u,v) transform if f(x,y) is rotated by 45 degrees?
In 2D can also rotate, shear etc
Under an affine transformation:
![Page 29: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/29.jpg)
The convolution theorem
![Page 30: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/30.jpg)
Filtering vs convolution in 1D
100 | 200 | 100 | 200 | 90 | 80 | 80 | 100 | 100f(x)1/4 | 1/2 | 1/4h(x)
g(x) | 150 | | | | | | |
molecule/template/kernel
filtering f(x) with h(x)
g(x) =
Zf(u)h(x− u) du
=Zf(x+ u0)h(−u0) du0
=Xi
f(x+ i)h(−i)
convolution of f(x) and h(x)
after change of variable
• note negative sign (which is a reflection in x) in convolution
• h(x) is often symmetric (even/odd), and then (e.g. for even)
![Page 31: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/31.jpg)
Filtering vs convolution in 2D
image f(x,y)
filter / kernel h(x,y)
g(x,y) =
convolution
filtering
for convolution, reflect filter in x and y axes
![Page 32: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/32.jpg)
Convolution
• Convolution: – Flip the filter in both dimensions (bottom to top, right to left)
h
f
slide: K. Grauman
h
filtering with hconvolution with h
![Page 33: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/33.jpg)
Filtering vs convolution in 2D in Matlab
2D filtering• g=filter2(h,f);
2D convolution• g=conv2(h,f);
],[],[],[,
lnkmflkhnmglk
f=imageh=filter
],[],[],[,
lnkmflkhnmglk
![Page 34: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/34.jpg)
In words: the Fourier transform of the convolution of two functions is the product of their individual Fourier transforms
Space convolution = frequency multiplication
Proof: exercise
Convolution theorem
Why is this so important?
Because linear filtering operations can be carried out by simple multiplications in the Fourier domain
![Page 35: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/35.jpg)
The importance of the convolution theorem
Example smooth an image with a Gaussian spatial filter
Gaussian scale=20 pixels
It establishes the link between operations in the frequency domain and the action of linear spatial filters
*1. Compute FT of image and FT of Gaussian
2. Multiply FT’s
3. Compute inverse FT of the result.
![Page 36: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/36.jpg)
f(x,y)
x
Fourier transform
Gaussian scale=3 pixels
*
|F(u,v)|
g(x,y)
|G(u,v)|
Inverse Fourier transform
![Page 37: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/37.jpg)
f(x,y)
x
Fourier transform
Gaussian scale=3 pixels
*
|F(u,v)|
g(x,y)
|G(u,v)|
Inverse Fourier transform
![Page 38: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/38.jpg)
There are two equivalent ways of carrying out linear spatial filtering operations:1. Spatial domain: convolution with a spatial operator
2. Frequency domain: multiply FT of signal and filter, and compute inverse FT of product
Why choose one over the other ?• The filter may be simpler to specify or compute in one of the domains
• Computational cost
![Page 39: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/39.jpg)
Exercise
What is the FT of …
?
2 small disks
![Page 40: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/40.jpg)
The sampling theorem
![Page 41: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/41.jpg)
Discrete Images - Sampling
x
X
f(x)
xx
![Page 42: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/42.jpg)
Fourier transform pairs
![Page 43: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/43.jpg)
Sampling Theorem in 1D
*
spatial domain frequency domain
replicated copies of F(u)
F(u)x
u
![Page 44: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/44.jpg)
Apply a box filter
The original continuous function f(x) is completely recovered from the samples provided the sampling frequency (1/X) exceeds twice the greatest frequency of the band-limited signal. (Nyquist sampling limit)
u1/X
F(u)f(x)
x
![Page 45: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/45.jpg)
The Sampling Theorem and Aliasingif sampling frequency is reduced …
spatial domain frequency domain
Frequencies above the Nyquist limit are ‘folded back’ corrupting the signal in the acceptable range.
The information in these frequencies is not correctly reconstructed.
x u
![Page 46: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/46.jpg)
* =
Sampling Theorem in 2D
* =
frequency domain
1/Y F(u,v)1/X
![Page 47: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/47.jpg)
If the Fourier transform of a function ƒ(x,y) is zero for all
frequencies beyond ub and vb,i.e. if the Fourier transform is
band-limited, then the continuous function ƒ(x,y) can be
completely reconstructed from its samples as long as the
sampling distances w and h along the x and y directions
are such that and bu
w21
bv
h21
The sampling theorem in 2D
![Page 48: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/48.jpg)
Aliasing
![Page 49: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/49.jpg)
Insufficient samples to distinguish the high and low frequency
aliasing: signals “travelling in disguise” as other frequencies
Aliasing : 1D example
If the signal has frequencies above the Nyquist limit …
![Page 50: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/50.jpg)
Aliasing in video
Slide by Steve Seitz
![Page 51: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/51.jpg)
Aliasing in 2D – under sampling example
original reconstruction
signal has frequencies above Nyquist limit
![Page 52: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/52.jpg)
Aliasing in images
![Page 53: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/53.jpg)
What’s happening?Input signal:
x = 0:.05:5; imagesc(sin((2.^x).*x))
Plot as image:
AliasingNot enough samples
![Page 54: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/54.jpg)
Anti-Aliasing
• Increase sampling frequency• e.g. in graphics rendering cast 4 rays per pixel
• Reduce maximum frequency to below Nyquist limit• e.g. low pass filter before sampling
![Page 55: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/55.jpg)
Example
convolve with Gaussian
*
down sample by factor of 4
down sample by factor of 4
4 x zoom
![Page 56: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/56.jpg)
Hybrid Images
![Page 57: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/57.jpg)
Frequency Domain and Perception
Campbell-Robson contrast sensitivity curve
slide: A. Efros
![Page 58: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/58.jpg)
![Page 59: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/59.jpg)
![Page 60: Lecture 2: 2D Fourier transforms and applications](https://reader034.vdocuments.net/reader034/viewer/2022052300/5868e8c51a28abc7568be4dd/html5/thumbnails/60.jpg)
Aude Oliva & Antonio Torralba & Philippe G Schyns, SIGGRAPH 2006