Lecture 3: Signal processing Andrew Owens PS1 due next Tuesday - - PowerPoint PPT Presentation

lecture 3 signal processing
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Lecture 3: Signal processing

Andrew Owens

slide-2
SLIDE 2
  • PS1 due next Tuesday
  • Updated holiday office hours:
  • Questions?
slide-3
SLIDE 3

Today

  • A few more filters
  • Fourier analysis
slide-4
SLIDE 4

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>
slide-5
SLIDE 5

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>
slide-6
SLIDE 6

Laplacian filter

  • The most popular approximation is the five-point formula which

consists in convolving the image with the kernel

=

slide-7
SLIDE 7

Image patches as filters

  • Goal: find in an image
  • What’s a good similarity/distance

measure between two patches?

Source: D. Hoiem

slide-8
SLIDE 8

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

slide-9
SLIDE 9

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

slide-10
SLIDE 10

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

slide-11
SLIDE 11

Matching with filters

Input Normalized X-Correlation Thresholded Image True detections

Method 3: Normalized cross-correlation.

Source: D. Hoiem

slide-12
SLIDE 12
  • 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

slide-13
SLIDE 13

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

slide-14
SLIDE 14

Example: g(t) = sin(2πf t) + (1/3)sin(2π(3f) t)

Change of basis

= +

Source: A. Efros

slide-15
SLIDE 15

Change of basis

Source: A. Efros

slide-16
SLIDE 16

= + =

Change of basis

Source: A. Efros

slide-17
SLIDE 17

= + =

Change of basis

Source: A. Efros

slide-18
SLIDE 18

= + =

Change of basis

Source: A. Efros

slide-19
SLIDE 19

= + =

Change of basis

Source: A. Efros

slide-20
SLIDE 20

= + =

Change of basis

Source: A. Efros

slide-21
SLIDE 21

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

slide-22
SLIDE 22

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

slide-23
SLIDE 23

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

slide-24
SLIDE 24

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

slide-25
SLIDE 25

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

slide-26
SLIDE 26

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

slide-27
SLIDE 27

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

slide-28
SLIDE 28

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

slide-29
SLIDE 29

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

slide-30
SLIDE 30

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

slide-31
SLIDE 31

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

slide-32
SLIDE 32

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

slide-33
SLIDE 33

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/MzAphyVd48Ve8eFDEq3jzb5zEHwVNBRV3XR3hZkU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aeO6305hbX1jc6u4XdrZ3ds/KB8etbVMFaEtIrlU3RBrypmgLcMp91EURyHnHbC8e3M7zxRpZkUj2aS0CDGQ8EiRrCxkn9fFT0uh1VRq/XLFbfuzoFWiZeTCuRo9stfvYEkaUyFIRxr7XtuYoIMK8MIp9NSL9U0wWSMh9S3VOCY6iCbnzxFZ1YZoEgqW8Kgufp7IsOx1pM4tJ0xNiO97M3E/zw/NdF1kDGRpIYKslgUpRwZiWb/owFTlBg+sQTxeytiIywsTYlEo2BG/5VXSPq97F3X34bLSuMnjKMIJnEIVPLiCBtxBE1pAQMIzvMKbY5wX5935WLQWnHzmGP7A+fwB4wmQVQ=</latexit>
slide-34
SLIDE 34

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!
slide-35
SLIDE 35

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

slide-36
SLIDE 36

Simple Fourier transforms

DFT (amplitude)

64x64 pixels

Image n m u v

u0

  • u0

v0

  • v0
slide-37
SLIDE 37

Simple Fourier transforms

slide-38
SLIDE 38

n m u v u v u v u v

Visualizing the image Fourier transform

f[n, m] F[u, v]

slide-39
SLIDE 39

Some important Fourier transforms

Image Magnitude DFT Phase DFT n m

64x64 pixels

slide-40
SLIDE 40

Some important Fourier transforms

Image Magnitude DFT Phase DFT n m

64x64 pixels

slide-41
SLIDE 41

Some important Fourier transforms

Image Magnitude DFT Phase DFT n m

64x64 pixels

slide-42
SLIDE 42

Some important Fourier transforms

Image Magnitude DFT Phase DFT

Translation

Shifts of an image only produce changes on the phase of the DFT.

slide-43
SLIDE 43

Some important Fourier transforms

Image Magnitude DFT Phase DFT

Scale

Small image details produce content in high spatial frequencies

slide-44
SLIDE 44

Some important Fourier transforms

Image Magnitude DFT Phase DFT

Orientation

A line transforms to a line

  • riented perpendicularly to

the first.

slide-45
SLIDE 45

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

slide-46
SLIDE 46

The DFT Game: find the right pairs

Solution in notes!

slide-47
SLIDE 47

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 ))

slide-48
SLIDE 48

Reconstruct an image, low frequency to high

slide-49
SLIDE 49

Reconstruct an image, low frequency to high

slide-50
SLIDE 50

Reconstruct an image, low frequency to high

slide-51
SLIDE 51

Reconstruct an image, low frequency to high

slide-52
SLIDE 52

Reconstruct an image, low frequency to high

slide-53
SLIDE 53

Phase and Magnitude

slide-54
SLIDE 54
slide-55
SLIDE 55

Campbell & Robson chart

Let’s define the following image:

With:

What do you think you should see when looking at this image?

slide-56
SLIDE 56
slide-57
SLIDE 57

What about the opposite of blurring?

  • +
  • Gaussian filter

Laplacian filter

slide-58
SLIDE 58
  • +
  • Laplacian filter

+ =

Gaussian filter

slide-59
SLIDE 59

Hybrid Images

Oliva & Schyns

slide-60
SLIDE 60

Hybrid Images

slide-61
SLIDE 61

= +

slide-62
SLIDE 62

Hybrid Images

slide-63
SLIDE 63
slide-64
SLIDE 64

http://cvcl.mit.edu/hybrid_gallery/gallery.html