04 Frequency Part1
04 Frequency Part1
Fundamentals of
Image Processing
Erkut Erdem
Dept. of Computer Engineering
Hacettepe University
Frequency Domain
Techniques – Part1
Review - Point Operations
• Smallest possible neighborhood is of size 1x1
• Process each point independently of the others
• Output image g depends only on the value of f
at a single point (x,y)
• Transformation function T remaps the sample’s value:
s = T(r)
where
– r is the value at the point in question
– s is the new value in the processed result
– T is a intensity transformation function
1 1 1
1 1 1
f [.,.] h[.,.]
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0
0 0
0 0
0 90
90 0
0 90
90 90
90 90
90 0
0 0
0
0
0 0
0 0
0 90
90 90
90 90
90 90
90 90
90 0
0 0
0
0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0
0
0 0
0 90
90 0
0 0
0 0
0 0
0 0
0 0
0 0
0
0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0
h[ m, n] = å g[ k , l ] f [ m + k , n + l ]
k ,l Slide credit: S. Seitz
1 1 1
1 1 1
f [.,.] h[.,.]
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 0 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
h[ m, n] = å g[ k , l ] f [ m + k , n + l ]
k ,l Slide credit: S. Seitz
1 1 1
1 1 1
f [.,.] h[.,.]
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 0 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
h[ m, n] = å g[ k , l ] f [ m + k , n + l ]
k ,l Slide credit: S. Seitz
1 1 1
1 1 1
f [.,.] h[.,.]
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 0 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
h[ m, n] = å g[ k , l ] f [ m + k , n + l ]
k ,l Slide credit: S. Seitz
1 1 1
1 1 1
f [.,.] h[.,.]
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 0 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
h[ m, n] = å g[ k , l ] f [ m + k , n + l ]
k ,l Slide credit: S. Seitz
1 1 1
1 1 1
f [.,.] h[.,.]
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 20 10
0 0 0 90 90 90 90 90 0 0 0 20 40 60 60 60 40 20
0 0 0 90 90 90 90 90 0 0 0 30 60 90 90 90 60 30
0 0 0 90 90 90 90 90 0 0 0 30 50 80 80 90 60 30
0 0 0 90 0 90 90 90 0 0 0 30 50 80 80 90 60 30
0 0 0 90 90 90 90 90 0 0 0 20 30 50 50 60 40 20
0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 30 20 10
0 0 90 0 0 0 0 0 0 0 10 10 10 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
h[ m, n] = å g[ k , l ] f [ m + k , n + l ]
k ,l Slide credit: S. Seitz
Review – Spatial Filtering
1 0 -1
2 0 -2
1 0 -1
Sobel
H I D
Carpet&image&(black&&&white)&
Carpet&image&(black&&&white)&
=&=& ...&
...&
...&
...&
...&
...&
Jean Baptiste Joseph Fourier (1768-1830)
had crazy idea (1807):
Any univariate function can be
rewritten as a weighted sum of
sines and cosines of different
frequencies.
Legendre
Lagrange
Jean Baptiste Joseph Fourier (1768-1830)
had crazy idea (1807):
Any univariate function can be
rewritten as a weighted sum of
sines and cosines of different
frequencies.
Asin(wx + f )
Add enough of them to get
any signal f(x) you want!
= +
= +
= +
= +
= +
= +
¥
1
= Aå sin(2p kt )
k =1 k
xkcd.com
Slide credit: J. Hays
Fourier Transform
We want to understand the frequency w of our signal. So, let s
reparametrize the signal by w instead of x:
F (w ) = R(w ) + iI (w )
-1 I (w )
A = ± R(w ) + I (w )
2 2
f = tan
R(w )
We can always go back:
I (w )
Amplitude: A = ± R(w ) + I (w ) Phase: f = tan
2 2 -1
R(w )
Discrete Fourier transform
• Forward transform
M −1 N−1
1
F(u, v) =
MN
∑ ∑ f (x, y)e − j 2 π (ux/M +vy/N )
x=0 y=0
45 deg.
0 Horizontal
orientation
0 fmax High
spatial
fx in cycles/image frequencies
Log
Log power spectrum
power spectrum
Fu,v(x,y)
Vector (u,v)
• Magnitude gives frequency
• Direction gives orientation.
Intensity Image
Fourier Image
http://sharp.bu.edu/~slehar/fourier/fourier.html#filtering
Slide credit: A. Efros More: http://www.cs.unm.edu/~brayer/vision/fourier.html
Signals can be composed
+ =
http://sharp.bu.edu/~slehar/fourier/fourier.html#filtering
Slide credit: A. Efros More: http://www.cs.unm.edu/~brayer/vision/fourier.html
Some important Fourier Transforms
Image
Magnitude FT
A B C
1 2 3
F[ g * h] = F[ g ] F[ h]
• The inverse Fourier transform of the product of two
Fourier transforms is the convolution of the two inverse
Fourier transforms
-1 -1 -1
F [ gh] = F [ g ] * F [ h]
• Convolution in spatial domain is equivalent to
multiplication in frequency domain!
Slide credit: A. Efros
Properties of Fourier Transforms
• Linearity
* =
FFT
FFT
=
Inverse FFT
f(x,y) |F(sx,sy)|
h(x,y) |H(sx,sy)|
g(x,y) |G(sx,sy)|
Box Filter
High-pass / band-pass:
Computer Vision - A Modern Approach - Set: Pyramids and Texture - Slides by D.A. Forsyth
Computer Vision - A Modern Approach - Set: Pyramids and Texture - Slides by D.A. Forsyth
Slide credit: B. Freeman and A. Torralba
Slide credit: B. Freeman and A. Torralba
This is the
magnitude
transform of
the cheetah
picture
Campbell-Robson contrast
Campbell-Robson contrast sensitivity curve
sensitivity curve
The higher
The higher the frequency thesensitive
the less frequency the less
human sensitive
visual system is...
human visual system is… Slide credit: J. Hays
Lossy Image Compression (JPEG)
CS 4495 Computer Vision – A. Bobick Frequency and Fourier Transform
Using
Using DCT
DCT in JPEG
in JPEG
• The
• The firstfirst coefficient
coefficient is theisDC
B(0,0)
B(0,0) thecomponent,
DC component, the
the average
average intensity
intensity
• The top-left coeffs represent low frequencies, the bottom
• The top-left coeffs represent low frequencies,
theright
bottom – high
rightfrequencies
– high frequencies
Using
Image DCT in JPEG
compression using DCT
• The
• DCT first coefficient
enables B(0,0) is by
image compression theconcentrating
DC component,mostthe
image
average in
information intensity
the low frequencies
• The top-left coeffs represent low frequencies, the bottom
• Loose unimportant image info (high frequencies) by cutting
right
B(u,v) at – high frequencies
bottom right
• The decoder computes the inverse DCT – IDCT
89k
89k 12k
12k
A C E
D