Review of Sampling & Linear Systems EE367/CS448I: Computational - - PowerPoint PPT Presentation

review of sampling linear systems
SMART_READER_LITE
LIVE PREVIEW

Review of Sampling & Linear Systems EE367/CS448I: Computational - - PowerPoint PPT Presentation

Review of Sampling & Linear Systems EE367/CS448I: Computational Imaging and Display stanford.edu/class/ee367 Lecture 5 Gordon Wetzstein Stanford University Whats a Discrete Image? ( ) continuous 2D visual signal on sensor: i x ,


slide-1
SLIDE 1

Review of Sampling & Linear Systems

Gordon Wetzstein Stanford University EE367/CS448I: Computational Imaging and Display stanford.edu/class/ee367 Lecture 5

slide-2
SLIDE 2

What’s a Discrete Image?

  • continuous 2D visual signal on sensor:
  • integration over pixels:

(detector footprint modulation transfer function, Boreman 2001)

i x,y

( )

! i x,y

( ) = i x,y ( )∗ rect

x w ⎡ ⎣ ⎢ ⎤ ⎦ ⎥⋅rect y h ⎡ ⎣ ⎢ ⎤ ⎦ ⎥ ⎛ ⎝ ⎜ ⎞ ⎠ ⎟

sensor pixel:

w h

slide-3
SLIDE 3

What’s a Discrete Image?

  • continuous 2D visual signal on sensor:
  • integration over pixels:

(detector footprint modulation transfer function, Boreman 2001)

  • discrete sampling:

(in irradiance )

i x,y

( )

E i, j

[ ] = sample !

f x,y

( )

( ) = !

f x,y

( )⋅

δ i, j

( )

n

m

W m2

! i x,y

( ) = i x,y ( )∗ rect

x w ⎡ ⎣ ⎢ ⎤ ⎦ ⎥⋅rect y h ⎡ ⎣ ⎢ ⎤ ⎦ ⎥ ⎛ ⎝ ⎜ ⎞ ⎠ ⎟

slide-4
SLIDE 4

Fourier Transform

  • any continuous, integrable, periodic function can be represented as an

infinite sum of sines and cosines:

  • most important for us: discrete Fourier transform
  • convolution theorem (critical):

f (x) = ˆ f (ξ)e2πiξx dξ

−∞ ∞

ˆ f (ξ) = f (x)e−2πiξx dx

−∞ ∞

x[n] = 1 N ˆ x[k]

k=0 N−1

e2πikn/N ˆ x[k] = x[n]

n=0 N−1

e−2πikn/N x∗g = F−1 F x

{ }⋅F g { }

{ }

slide-5
SLIDE 5

Discrete Fourier Transform

  • What is this?
slide-6
SLIDE 6

Discrete Fourier Transform

  • What is this?
slide-7
SLIDE 7

Filtering – Low-pass Filter

  • low-pass filter: convolution in primal domain

* =

b = x∗c b x c

small kernel

slide-8
SLIDE 8

Filtering – Low-pass Filter

  • low-pass filter: multiplication in frequency domain

. =

F b

{ } = F x { }⋅F c { }

big

slide-9
SLIDE 9

Filtering – Low-pass Filter

  • low-pass filter: hard cutoff

. =

F b

{ } = F x { }⋅F c { }

slide-10
SLIDE 10

Filtering – Low-pass Filter

  • Bessel function of the first kind or “jinc”

F−1{

}

imagemagick.org

  • ptique-ingenieur.org
slide-11
SLIDE 11

Filtering – Low-pass Filter

  • hard frequency filters often introduce ringing

ß

slide-12
SLIDE 12

Filtering – High-pass Filter

  • sharpening (possibly with ringing, but don’t see any here)

ß

slide-13
SLIDE 13

Filtering – Unsharp Masking

  • sharpening (without ringing): unsharp masking, e.g. in Photoshop

