lecture 11: texture - cs.princeton.edu

97
COS 429: Computer Vision Lecture 11: Texture Acknowledgment: slides from Antonio Torralba, Kristen Grauman, Jitendra Malik, Alyosha Efros, Tom Funkhouser, Szymon Rusinkiewicz

Upload: others

Post on 04-Nov-2021

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture 11: Texture - cs.princeton.edu

COS 429: Computer Vision

Lecture 11: Texture

Acknowledgment: slides from Antonio Torralba, Kristen Grauman, Jitendra Malik, Alyosha Efros, Tom Funkhouser, Szymon Rusinkiewicz

Page 2: Lecture 11: Texture - cs.princeton.edu

Texture

What is a texture?

Torralba

Page 3: Lecture 11: Texture - cs.princeton.edu

Texture

What is a texture?

Torralba

Page 4: Lecture 11: Texture - cs.princeton.edu

Texture

What is a texture?

Torralba

Page 5: Lecture 11: Texture - cs.princeton.edu

Texture

• Texture: stochastic pattern that is stationary(“looks the same” at all locations)

• May be structured or random

Wei & Levoy

Page 6: Lecture 11: Texture - cs.princeton.edu

Texture

Stochastic Stationary

Page 7: Lecture 11: Texture - cs.princeton.edu

Texture

Stochastic Stationary

Page 8: Lecture 11: Texture - cs.princeton.edu

Goal

• Computational representation of texture– Textures generated by same stationary stochastic

process have same representation– Perceptually similar textures have similar

representations

5, 7, 34, 2, 199, 12Hypothetical texture representation

Page 9: Lecture 11: Texture - cs.princeton.edu

Applications

• Segmentation• 3D Reconstruction• Classification• Synthesis

http://animals.nationalgeographic.com/

Page 10: Lecture 11: Texture - cs.princeton.edu

Applications

• Segmentation• 3D Reconstruction• Classification• Synthesis

Page 11: Lecture 11: Texture - cs.princeton.edu

Applications

• Segmentation• 3D Reconstruction• Classification• Synthesis

Grauman

Page 12: Lecture 11: Texture - cs.princeton.edu

Applications

• Segmentation• 3D Reconstruction• Classification• Synthesis

Grauman

Page 13: Lecture 11: Texture - cs.princeton.edu

Applications

• Segmentation• 3D Reconstruction• Classification• Synthesis

Input OutputEfros

Page 14: Lecture 11: Texture - cs.princeton.edu

Texture Representation?

• What makes a good texture representation?– Textures generated by same stationary stochastic

process have same representation– Perceptually similar textures have similar

representations

Page 15: Lecture 11: Texture - cs.princeton.edu

Statistics of filter banks

Page 16: Lecture 11: Texture - cs.princeton.edu

Filter-Based Texture Representation

• Research suggests that the human visual system performs local spatial frequency analysis(Gabor filters)

J. J. Kulikowski, S. Marcelja, and P. Bishop. Theory of spatial position and spatial frequency relations in the receptive fields of simple cells in the visual cortex. Biol. Cybern, 43:187-198, 1982.

Page 17: Lecture 11: Texture - cs.princeton.edu

Texture Representation

• Analyze textures based on the responses of linear filters – Use filters that look like patterns

(spots, edges, bars, …)– Compute magnitudes of filter responses

• Represent textures with statistics of filter responses within local windows– Histogram of feature responses for all pixels in window

Grauman

Page 18: Lecture 11: Texture - cs.princeton.edu

Texture Representation Example

original image

derivative filter responses, squared

statistics to summarize patterns in small

windows

mean d/dx

value

mean d/dy

value Win. #1 4 10

Grauman

Page 19: Lecture 11: Texture - cs.princeton.edu

Texture Representation Example

original image

derivative filter responses, squared

statistics to summarize patterns in small

windows

mean d/dx

value

mean d/dy

value Win. #1 4 10

Win.#2 18 7

Grauman

Page 20: Lecture 11: Texture - cs.princeton.edu

Texture Representation Example

original image

derivative filter responses, squared

statistics to summarize patterns in small

windows

mean d/dx

value

mean d/dy

value Win. #1 4 10

Win.#2 18 7

Win.#9 20 20

Grauman

Page 21: Lecture 11: Texture - cs.princeton.edu

Texture Representation Example

statistics to summarize patterns in small

windows

mean d/dx

value

mean d/dy

value Win. #1 4 10

Win.#2 18 7

Win.#9 20 20

Dimension 1 (mean d/dx value)Dim

