Lecture 5: Statistical models of images Today Review Fourier - - PowerPoint PPT Presentation

lecture 5 statistical models of images today
SMART_READER_LITE
LIVE PREVIEW

Lecture 5: Statistical models of images Today Review Fourier - - PowerPoint PPT Presentation

Lecture 5: Statistical models of images Today Review Fourier transforms Image statistics Texture synthesis The Discrete Fourier transform The Discrete Fourier Transform (DFT) transforms a signal f[n] into F[u] as: Fourier


slide-1
SLIDE 1

Lecture 5: Statistical models of images

slide-2
SLIDE 2

Today

  • Review Fourier transforms
  • Image statistics
  • Texture synthesis
slide-3
SLIDE 3

F[u] =

N−1

n=0

f[n] exp (−2πj un N )

The Discrete Fourier transform

The Discrete Fourier Transform (DFT) transforms a signal f[n] into F[u] as:

1D image Fourier coefficient for frequency u

slide-4
SLIDE 4

Examples

From Szeliski 3.4

slide-5
SLIDE 5

Examples

a = np.eye(8)[0] np.fft.fft(a)

array([1.+0.j, 1.+0.j, 1.+0.j, 1.+0.j, 1.+0.j, 1.+0.j, 1.+0.j, 1.+0.j])

slide-6
SLIDE 6

Examples

a = np.ones(8) np.fft.fft(a)

array([8.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j])

slide-7
SLIDE 7

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

slide-8
SLIDE 8

Examples

What is the 2D FFT of a line?

slide-9
SLIDE 9

Fourier transform in x direction

+v

  • v
slide-10
SLIDE 10

+v

  • v
  • u

+u

Full 2D Fourier transform

slide-11
SLIDE 11

What is a “natural” image?

“Natural” image

“Fake” image

Source: Torralba, Freeman, Isola

slide-12
SLIDE 12

Source: Torralba, Freeman, Isola

slide-13
SLIDE 13

Statistical modeling of images

The pixel

Source: Torralba, Freeman, Isola

slide-14
SLIDE 14

Statistical modeling of images

Assumptions:

  • Independence: All pixels are independent.
  • Stationarity: The distribution of pixel intensities does not depend on image location.

Source: Torralba, Freeman, Isola

slide-15
SLIDE 15

Fitting the model

Pixel intensity Counts

Source: Torralba, Freeman, Isola

slide-16
SLIDE 16

Sampling new images

Sample

Source: Torralba, Freeman, Isola

slide-17
SLIDE 17

Sampling new images

Sample

Doesn’t work very well!

Source: Torralba, Freeman, Isola

slide-18
SLIDE 18

Statistical modeling of images

The pixel

Source: Torralba, Freeman, Isola

slide-19
SLIDE 19

Statistical modeling of images

The pixel Another pixel

Source: Torralba, Freeman, Isola

slide-20
SLIDE 20

Δ = 1 Δ = 2 Δ = 10 Δ = 40 C Δ horizontal vertical

Source: Torralba, Freeman, Isola

slide-21
SLIDE 21

Gaussian model

We want a distribution that captures the correlation structure typical of natural images. Let C be the covariance matrix of the image: Diagonalization of circulant matrices: C = EDET Stationarity assumption: Symmetrical circulant matrix The eigenvectors are the Fourier basis The eigenvalues are the squared magnitude of the Fourier coefficients D=

2 2

Source: Torralba, Freeman, Isola

slide-22
SLIDE 22

A remarkable property of natural images

  • D. J. Field, "Relations between the statistics of natural images and

the response properties of cortical cells," J. Opt. Soc. Am. A 4, 2379- (1987)

Spectra

1/va

Low spatial frequencies High spatial frequencies

Power spectra fall off as

Source: Torralba, Freeman, Isola

slide-23
SLIDE 23

Sampling new images

Sample

Source: Torralba, Freeman, Isola

Fit the Gaussian image model to each of the images in the top row, then draw another random sample (with random phase), you get the bottom row.

slide-24
SLIDE 24

Sampling new images

Source: Torralba, Freeman, Isola

slide-25
SLIDE 25

Doesn’t always work well!

Source: Torralba, Freeman, Isola

slide-26
SLIDE 26

Denoising

= +

Decomposition of a noisy image

Source: Torralba, Freeman, Isola

slide-27
SLIDE 27

Denoising

= +

Decomposition of a noisy image Natural image White Gaussian noise: N(0, σn2) Find I(x,y) that maximizes the posterior (maximum a posteriory, MAP): x likelihood prior (Bayes’ theorem)

Source: Torralba, Freeman, Isola

slide-28
SLIDE 28

Denoising

= +

Decomposition of a noisy image Natural image White Gaussian noise: N(0, σn2) Find I(x,y) that maximizes the posterior (maximum a posteriory, MAP): x likelihood prior x

Source: Torralba, Freeman, Isola

slide-29
SLIDE 29

Denoising

x likelihood prior x This can also be written in the Fourier domain, for constant A: The solution is: (note this is a linear operation)

Source: Torralba, Freeman, Isola

slide-30
SLIDE 30

= + = +

The truth: The estimated decomposition:

