1 of 35

Nima Kalantari

CSCE 448/748 - Computational Photography

Texture Synthesis

Many slides from Alexei A. Efros

2 of 35

Texture

  • Texture depicts spatially repeating patterns
  • Many natural phenomena are textures

radishes

rocks

yogurt

3 of 35

Texture Synthesis

  • Goal of Texture Synthesis: create new samples of a given texture
  • Many applications: hole-filling, texturing surfaces

4 of 35

The Challenge

  • Need to model the whole spectrum: from repeated to stochastic texture

5 of 35

Weather Forecasting

Let’s predict weather:

    • Given today’s weather only, we want to know tomorrow’s
    • Suppose weather can only be {Sunny, Cloudy, Raining}

The “Weather Channel” algorithm:

    • Over a long period of time, record:
      • How often S followed by R
      • How often S followed by S
      • Etc.
    • Compute percentages for each state:
      • P(R|S), P(S|S), etc.
    • Predict the state with highest probability!
    • It’s a Markov Chain

6 of 35

Markov Chain

What if we know today and yesterday’s weather?

Tomorrow

C

S

R

Today

R

C

S

7 of 35

Second Order Markov Chain

Tomorrow

C

S

R

Today

R

C

S

Observation

R,R

R,C

R,S

C,R

C,C

C,S

S,R

S,C

S,S

8 of 35

Markov Chains

Markov Chain

    • a sequence of random variables

    • is the state of the model at time t

    • Markov assumption: each state is dependent only on the previous one
      • dependency given by a conditional probability:

    • The above is actually a first-order Markov chain
    • An N’th-order Markov chain:

9 of 35

Text synthesis

Create plausible looking poetry, love letters, term papers, etc.

Most basic algorithm

    • Build probability histogram
      • find all blocks of N consecutive words/letters in training documents
      • compute probability of occurance
    • Given words
      • compute by sampling from

10 of 35

Markov Chain Example: Text

“A dog is a man’s best friend. It’s a dog eat dog world out there.”

2/3

1/3

1/3

1/3

1/3

1

1

1

1

1

1

1

1

1

1

a

dog

is

man’s

best

friend

it’s

eat

world

out

there

dog

is

man’s

best

friend

it’s

eat

world

out

there

a

.

.

11 of 35

Mark V. Shaney (Bell Labs)

Results:

    • “As I've commented before, really relating to someone involves standing next to impossible.”
    • “One morning I shot an elephant in my arms and kissed him.”
    • “I spent an interesting evening recently with a grain of salt”

12 of 35

Markov Random Field

A Markov random field (MRF)

    • generalization of Markov chains to two or more dimensions.

First-order MRF:

    • probability that pixel X takes a certain value given the values of neighbors A, B, C, and D:

D

C

X

A

B

X

*

*

*

*

*

*

*

*

X

*

*

*

*

*

*

*

*

*

*

*

*

    • Higher order MRF’s have larger neighborhoods

13 of 35

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

14 of 35

Neighborhood Window

input

15 of 35

Varying Window Size

Increasing window size

16 of 35

Synthesis Results

french canvas

rafia weave

17 of 35

More Results

white bread

brick wall

18 of 35

Homage to Shannon

19 of 35

Hole Filling

20 of 35

Extrapolation

21 of 35

Summary

  • The Efros & Leung algorithm
    • Very simple
    • Surprisingly good results
    • …but very slow

22 of 35

Image Quilting [Efros & Freeman]

  • Observation: neighbor pixels are highly correlated

p

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

Synthesizing a block

23 of 35

Input texture

B1

B2

Random placement

of blocks

block

B1

B2

Neighboring blocks

constrained by overlap

B1

B2

Minimal error

boundary cut

24 of 35

Minimal error boundary

min. error boundary

overlapping blocks

vertical boundary

_

=

2

overlap error

25 of 35

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

26 of 35

27 of 35

28 of 35

29 of 35

30 of 35

Portilla & Simoncelli

Wei & Levoy

Our algorithm

input image

Xu, Guo & Shum

31 of 35

Application: Texture Transfer

  • Try to explain one object with bits and pieces of another object:

+

=

32 of 35

Texture Transfer

Constraint

Texture sample

33 of 35

  • Take the texture from one image and “paint” it onto another object

Texture Transfer

Same as texture synthesis, except an additional constraint:

    • Consistency of texture
    • Similarity to the image being “explained”

34 of 35

=

+

35 of 35