ensi

on 2

(mea

n d/

dy v

alue

)

Grauman

Page 22: Lecture 11: Texture - cs.princeton.edu

Texture Representation Example

statistics to summarize patterns in small

windows

mean d/dx

value

mean d/dy

value Win. #1 4 10

Win.#2 18 7

Win.#9 20 20

Dimension 1 (mean d/dx value)Dim

ensi

on 2

(mea

n d/

dy v

alue

)

Far: dissimilartextures

Close: similartextures

Grauman

Page 23: Lecture 11: Texture - cs.princeton.edu

Filter Banks

• Previous example used two filters, resulting in 2-dimensional feature vector– x and y derivatives revealed local structure

• Filter bank: many filters– Higher-dimensional feature space– Distance still related to similarity of local structure

Grauman

Page 24: Lecture 11: Texture - cs.princeton.edu

Filter banks

• What filters to put in the bank?– Combination of different scales, orientations, patterns

scales

orientations

“Edges” “Bars”

“Spots”

Grauman

Page 25: Lecture 11: Texture - cs.princeton.edu

Imag

e fro

m h

ttp://

ww

w.te

xase

xplo

rer.c

om/a

ustin

cap2

.jpg

Grauman

Page 26: Lecture 11: Texture - cs.princeton.edu

Showing magnitude of responses

Grauman

Page 27: Lecture 11: Texture - cs.princeton.edu

Grauman

Page 28: Lecture 11: Texture - cs.princeton.edu

Grauman

Page 29: Lecture 11: Texture - cs.princeton.edu

Grauman

Page 30: Lecture 11: Texture - cs.princeton.edu

Grauman

Page 31: Lecture 11: Texture - cs.princeton.edu

Grauman

Page 32: Lecture 11: Texture - cs.princeton.edu

Grauman

Page 33: Lecture 11: Texture - cs.princeton.edu

Grauman

Page 34: Lecture 11: Texture - cs.princeton.edu

Grauman

Page 35: Lecture 11: Texture - cs.princeton.edu

Grauman

Page 36: Lecture 11: Texture - cs.princeton.edu

Grauman

Page 37: Lecture 11: Texture - cs.princeton.edu

Grauman

Page 38: Lecture 11: Texture - cs.princeton.edu

Grauman

Page 39: Lecture 11: Texture - cs.princeton.edu

Grauman

Page 40: Lecture 11: Texture - cs.princeton.edu

Grauman

Page 41: Lecture 11: Texture - cs.princeton.edu

Grauman

Page 42: Lecture 11: Texture - cs.princeton.edu

Grauman

Page 43: Lecture 11: Texture - cs.princeton.edu

Grauman

Page 44: Lecture 11: Texture - cs.princeton.edu

Grauman

Page 45: Lecture 11: Texture - cs.princeton.edu

You Try: Can you match the texture to the response?

Mean abs responses

Filters A

B

C

1

2

3

Derek Hoiem

Page 46: Lecture 11: Texture - cs.princeton.edu

Application: Retrieval

• Retrieve similar imagesbased on texture

Y. Rubner, C. Tomasi, and L. J. Guibas. The earth mover's distance as a metric for image retrieval. International Journal of Computer Vision, 40(2):99-121, November 2000,

Page 47: Lecture 11: Texture - cs.princeton.edu

Textons

• Elements (“textons”) either identical or come from some statistical distribution

• Can analyze in natural images

Olhausen & Field

Page 48: Lecture 11: Texture - cs.princeton.edu

Clustering Textons

• Output of bank of n filters can be thought of as vector in n-dimensional space

• Can cluster these vectors using k-means [Malik et al.]

• Result: dictionary of most common textures

Page 49: Lecture 11: Texture - cs.princeton.edu

K-means clustering

Page 50: Lecture 11: Texture - cs.princeton.edu

Revisiting k-means

Most well-known and popular clustering algorithm:

Start with some initial cluster centers

Iterate:– Assign/cluster each example to closest center– Recalculate centers as the mean of the points in a cluster

Credit: David Kauchak

Page 51: Lecture 11: Texture - cs.princeton.edu

K-means: an example

Credit: David Kauchak

Page 52: Lecture 11: Texture - cs.princeton.edu

K-means: Initialize centers randomly

Credit: David Kauchak

Page 53: Lecture 11: Texture - cs.princeton.edu

K-means: assign points to nearest center

Credit: David Kauchak

Page 54: Lecture 11: Texture - cs.princeton.edu

K-means: readjust centers