b = x*(δ − clowpass_ gauss) = x − x*clowpass_ gauss b = x*(δ + chighpass) = x + x*chighpass

  • r
slide-14
SLIDE 14

Filtering – Unsharp Masking

  • sharpening (without ringing): unsharp masking, e.g. in Photoshop
  • riginal

unsharp mask

slide-15
SLIDE 15

Filtering – Band-pass Filter

ß

slide-16
SLIDE 16

Filtering – Oriented Band-pass Filter

ß

  • edges with specific orientation (e.g., hat) are gone!
slide-17
SLIDE 17

Optical Filtering with Fourier Optics

  • can do all of this optically (with coherent light)!
  • Fourier optics – not part of this course

http://en.wikipedia.org/wiki/Fourier_optics

slide-18
SLIDE 18

Image Downsampling (& Upsampling)

  • best demonstrated with “high-frequency” image
  • that’s just resampling, right?
slide-19
SLIDE 19
  • best demonstrated with “high-frequency” image
  • that’s just resampling, right?

pocketfullofliberty.com/high-frequency-trading

  • riginal image: I
slide-20
SLIDE 20

pocketfullofliberty.com/high-frequency-trading

re-sample image: I(1:4:end,1:4:end) in Matlab something is wrong - aliasing!

slide-21
SLIDE 21
  • best demonstrated with “high-frequency” image
  • that’s just resampling, right?

pocketfullofliberty.com/high-frequency-trading

need to low-pass filter image first!

slide-22
SLIDE 22
  • best demonstrated with “high-frequency” image
  • that’s just resampling, right?

pocketfullofliberty.com/high-frequency-trading

need to low-pass filter image first!

slide-23
SLIDE 23

pocketfullofliberty.com/high-frequency-trading

first: filter out high frequencies (“anti-aliasing”) then: then re-sample image: I(1:4:end,1:4:end)

slide-24
SLIDE 24
  • “anti-aliasing” à bef

befor

  • re re-sampling, apply appropriate filter!
  • how much filtering? Shannon-Nyquist sampling theorem:

fs ≥ 2 fmax

Image Downsampling (& Upsampling)

slide-25
SLIDE 25

pocketfullofliberty.com/high-frequency-trading

no anti-aliasing with anti-aliasing

slide-26
SLIDE 26

Examples of Aliasing: Temporal Aliasing

  • wagon wheel effect (temporal aliasing)
  • sampling frequency was lower than 2 fmax

wikipedia

slide-27
SLIDE 27

Examples of Aliasing: Temporal Aliasing

  • wagon wheel effect

(temporal aliasing):

youtube.com/watch?v=jHS9JGkEOmA

slide-28
SLIDE 28

Examples of Aliasing: Sampling on Sensor

  • point source on focal plane maps to PSF

focal plane

slide-29
SLIDE 29

Examples of Aliasing: Sampling on Sensor

  • PSF must be larger than 2*pixel size!

focal plane Optical Anti-Aliasing (AA) filter

slide-30
SLIDE 30

Other Forms of Aliasing

  • photography – optical AA filter removed (“hot rodding” camera)

mosaicengineering.com John Shafer

slide-31
SLIDE 31

Other Forms of Aliasing

  • photography – optical AA filter removed (“hot rodding” camera)

maxmax.com

without AA filter with AA filter (standard)

slide-32
SLIDE 32

Other Forms of Aliasing

  • photography – optical AA filter removed (“hot rodding” camera)

maxmax.com

without AA filter with AA filter (standard)

slide-33
SLIDE 33
  • away from focal plane: out of focus blur

focal plane blurred point

Lens as Optical Low-pass Filter

slide-34
SLIDE 34
  • shift-invariant convolution

focal plane

Lens as Optical Low-pass Filter

slide-35
SLIDE 35

Lens as Optical Low-pass Filter

point spread function (PSF): c

x b

sharp image measured, blurred image

