Lecture 3: Signal processing Andrew Owens PS1 due next Tuesday - - PowerPoint PPT Presentation
Lecture 3: Signal processing Andrew Owens PS1 due next Tuesday - - PowerPoint PPT Presentation
Lecture 3: Signal processing Andrew Owens PS1 due next Tuesday Updated holiday office hours: Questions? Today A few more filters Fourier analysis <latexit
- PS1 due next Tuesday
- Updated holiday office hours:
- Questions?
Today
- A few more filters
- Fourier analysis
Laplacian filter
- Used to detect object boundaries and other
salient image structures
- The Laplacian operator is defined as the sum of
the second order derivatives of a function:
- Sensitive to noise. Blur first!
r2I = ∂2I ∂x2 + ∂2I ∂y2
<latexit sha1_base64="6JG0rPkXeHIWG47l8jIU5ZTrDE8=">ACOXicfVDLSgMxFM3UV62vqks3wSIQpmpgm6Eohu7q2Af0GnLnThmYyQ5IRy9DfcuNfuBPcuFDErT9g+kC0FQ8ETs49yb3eBFnStv2k5VaWFxaXkmvZtbWNza3sts7VRXGktAKCXko6x4oypmgFc0p/VIUg8Tmte/3JUr91SqVgobvQgos0AuoL5jIA2UjtbdgV4HFoFXMLn2PUlkMSNQGoGvFUoDb8v+K5VGOKjfy0DY2lnc3beHgPE2dKcmiKcjv76HZCEgdUaMJBqYZjR7qZjEYSTocZN1Y0AtKHLm0YKiCgqpmMNx/iA6N0sB9Kc4TGY/VnRwKBUoPAM84AdE/N1kbiX7VGrP2zZsJEFGsqyOQhP+ZYh3gUI+4wSYnmA0OASGb+ikPTDTahJ0xITizK8+TaiHvHOft65Nc8WIaRxrtoX10iBx0ioroCpVRBRF0j57RK3qzHqwX6936mFhT1rRnF/2C9fkF1ous/w=</latexit>Laplacian filter
- The most popular approximation is the five-point formula which
consists in convolving the image with the kernel
- Based on the approximation of the 2nd derivative filter: [1, -2, 1]
(f(n − 1) − f(n)) − (f(n) − f(n + 1)) = f(n − 1) − 2f(n) + f(n + 1)
<latexit sha1_base64="nHOK6xLOIulxV7TgkJhAuH5SE0=">ACJHicbVDLSgMxFM3UV62vUZdugkVoKS0zVAQoejGZQXbCu1QMmDc1khiQjlKEf48ZfcePCBy7c+C1mpoNo64WQk3PO5eYeN2RUKsv6NHJLyura/n1wsbm1vaOubvXlkEkMGnhgAXizkWSMpJS1HFyF0oCPJdRjru+CrRO/dESBrwWzUJieOjIacexUhpqm+el7wSr9plWIUalJM7YbJ3xdbMBfyx1FOpkl9s2jVrLTgIrAzUARZNfvmW28Q4MgnXGpOzaVqicGAlFMSPTQi+SJER4jIakqyFHPpFOnC45hUeaGUAvEPpwBVP2d0eMfCknvqudPlIjOa8l5H9aN1LemRNTHkaKcDwb5EUMqgAmicEBFQrNtEAYUH1XyEeIYGw0rkWdAj2/MqLoF2v2c16+ak2LjM4siDA3AISsAGp6ABrkETtAGD+AJvIBX49F4Nt6Nj5k1Z2Q9+BPGV/fHbqb4g=</latexit>Laplacian filter
- The most popular approximation is the five-point formula which
consists in convolving the image with the kernel
=
Image patches as filters
- Goal: find in an image
- What’s a good similarity/distance
measure between two patches?
Source: D. Hoiem
Matching with filters
Method 1: Filter the image with
Input Filtered Image
] , [ ] , [ ] , [
,
l n k m f l k g n m h
l k
+ + = ∑
What went wrong?
f = image g = filter
Source: D. Hoiem
Matching with filters
Input Filtered Image (scaled) Thresholded Image
) ] , [ ( ) ] , [ ( ] , [
,
l n k m g f l k f n m h
l k
+ + − = ∑
True detections False detections mean of f
Method 2: Filter the image with zero-mean eye.
Source: D. Hoiem
Matching with filters
5 . , 2 , , 2 , ,
) ] , [ ( ) ] , [ ( ) ] , [ )( ] , [ ( ] , [ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛ − + + − − + + − =
∑ ∑ ∑
l k n m l k n m l k
f l n k m f g l k g f l n k m f g l k g n m h
mean image patch mean template
Method 3: Normalized cross-correlation.
Source: D. Hoiem
Matching with filters
Input Normalized X-Correlation Thresholded Image True detections
Method 3: Normalized cross-correlation.
Source: D. Hoiem
- So far, we’ve focused on convolution
- What about other linear transformations?
Other linear transformations
=
U
f F
- Change the basis
e.g. Fourier transform
F[u] =
N−1
∑
n=0
f[n] exp (−2πj un N )
The Discrete Fourier transform
Discrete Fourier Transform (DFT) transforms a signal f[n] into F[u] as: Discrete Fourier Transform (DFT) is a linear operator. Therefore, we can write:
? ? ? ? ? ? ? ? … ?
F
f
NxN array
n u
=
exp (−2πj un N )
Source: Torralba, Freeman, Isola
Example: g(t) = sin(2πf t) + (1/3)sin(2π(3f) t)
Change of basis
= +
Source: A. Efros
Change of basis
Source: A. Efros
= + =
Change of basis
Source: A. Efros
= + =
Change of basis
Source: A. Efros
= + =
Change of basis
Source: A. Efros
= + =
Change of basis
Source: A. Efros
= + =
Change of basis
Source: A. Efros
Frequency Spectra
A
∞
X
k=1
1 k sin(2πkt)
<latexit sha1_base64="/zy0YhesJzEUJHslqENQdBq2EZ8=">ACF3icbVDLSsNAFJ3UV62vqks3g0Wom5JUQTdC1Y3LCvYBTS2T6aQdMpmEmRuhPyFG3/FjQtF3OrOv3H6WGjrgQuHc+7l3nu8WHANtv1t5ZaWV1bX8uFjc2t7Z3i7l5TR4mirEjEam2RzQTXLIGcBCsHStGQk+wlhdcj/3WA1OaR/IORjHrhmQguc8pASP1ipVLVydhLw3wBXaye5dLH0bY9RWhqZOlQYZdzW56sYcB3DcK5bsij0BXiTOjJTQDPVe8cvtRzQJmQqiNYdx46hmxIFnAqWFdxEs5jQgAxYx1BJQqa76eSvDB8ZpY/9SJmSgCfq74mUhFqPQs90hgSGet4bi/95nQT827KZwAk3S6yE8EhgiPQ8J9rhgFMTKEUMXNrZgOickETJQFE4Iz/IiaVYrzknFvj0t1a5mceTRATpEZeSgM1RDN6iOGoiR/SMXtGb9WS9WO/Wx7Q1Z81m9tEfWJ8/g7ie4A=</latexit>=
Source: A. Efros
Visualizing the Fourier transform
exp (α j) = cos(α) + j sin(α)
F[u] =
N−1
∑
n=0
f[n] exp (−2πj un N )
cos (2π un N ) − j sin (2π un N )
For: u=1 N=16
Real Imag n=0 n=1 n=2 n=3 n=4 5 6 7 8 9 10 11 12 13 14 15
Source: Torralba, Freeman, Isola
Visualizing the transform coefficients
exp (−2πj un N )
For N=16
F
f
16x16 array n=0
u=0
=
u=1 1 2 n=15 u=15 u=2 Real Imag n=0…15 …
Source: Torralba, Freeman, Isola
Visualizing the transform coefficients
exp (−2πj un N )
For N=16
F
f
16x16 array n=0 u=0
=
u=1
1 2 n=15 u=15 u=2 Real Imag …
Source: Torralba, Freeman, Isola
Visualizing the transform coefficients
exp (−2πj un N )
Real Imag n=0 n=1 n=2 n=3 n=4 5 6 7 8 9 10 11 12 13 14 15
For N=16
F
f
16x16 array n=0 u=0
=
u=1
1 2 n=15 u=15 u=2 …
Source: Torralba, Freeman, Isola
Visualizing the transform coefficients
exp (−2πj un N )
Real Imag n=0 n=1 n=2 n=3 n=4 5 6 7 8 9 10 11 12 13 14 15
For N=16
F
f
16x16 array n=0 u=0
=
u=1
1 2 n=15 u=15 u=2 …
Source: Torralba, Freeman, Isola
Visualizing the transform coefficients
exp (−2πj un N )
For N=16
F
f
16x16 array n=0 u=0
=
u=1 1 2 n=15 u=15
u=2
Real Imag …
Source: Torralba, Freeman, Isola
Visualizing the transform coefficients
exp (−2πj un N )
For N=16
Real Imag n=0 n=1 n=2 3 4 5 6 7 8 9 10 11 12 13 14 15
F
f
16x16 array n=0 u=0
=
u=1 1 2 n=15 u=15
u=2
…
Source: Torralba, Freeman, Isola
Visualizing the transform coefficients
exp (−2πj un N )
For N=16
Real Imag n=0 n=1 n=2 3 4 5 6 7 8 9 10 11 12 13 14 15
F
f
16x16 array n=0 u=0
=
u=1 1 2 n=15 u=15 u=2 …
Source: Torralba, Freeman, Isola
Visualizing the transform coefficients
exp (−2πj un N )
For N=16
Real Imag
F
f
16x16 array n=0 u=0
=
u=1 1 2 n=15 u=15 u=2 …
Source: Torralba, Freeman, Isola
F[u] =
N−1
∑
n=0
f[n] exp (−2πj un N )
The inverse of the Discrete Fourier transform
Discrete Fourier Transform (DFT): Its inverse:
F
f
NxN array n=0 u=0
=
u=1 1 2 n=15 u=15 u=2 …
F
F
NxN array n=0 u=0
=
u=1 1 2 n=15 u=15 u=2 …
f[n] = 1 N
N−1
∑
u=0
F[u] exp (2πj un N )
Source: Torralba, Freeman, Isola
F[u] =
N−1
∑
n=0
f[n] exp (−2πj un N )
For images, the 2D DFT
1D Discrete Fourier Transform (DFT) transforms a signal f [n] into F [u] as: 2D Discrete Fourier Transform (DFT) transforms an image f [n,m] into F [u,v] as:
F[u, v] =
N−1
∑
n=0 M−1
∑
m=0
f[n, m] exp (−2πj ( un N + vm M ))
Source: Torralba, Freeman, Isola
Useful properties of the Fourier transform
- 2D Fourier transform is separable (just like Gaussian)
- Fast Fourier transform (FFT) computable in
- Complex exponentials are eigenfunctions of linear shift invariant systems
- i.e. If we convolve a complex exponential f with filter g, we get a
complex scaled version out:
f[u] = ejωu
<latexit sha1_base64="q7F20yt+lBEilJ0/zE0RScyR3uQ=">ACFnicbVDLSgNBEJz1bXxFPXpDIihl0V9CKIXjwqGBWya+id9MZJZh/MzAphyVd48Ve8eFDEq3jzb5zEHwVNBRV3XR3hZkU2rjuhzMyOjY+MTk1XZqZnZtfKC8uXeg0V5xqPJWpugpRkxQJ1Ywkq4yRiHki7DznHfv7wlpUWanJtuRkGMrUREgqOxUqO8FdXzA6Aros2+GlMLYS85/ulCHzUBlrW0fYhLC9AVGjXHGr7gDwl3hDUmFDnDbK734z5XlMieESta57bmaCApURXFKv5OeaMuQdbFHd0gRj0kExeKsHa1ZpQpQqW4mBgfp9osBY624c2s4YzY3+7fXF/7x6bqL9oBJlhtK+NeiKJdgUuhnBE2hiBvZtQS5EvZW4DeokBubZMmG4P1+S+52K56O1X3bLdyeDSMY4qtsFW2zjy2xw7ZCTtlNcbZHXtgT+zZuXcenRfn9at1xBnOLMfcN4+AQrtnB0=</latexit>f ∗ g = (a + bj)f
<latexit sha1_base64="q7F20yt+lBEilJ0/zE0RScyR3uQ=">ACFnicbVDLSgNBEJz1bXxFPXpDIihl0V9CKIXjwqGBWya+id9MZJZh/MzAphyVd48Ve8eFDEq3jzb5zEHwVNBRV3XR3hZkU2rjuhzMyOjY+MTk1XZqZnZtfKC8uXeg0V5xqPJWpugpRkxQJ1Ywkq4yRiHki7DznHfv7wlpUWanJtuRkGMrUREgqOxUqO8FdXzA6Aros2+GlMLYS85/ulCHzUBlrW0fYhLC9AVGjXHGr7gDwl3hDUmFDnDbK734z5XlMieESta57bmaCApURXFKv5OeaMuQdbFHd0gRj0kExeKsHa1ZpQpQqW4mBgfp9osBY624c2s4YzY3+7fXF/7x6bqL9oBJlhtK+NeiKJdgUuhnBE2hiBvZtQS5EvZW4DeokBubZMmG4P1+S+52K56O1X3bLdyeDSMY4qtsFW2zjy2xw7ZCTtlNcbZHXtgT+zZuXcenRfn9at1xBnOLMfcN4+AQrtnB0=</latexit>,
O(n log(n))
<latexit sha1_base64="/XLwfcL0zMTM9rlpVAPGc6QJjXo=">AB8nicbVBNSwMxEJ2tX7V+VT16CRahvZRdFfRY9OLNCvYDtkvJptk2NJsSVYoS3+GFw+KePXePfmLZ70NYHA4/3ZpiZFyacaeO6305hbX1jc6u4XdrZ3ds/KB8etbVMFaEtIrlU3RBrypmgLcMp91EURyHnHbC8e3M7zxRpZkUj2aS0CDGQ8EiRrCxkn9fFT0uh1VRq/XLFbfuzoFWiZeTCuRo9stfvYEkaUyFIRxr7XtuYoIMK8MIp9NSL9U0wWSMh9S3VOCY6iCbnzxFZ1YZoEgqW8Kgufp7IsOx1pM4tJ0xNiO97M3E/zw/NdF1kDGRpIYKslgUpRwZiWb/owFTlBg+sQTxeytiIywsTYlEo2BG/5VXSPq97F3X34bLSuMnjKMIJnEIVPLiCBtxBE1pAQMIzvMKbY5wX5935WLQWnHzmGP7A+fwB4wmQVQ=</latexit>Useful properties of the Fourier transform
- Convolution is multiplication in the Fourier domain!
F{f ∗ g} = F{f} · F{g}
<latexit sha1_base64="NuPhTfW8GBxIfk9gYaK7S7MUhw=">ACKnicbVDLSsNAFJ3UV62vqEs3g0VwVRIVdCNUBXFZwT6gCWUynbRDJw9mboQS8j1u/BU3XSjFrR/ipM3Cth4YOJxzLnPv8WLBFVjW1CitrW9sbpW3Kzu7e/sH5uFRS0WJpKxJIxHJjkcUEzxkTeAgWCeWjASeYG1v9JD7VcmFY/CFxjHzA3IOQ+pwS01DPvnIDAkBKRPmZO6mOHKMADJ8O3eNHRkP7ESzKOtkzq1bNmgGvErsgVSg0TMnTj+iScBCoIo1bWtGNyUSOBUsKziJIrFhI7IgHU1DUnAlJvOTs3wmVb62I+kfiHgmfp3IiWBUuPA08l8T7Xs5eJ/XjcB/8ZNeRgnwEI6/8hPBIYI573hPpeMghrQqjkeldMh0QSCrdi7BXj5lbQuavZlzXq+qtbvizrK6ASdonNko2tUR0+ogZqIojf0gT7Rl/FuTIyp8T2Ploxi5hgtwPj5BWxRp+Q=</latexit>- Can be much faster for big filters
- Speed is independent of filter size!
Visualizing the image Fourier transform
Using the real and imaginary components: Or using a polar decomposition: The values of F [u,v] are complex. Amplitude Phase
F[u, v] =
N−1
∑
n=0 M−1
∑
m=0
f[n, m] exp (−2πj ( un N + vm M ))
Source: Torralba, Freeman, Isola
Simple Fourier transforms
DFT (amplitude)
64x64 pixels
Image n m u v
u0
- u0
v0
- v0
Simple Fourier transforms
n m u v u v u v u v
Visualizing the image Fourier transform
f[n, m] F[u, v]
Some important Fourier transforms
Image Magnitude DFT Phase DFT n m
64x64 pixels
Some important Fourier transforms
Image Magnitude DFT Phase DFT n m
64x64 pixels
Some important Fourier transforms
Image Magnitude DFT Phase DFT n m
64x64 pixels
Some important Fourier transforms
Image Magnitude DFT Phase DFT
Translation
Shifts of an image only produce changes on the phase of the DFT.
Some important Fourier transforms
Image Magnitude DFT Phase DFT
Scale
Small image details produce content in high spatial frequencies
Some important Fourier transforms
Image Magnitude DFT Phase DFT
Orientation
A line transforms to a line
- riented perpendicularly to
the first.
The DFT Game: find the right pairs
A B C 1 2 3
fx(cycles/image pixel size) fx(cycles/image pixel size) fx(cycles/image pixel size)
Images DFT magnitude
The DFT Game: find the right pairs
Solution in notes!
The inverse Discrete Fourier transform
2D Discrete Fourier Transform (DFT) transforms an image f [n,m] into F [u,v] as:
F[u, v] =
N−1
∑
n=0 M−1
∑
m=0
f[n, m] exp (−2πj ( un N + vm M ))
The inverse of the 2D DFT is:
f[n, m] = 1 NM
N−1
∑
n=0 M−1
∑
m=0
F[u, v] exp (+2πj ( un N + vm M ))
Reconstruct an image, low frequency to high
Reconstruct an image, low frequency to high
Reconstruct an image, low frequency to high
Reconstruct an image, low frequency to high
Reconstruct an image, low frequency to high
Phase and Magnitude
Campbell & Robson chart
Let’s define the following image:
With:
What do you think you should see when looking at this image?
What about the opposite of blurring?
- +
- Gaussian filter
Laplacian filter
- +
- Laplacian filter
+ =
Gaussian filter
Hybrid Images
Oliva & Schyns
Hybrid Images
= +
Hybrid Images
http://cvcl.mit.edu/hybrid_gallery/gallery.html