Credit: David Kauchak

Page 55: Lecture 11: Texture - cs.princeton.edu

K-means: assign points to nearest center

Credit: David Kauchak

Page 56: Lecture 11: Texture - cs.princeton.edu

K-means: readjust centers

Credit: David Kauchak

Page 57: Lecture 11: Texture - cs.princeton.edu

K-means: assign points to nearest center

Credit: David Kauchak

Page 58: Lecture 11: Texture - cs.princeton.edu

K-means: readjust centers

Credit: David Kauchak

Page 59: Lecture 11: Texture - cs.princeton.edu

K-means: assign points to nearest center

No changes: DoneCredit: David Kauchak

Page 60: Lecture 11: Texture - cs.princeton.edu

K-means

Iterate:– Assign/cluster each example to closest center– Recalculate centers as the mean of the points in a

cluster

How do we do this?Credit: David Kauchak

Page 61: Lecture 11: Texture - cs.princeton.edu

K-means

Iterate:– Assign/cluster each example to closest center– Recalculate centers as the mean of the points in a

cluster

Where are the cluster centers?Credit: David Kauchak

Page 62: Lecture 11: Texture - cs.princeton.edu

K-means

Iterate:– Assign/cluster each example to closest center– Recalculate centers as the mean of the points in a

cluster

How do we calculate these?Credit: David Kauchak

Page 63: Lecture 11: Texture - cs.princeton.edu

Iterate:– Assign/cluster each example to closest center– Recalculate centers as the mean of the points in a

cluster

K-means

Mean of the points in the cluster:

µ(C) = 1|C |

xx∈C∑

Credit: David Kauchak

Page 64: Lecture 11: Texture - cs.princeton.edu

K-means loss function

K-means tries to minimize what is called the “k-means” loss function:

loss= d(xi,µk )2 where µk is cluster center for xi

i=1

n

that is, the sum of the squared distances from each point to the associated cluster center

Credit: David Kauchak

Page 65: Lecture 11: Texture - cs.princeton.edu

Minimizing k-means loss

Iterate: 1. Assign/cluster each example to closest center 2. Recalculate centers as the mean of the points in a cluster

loss= d(xi,µk )2 where µk is cluster center for xi

i=1

n

Does each step of k-means move towards reducing this loss function (or at least not increasing)?

Credit: David Kauchak

Page 66: Lecture 11: Texture - cs.princeton.edu

Minimizing k-means loss

Iterate: 1. Assign/cluster each example to closest center 2. Recalculate centers as the mean of the points in a cluster

loss= d(xi,µk )2 where µk is cluster center for xi

i=1

n

This isn’t quite a complete proof/argument, but:

1. Any other assignment would end up in a larger loss

1. The mean of a set of values minimizes the squared error

Credit: David Kauchak

Page 67: Lecture 11: Texture - cs.princeton.edu

Minimizing k-means loss

Iterate: 1. Assign/cluster each example to closest center 2. Recalculate centers as the mean of the points in a cluster

loss= d(xi,µk )2 where µk is cluster center for xi

i=1

n

Does this mean that k-means will always find the minimum loss/clustering?

Credit: David Kauchak

Page 68: Lecture 11: Texture - cs.princeton.edu

Minimizing k-means loss

Iterate: 1. Assign/cluster each example to closest center 2. Recalculate centers as the mean of the points in a cluster

loss= d(xi,µk )2 where µk is cluster center for xi

i=1

n

NO! It will find a minimum.

Unfortunately, the k-means loss function is generally not convex and for most problems has many, many minima

We’re only guaranteed to find one of them

Credit: David Kauchak

Page 69: Lecture 11: Texture - cs.princeton.edu

K-means: Initialize centers randomly

What would happen here?

Seed selection ideas?Credit: David Kauchak

Page 70: Lecture 11: Texture - cs.princeton.edu

K-means: Initialize furthest from centers

Pick a random point for the first center

Credit: David Kauchak

Page 71: Lecture 11: Texture - cs.princeton.edu

K-means: Initialize furthest from centers

What point will be chosen next?

Credit: David Kauchak

Page 72: Lecture 11: Texture - cs.princeton.edu

K-means: Initialize furthest from centers

Furthest point from center

What point will be chosen next?Credit: David Kauchak

Page 73: Lecture 11: Texture - cs.princeton.edu

K-means: Initialize furthest from centers

Furthest point from center

What point will be chosen next?Credit: David Kauchak

Page 74: Lecture 11: Texture - cs.princeton.edu