b = c∗ x

diffraction-limited PSF of circular aperture (aka “Airy” pattern):

slide-36
SLIDE 36

Deconvolution – Next Class!

  • given measurements b and convolution kernel c, what is x?

* =

b c x

?

slide-37
SLIDE 37

Overview of Terms

  • point spread function (PSF) = blur kernel
  • optical transfer function (OTF) – Fourier transform of PSF
  • modulation transfer function (MTF) – magnitude of OTF

F PSF

{ } = OTF = MTF ⋅eiφ

slide-38
SLIDE 38

Sampling – Quick Summary

  • Shannon-Nyquist theorem: always sample signal at

a sampling rate >= 2*highest frequency of signal!

  • if Shannon-Nyquist is violated, aliasing occurs
  • aliasing cannot be corrected digitally in post-

processing (see optical anti-aliasing filter)

  • PSF is usually a low-pass filter L
slide-39
SLIDE 39

Matrices and Linear Systems - Review

  • basic linear algebra, review if necessary!
  • stanford.edu/ee263 – lecture slides and recorded

lectures online

  • quick summary now
slide-40
SLIDE 40

Matrices and Linear Systems - Review

  • most computational imaging problems are linear
  • geometric optics approximation of light is linear in

amplitude

  • not true for wave-based models (e.g. interference,

phase retrieval, …), but we don’t cover these

slide-41
SLIDE 41

Matrices and Linear Systems - Review

b = Ax

blurry, noisy, or otherwise corrupted measurements system matrix latent (unknown) image

  • most computational imaging problems are linear
slide-42
SLIDE 42

Matrix Properties

  • common problem: given b, what can I hope to

recover?

  • answer: analyze matrix properties: condition

number, rank, characterize range space somehow!

b = Ax

slide-43
SLIDE 43
  • singular value decomposition (SVD):
  • matrix condition number: (1 is the best)
  • rank(A): number of independent columns = number of

nonzero singular values

κ A

( ) = σ max A ( )

σ min A

( )

Matrix Properties

A = UΣV * A = U Σ V *

m n m n n n m m

slide-44
SLIDE 44
  • singular value decomposition (SVD):
  • if A square, eigen decomposition:
  • in general:

à so eigen values of are singular values of squared

Matrix Properties

A = UΣV * A = U Σ V *

m n m n n n m m

A = UDU *

A*A = (VΣ*U *)(UΣV *) = VΣ*ΣV * A*A A

slide-45
SLIDE 45
  • given b, what can I hope to recover?
  • example: convolution with PSF c

b = c∗ x = Cx

Matrix Properties: Useful Example

slide-46
SLIDE 46
  • matrix form of convolution
  • C is circulant matrix

(for circular boundary conditions)

  • eigen-decomposition of circulant matrix:
  • matrix of eigenvectors is discrete Fourier transform!
  • eigenvalues:

b = c∗ x b = Cx C = UDU * = F−1DF diag(D) = ˆ c b = c∗ x = Cx = F−1diag(ˆ c)Fx = F−1 F c

{ }⋅F x { }

{ }

Useful Example

slide-47
SLIDE 47
  • matrix is rank-deficient
  • i.e. when convolution kernel is low-pass filter!

C abs F c

{ }

( ) → modulation transfer function (MTF)

Useful Example

slide-48
SLIDE 48

abs F c

{ }

( ) → modulation transfer function (MTF)

sort(MTF) = eigenvalues of CTC

Useful Example

  • matrix is rank-deficient
  • i.e. when convolution kernel is low-pass filter!

C

slide-49
SLIDE 49

abs F c

{ }

( ) → modulation transfer function (MTF)

sort(MTF) = eigenvalues of CTC

Useful Example

noise floor of camera signal-to-noise-ratio (SNR) is below threshold

  • matrix is rank-deficient
  • i.e. when convolution kernel is low-pass filter!