Source: Torralba, Freeman, Isola

slide-31
SLIDE 31

Statistical modeling of images

A small neighborhood

Source: Torralba, Freeman, Isola

slide-32
SLIDE 32

[-1 1]

g[m,n] h[m,n] = f[m,n] [-1, 1]

Source: Torralba, Freeman, Isola

slide-33
SLIDE 33

[-1 1]T

g[m,n] h[m,n] = f[m,n] [-1, 1]T

Source: Torralba, Freeman, Isola

slide-34
SLIDE 34

Observation: Sparse filter response

Source: Torralba, Freeman, Isola

slide-35
SLIDE 35

Red – true pdf Black – best Gaussian fit

Image [1 -1] filter output [1 -1] output histogram Intensity histogram

slide-36
SLIDE 36

A model based on filter outputs

A small neighborhood

k

p(hk(x,y))

Filter outputs All pixels and all outputs are independent

Source: Torralba, Freeman, Isola

slide-37
SLIDE 37

Sampling images

Gaussian model Wavelet marginal model

Source: Torralba, Freeman, Isola

slide-38
SLIDE 38

Taking a picture…

What the camera give us… How do we correct this?

Slides R. Fergus

slide-39
SLIDE 39

Slides R. Fergus

Deblurring

slide-40
SLIDE 40

Slides R. Fergus

Deblurring

slide-41
SLIDE 41

Slides R. Fergus

Deblurring

slide-42
SLIDE 42

Image formation process

= ⊗

Blurry image Sharp image Blur 
 kernel Input to algorithm Desired output Convolution


  • perator

Model is approximation

slide-43
SLIDE 43

Multiple possible solutions

= ⊗

Blurry image Sharp image Blur kernel

= ⊗ = ⊗

slide-44
SLIDE 44

Natural image statistics

Histogram of image gradients

Characteristic distribution with heavy tails

Slides R. Fergus

slide-45
SLIDE 45

Blury images have different statistics

Histogram of image gradients

Slides R. Fergus

slide-46
SLIDE 46

Parametric distribution

Histogram of image gradients

Use parametric model of sharp image statistics

Slides R. Fergus

slide-47
SLIDE 47

Nonparametric image models

slide-48
SLIDE 48

Texture Synthesis

Source: A. Efros

slide-49
SLIDE 49

Efros & Leung Algorithm

  • Assuming Markov property, compute P(p|N(p))

– Building explicit probability tables infeasible

p

Synthesizing a pixel

non-parametric sampling

Input image

– Instead, we search the input image for all similar neighborhoods — that’s our pdf for p

– To sample from this pdf, just pick one match at random

Source: A. Efros

slide-50
SLIDE 50

Some Details

  • Growing is in “onion skin” order

– Within each “layer”, pixels with most neighbors are synthesized first – If no close match can be found, the pixel is not synthesized until the end

  • Using Gaussian-weighted SSD is very important

– to make sure the new pixel agrees with its closest neighbors – Approximates reduction to a smaller neighborhood window if data is too sparse

Source: A. Efros

slide-51
SLIDE 51

Neighborhood Window

input

Source: A. Efros

slide-52
SLIDE 52

Varying Window Size

Increasing window size

Source: A. Efros

slide-53
SLIDE 53

Synthesis Results

french canvas rafia weave

Source: A. Efros

slide-54
SLIDE 54

More Results

white bread brick wall

Source: A. Efros

slide-55
SLIDE 55

Homage to Shannon

Source: A. Efros

slide-56
SLIDE 56

Hole Filling

Source: A. Efros

slide-57
SLIDE 57

Extrapolation

Source: A. Efros

slide-58
SLIDE 58

Summary

  • The Efros & Leung algorithm

– Very simple – Surprisingly good results – Synthesis is easier than analysis! – …but very slow

slide-59
SLIDE 59

p

Image Quilting [Efros & Freeman]

  • Observation: neighbor pixels are highly correlated

Input image

non-parametric sampling

B Idea: unit of synthesis = block

  • Exactly the same but now we want P(B|N(B))
  • Much faster: synthesize all pixels in a block at once
  • Not the same as multi-scale!

Synthesizing a block

slide-60
SLIDE 60

Input texture

B1 B2

Random placement

  • f blocks

block

B1 B2

Neighboring blocks constrained by overlap

B1 B2

Minimal error boundary cut

slide-61
SLIDE 61
  • min. error boundary

Minimal error boundary

  • verlapping blocks

vertical boundary

_

=

2

  • verlap error
slide-62
SLIDE 62

Our Philosophy

  • The “Corrupt Professor’s Algorithm”:

– Plagiarize as much of the source image as you can – Then try to cover up the evidence

  • Rationale:

– Texture blocks are by definition correct samples of texture so problem only connecting them together

slide-63
SLIDE 63
slide-64
SLIDE 64
slide-65
SLIDE 65
slide-66
SLIDE 66
slide-67
SLIDE 67
slide-68
SLIDE 68
slide-69
SLIDE 69

Failures

(Chernobyl Harvest)

slide-70
SLIDE 70

Texture Transfer

Constraint Texture sample

slide-71
SLIDE 71