K-means: Initialize furthest from centers

Furthest point from center

Any issues/concerns with this approach?Credit: David Kauchak

Page 75: Lecture 11: Texture - cs.princeton.edu

Furthest points concerns

If k = 4, which points will get chosen?

Credit: David Kauchak

Page 76: Lecture 11: Texture - cs.princeton.edu

Furthest points concerns

If we do a number of trials, will we get different centers?

Credit: David Kauchak

Page 77: Lecture 11: Texture - cs.princeton.edu

Furthest points concerns

Doesn’t deal well with outliers

Credit: David Kauchak

Page 78: Lecture 11: Texture - cs.princeton.edu

K-means

• But usually k-means works pretty well• Especially with large number of points and large

number of centers k• Variations: kmeans++, etc• Alternatives: spectral clustering, hierarchical

(bottom-up, agglomerative or top-down, divisive)

Page 79: Lecture 11: Texture - cs.princeton.edu

Coming back to textons

Page 80: Lecture 11: Texture - cs.princeton.edu

Clustering Textons

• Output of bank of n filters can be thought of as vector in n-dimensional space

• Can cluster these vectors using k-means [Malik et al.]

• Result: dictionary of most common textures

Page 81: Lecture 11: Texture - cs.princeton.edu

Clustering Textons

Image

Clustered TextonsTexton to Pixel Mapping

Malik

Page 82: Lecture 11: Texture - cs.princeton.edu

Using Texture in Segmentation

• Compute histogram of how many times each of the k clusters occurs in a neighborhood

• Define similarity of histograms hi and hj using χ2

• Different histograms → separate regions

�2 =1

2

X

k

(hi(k)� hj(k))2

hi(k) + hj(k)

Page 83: Lecture 11: Texture - cs.princeton.edu

Application: Segmentation

Malik

Page 84: Lecture 11: Texture - cs.princeton.edu

Texture synthesis

Page 85: Lecture 11: Texture - cs.princeton.edu

Markov Random Fields

• Different way of thinking about textures• Premise: probability distribution of a pixel

depends on values of neighbors• Probability the same throughout image– Extension of Markov chains

Page 86: Lecture 11: Texture - cs.princeton.edu

Motivation from Language

• Shannon (1948) proposed a way to synthesize new text using N-grams– Use a large text to compute probability distributions of

each letter given N–1 previous letters – Starting from a seed repeatedly sample the conditional

probabilities to generate new letters– Can do this with image patches!

Efros

Page 87: Lecture 11: Texture - cs.princeton.edu

Texture Synthesis Based on MRF

• For each pixel in destination:– Take already-synthesized neighbors– Find closest match in original texture– Copy pixel to destination

• Efros & Leung 1999– Speedup by Wei & Levoy 2000– Extension to copying whole blocks

by Efros & Freeman 2001

Wei & Levoy

Page 88: Lecture 11: Texture - cs.princeton.edu

• Compute output pixels in scanline order (top-to-bottom,left-to-right)

Efros & Leung Algorithm

Efros

Page 89: Lecture 11: Texture - cs.princeton.edu

• Find candidate pixels based on similarities of pixel features in neighborhoods

Efros & Leung Algorithm

Efros

Page 90: Lecture 11: Texture - cs.princeton.edu

Efros & Leung Algorithm

• Similarities of pixel neighborhoods can be computed with squared differences (SSD)of pixel colors and/or filter bank responses

||( – )||2

Efros

Page 91: Lecture 11: Texture - cs.princeton.edu

Efros & Leung Algorithm

• For each pixel p:– Find the best matching K windows from the input image– Pick one matching window at random– Assign p to be the center pixel of that window

input image

p

Efros

Page 92: Lecture 11: Texture - cs.princeton.edu

Synthesis Results

Efros

Page 93: Lecture 11: Texture - cs.princeton.edu

Synthesis Results

white bread brick wall

Efros

Page 94: Lecture 11: Texture - cs.princeton.edu

Hole Filling

• Fill pixels in “onion skin” order– Within each “layer”, pixels with most neighbors

are synthesized first– Normalize error by the number of known pixels– If no close match can be found, the pixel is not

synthesized until the end

Page 95: Lecture 11: Texture - cs.princeton.edu

Hole Filling

Efros

Page 96: Lecture 11: Texture - cs.princeton.edu

Extrapolation

Page 97: Lecture 11: Texture - cs.princeton.edu

Special video

https://ghc.anitab.org/ghc-17-livestream/

(Wednesday keynote, 16:20 min - 44:00 min)