C

slide-50
SLIDE 50

abs F c

{ }

( ) → modulation transfer function (MTF)

sort(MTF) = eigenvalues of CTC

Useful Example

noise floor of camera (e.g. high ISO) signal-to-noise-ratio (SNR) is below threshold

  • matrix is rank-deficient
  • i.e. when convolution kernel is low-pass filter!

C

slide-51
SLIDE 51

abs F c

{ }

( ) → modulation transfer function (MTF)

sort(MTF) = eigenvalues of CTC

Useful Example

noise floor of camera (cooled, scientific CCD) signal-to-noise-ratio (SNR) is below threshold

  • matrix is rank-deficient
  • i.e. when convolution kernel is low-pass filter!

C

slide-52
SLIDE 52

Linear Systems

  • other common problem: given b, what is x?
  • answer: invert matrix?

b = Ax xest = A−1b

?

slide-53
SLIDE 53

Linear Systems

  • other common problem: given b, what is x?
  • answer: invert matrix – generally not!

b = Ax xest = A−1b

?

slide-54
SLIDE 54

Linear Systems

  • problem 1: matrix inverse only defined for square,

full-rank matrices – most imaging problems are NOT!

  • problem 2: most imaging problems deal with really

big matrices – couldn’t compute inverse, even if there was one!

  • solution: iterative (convex) optimization
slide-55
SLIDE 55

Linear Systems

  • case 1: over-determined system = more

measurements than unknowns

  • formulate least-squared error objective function:

A ∈Rm×n, m > n minimize

x

1 2 b − Ax 2

2

r 2

2 =

r

i 2 i

, r = b − Ax

norm

ℓ2

residual

slide-56
SLIDE 56
  • least squares solution: gradient of objective = 0
  • gradient:
  • equate to zero – normal equations:

∇x 1 2 b − Ax 2

2 = ∇x

1 2 bTb − 2bT Ax + xT AT Ax

( ) = AT Ax − ATb

AT Ax = ATb

Linear Systems

slide-57
SLIDE 57
  • closed-form solution to normal equations:
  • rarely applicable, because again A is big and

usually not full rank

  • regularized solution

(always full rank, but still too big to directly invert)

AT Ax = ATb

Linear Systems

xest = AT A

( )

−1 ATb

xest = AT A + λI

( )

−1 ATb

slide-58
SLIDE 58
  • solve with iterative method, easiest one: steepest

descent

  • use the negative gradient of objective as descent

direction at iteration k, with step length

Linear Systems – Gradient Descent

AT A + λI

! A

" # $ % $ ⎛ ⎝ ⎜ ⎞ ⎠ ⎟ x = ATb

! b

&

x(k+1) = x(k) −α∇x = x(k) −α ! AT ! Ax(k) − ! b

( )

α

slide-59
SLIDE 59
  • use the negative gradient of objective as descent

direction at iteration k, with step length

  • for large-scale problems, implement as function

handles!

x(k+1) = x(k) −α∇x = x(k) −α ! AT ! Ax(k) − ! b

( )

Linear Systems – Gradient Descent α

slide-60
SLIDE 60
  • back to convolution example (here just C, not )
  • efficient implementation using convolution theorem:

x(k+1) = x(k) −αCT Cx(k) − b

( )

Linear Systems – Gradient Descent x(k+1) = x(k) −αF−1 ˆ c* ⋅F F−1 ˆ c⋅F x(k)

{ }

{ }− b

{ }

{ }

CTC

slide-61
SLIDE 61

Next: How to do it right – Deconvolution!

  • inverse filtering
  • Wiener filtering
  • sparse gradients
  • ADMM
slide-62
SLIDE 62

References and Further Reading

  • Boreman, “Modulation Transfer Function in Optical and ElectroOptical Systems”, SPIE Publications, 2001
  • http://www.imagemagick.org/Usage/fourier/
  • wikipedia