mid-level image editing with patchmatch - connelly barnes

102
Mid-level Image Editing with PatchMatch Connelly Barnes University of Virginia

Upload: others

Post on 12-Feb-2022

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Mid-level Image Editing with PatchMatch - Connelly Barnes

Mid-level Image Editing with PatchMatch

Connelly Barnes

University of Virginia

Page 2: Mid-level Image Editing with PatchMatch - Connelly Barnes

Pa

inti

ng

by

Ra

do

Ja

vor

Page 3: Mid-level Image Editing with PatchMatch - Connelly Barnes

20x speed

Page 4: Mid-level Image Editing with PatchMatch - Connelly Barnes
Page 5: Mid-level Image Editing with PatchMatch - Connelly Barnes

Why is Content Creation Hard?

Page 6: Mid-level Image Editing with PatchMatch - Connelly Barnes

Why Does it Matter?

Movies Games

Graphic Design Fabrication

Page 7: Mid-level Image Editing with PatchMatch - Connelly Barnes

Research Goals

•  Easier for everyone to create content

•  Smarter tools with an understanding of images

•  Strategies:

– Exploit statistics of the natural world

– Mid level (patch) image manipulation

Page 8: Mid-level Image Editing with PatchMatch - Connelly Barnes

Other Research Projects

[Digital Bas-Relief from 3D Scenes, SIGGRAPH ‘07] [Video Puppetry, A Performative… SIGGRAPH Asia ‘08]

[RealBrush, under review, Jingwan Lu at Princeton] [Optimizing Parallelism, Locality, …, ACM PLDI ‘13]

Page 9: Mid-level Image Editing with PatchMatch - Connelly Barnes

This Talk: PatchMatch

[Barnes et al, PatchMatch: A Randomized Correspondence Algorithm, SIGGRAPH ‘09]

Input Photograph Synthesized Output with User Constraints

Page 10: Mid-level Image Editing with PatchMatch - Connelly Barnes

Previous Work: Texture and Patches

[Efros and Leung ‘99] [Efros and Freeman ‘01]

[Hertzmann et al ‘01]

Page 11: Mid-level Image Editing with PatchMatch - Connelly Barnes

Three Example Applications

[Barnes et al, PatchMatch: A Randomized Correspondence Algorithm, SIGGRAPH ‘09]

Page 12: Mid-level Image Editing with PatchMatch - Connelly Barnes

Three Example Applications

[Photoshop demos]

Page 13: Mid-level Image Editing with PatchMatch - Connelly Barnes

Overview

•  Fast matching in images: the PatchMatch algorithm

–  Randomized algorithm

– Applications: Image editing and video tapestries

•  Matching under lighting and geometric variations

– Dealing with higher dimensional spaces

– Applications: computer vision, stitching and morphing, …

•  Impact

•  Future perspectives

Page 14: Mid-level Image Editing with PatchMatch - Connelly Barnes

Overview

•  Fast matching in images: the PatchMatch algorithm

–  Randomized algorithm

– Applications: Image editing and video tapestries

•  Matching under lighting and geometric variations

– Dealing with higher dimensional spaces

– Applications: computer vision, stitching and morphing, …

•  Impact

•  Future perspectives

Page 15: Mid-level Image Editing with PatchMatch - Connelly Barnes

Manual Hole Filling

Page 16: Mid-level Image Editing with PatchMatch - Connelly Barnes

Manual Hole Filling

Copy

Paste

Page 17: Mid-level Image Editing with PatchMatch - Connelly Barnes

Manual Hole Filling

Page 18: Mid-level Image Editing with PatchMatch - Connelly Barnes

Manual Hole Filling

Page 19: Mid-level Image Editing with PatchMatch - Connelly Barnes

Manual Hole Filling

Page 20: Mid-level Image Editing with PatchMatch - Connelly Barnes

Manual Hole Filling

Page 21: Mid-level Image Editing with PatchMatch - Connelly Barnes

Manual Hole Filling

Page 22: Mid-level Image Editing with PatchMatch - Connelly Barnes

Intuition for Automatic Hole Filling

Time:

O(n2)

Pseudocode:

For each patch p in the hole region:

Loop through all patches q in background region;

Find the most similar to p.

Page 23: Mid-level Image Editing with PatchMatch - Connelly Barnes

Hole Filling

Repeat

Initialize

hole

Update

image

Find NN

inside → out

[Wexler ‘04]

Page 24: Mid-level Image Editing with PatchMatch - Connelly Barnes

Hole Filling

Repeat

Initialize

hole

Update

image

Find NN

inside → out

[Wexler ‘04]

Page 25: Mid-level Image Editing with PatchMatch - Connelly Barnes

Problem

A B

“Hole” “Background”

Page 26: Mid-level Image Editing with PatchMatch - Connelly Barnes

Previous Work

kd-tree with PCA

[Hertzmann '01]

Time:

O(n log n)

Page 27: Mid-level Image Editing with PatchMatch - Connelly Barnes

Observation about Image Statistics

Page 28: Mid-level Image Editing with PatchMatch - Connelly Barnes

Observation about Image Statistics

a

f(a) = b - a

b

Page 29: Mid-level Image Editing with PatchMatch - Connelly Barnes

Observation about Image Statistics

Page 30: Mid-level Image Editing with PatchMatch - Connelly Barnes

0%#

10%#

20%#

30%#

40%#

50%#

60%#

0# 1# 2# 3# 4# 5# 6# 7# 8# 9# 10# 11# 12# 13# 14# 15# 16# 17# 18# 19# 20#

Percent'of'Patches'

Distance'from'Neighboring'Offset'[Pixels]'

Use Statistics to Make Fast Algorithm

58%

14%

10% 4% 14% …

Distribution of

Correspondence

Vectors

0%#

10%#

20%#

30%#

40%#

50%#

60%#

Percent'of'Patches'

0%#

0# 1# 2# 3# 4# 5# 6# 7# 8# 9# 10# 11# 12# 13# 14# 15# 16# 17# 18# 19# 20#

Distance'from'Neighboring'Offset'[Pixels]'

Page 31: Mid-level Image Editing with PatchMatch - Connelly Barnes

Matching: Translation Only

A B

Distribution of

Correspondence

Vectors

Page 32: Mid-level Image Editing with PatchMatch - Connelly Barnes

Intuition for PatchMatch

A B

?

?

?

Distribution of

Correspondence

Vectors

Page 33: Mid-level Image Editing with PatchMatch - Connelly Barnes

Intuition for PatchMatch

A B

Distribution of

Correspondence

Vectors

Page 34: Mid-level Image Editing with PatchMatch - Connelly Barnes

Intuition for PatchMatch

A B

Distribution of

Correspondence

Vectors

Page 35: Mid-level Image Editing with PatchMatch - Connelly Barnes

Intuition for PatchMatch

A B

Distribution of

Correspondence

Vectors

Page 36: Mid-level Image Editing with PatchMatch - Connelly Barnes

Intuition for PatchMatch

A B

Distribution of

Correspondence

Vectors

Page 37: Mid-level Image Editing with PatchMatch - Connelly Barnes

Step 1: Random Initialization

A B

Distribution of

Correspondence

Vectors

Page 38: Mid-level Image Editing with PatchMatch - Connelly Barnes

Step 2: Propagation

B

After propagation:

f(x, y) = argminD { current, left, above }

Good

Bad

OK

A

Distribution of

Correspondence

Vectors

Distribution of

Correspondence

Vectors

Page 39: Mid-level Image Editing with PatchMatch - Connelly Barnes

Step 2: Propagation

B

R

After propagation:

f(x, y) = argminD { current, left, above }

A

Distribution of

Correspondence

Vectors

Page 40: Mid-level Image Editing with PatchMatch - Connelly Barnes

Step 2: Propagation

B

R

A

Distribution of

Correspondence

Vectors

Page 41: Mid-level Image Editing with PatchMatch - Connelly Barnes

Step 3: Random Search

A B

Distribution of

Correspondence

Vectors

Page 42: Mid-level Image Editing with PatchMatch - Connelly Barnes

Step 3: Random Search

A B

Box width: w (image width)

Distribution of

Correspondence

Vectors

Page 43: Mid-level Image Editing with PatchMatch - Connelly Barnes

Step 3: Random Search

A B

Box width: αw

Distribution of

Correspondence

Vectors

Page 44: Mid-level Image Editing with PatchMatch - Connelly Barnes

Step 3: Random Search

A B

Box width: α2w

Distribution of

Correspondence

Vectors

Page 45: Mid-level Image Editing with PatchMatch - Connelly Barnes

Step 3: Random Search

A B

Box width: 1 pixel

Distribution of

Correspondence

Vectors

Page 46: Mid-level Image Editing with PatchMatch - Connelly Barnes

Propagation and Search

A B

After propagation and search:

f(x, y) = argminD { candidate correspondences }

Distribution of

Correspondence

Vectors

Page 47: Mid-level Image Editing with PatchMatch - Connelly Barnes

PatchMatch: Summary

Step 1: Initialization

Step 2: Propagation

Step 3: Random Search

Repeat until

Converged

Page 48: Mid-level Image Editing with PatchMatch - Connelly Barnes

Convergence

Page 49: Mid-level Image Editing with PatchMatch - Connelly Barnes

[After second iteration]

Convergence

10-100x faster than kd-tree

[After first iteration]

Propagation Random Search PatchMatch Ground Truth Propagation Random Search PatchMatch Ground Truth

Page 50: Mid-level Image Editing with PatchMatch - Connelly Barnes

Overview

•  Fast matching in images: the PatchMatch algorithm

–  Randomized algorithm

– Applications: Image editing and video tapestries

•  Matching under lighting and geometric variations

– Dealing with higher dimensional spaces

– Applications: computer vision, stitching and morphing, …

•  Impact

•  Future perspectives

Page 51: Mid-level Image Editing with PatchMatch - Connelly Barnes

Retargeting and Reshuffling

[Simakov '08]

Iterative Optimization Methods

Texture Synthesis [Kwatra '05]

Hole Filling [Wexler '04]

Page 52: Mid-level Image Editing with PatchMatch - Connelly Barnes

Hole Filling

Repeat

Initialize

hole

Update

image

Find NN

inside → out

[Wexler ‘04]

Page 53: Mid-level Image Editing with PatchMatch - Connelly Barnes

Retargeting / Reshuffling

Repeat

Initial

guess

Update

output

Find NN

A ↔ B

[Simakov ‘08]

Page 54: Mid-level Image Editing with PatchMatch - Connelly Barnes

Retargeting / Reshuffling

Repeat

Initial

guess

Update

output

Find NN

A ↔ B

[Simakov ‘08]

Page 55: Mid-level Image Editing with PatchMatch - Connelly Barnes

Hole Filling

Input Hole Output (enlarged)

Page 56: Mid-level Image Editing with PatchMatch - Connelly Barnes

Hole Filling

Input Hole Output (enlarged)

Page 57: Mid-level Image Editing with PatchMatch - Connelly Barnes

Hole Filling

Input Hole Output (enlarged)

Page 58: Mid-level Image Editing with PatchMatch - Connelly Barnes

Hole Filling

Input Hole Output (enlarged)

Page 59: Mid-level Image Editing with PatchMatch - Connelly Barnes

Reshuffling

Input Enlarged Reduced

Page 60: Mid-level Image Editing with PatchMatch - Connelly Barnes

Reshuffling

Page 61: Mid-level Image Editing with PatchMatch - Connelly Barnes

Example User Interaction

Page 62: Mid-level Image Editing with PatchMatch - Connelly Barnes

Overview

•  Fast matching in images: the PatchMatch algorithm

–  Randomized algorithm

– Applications: Image editing and video tapestries

•  Matching under lighting and geometric variations

– Dealing with higher dimensional spaces

– Applications: computer vision, stitching and morphing, …

•  Impact

•  Future perspectives

Page 63: Mid-level Image Editing with PatchMatch - Connelly Barnes

Video Tapestries: Inspiration

The Bayeux Tapestry

Trajan’s Column “The Achievement of the Grail” – Burne-Jones

Page 64: Mid-level Image Editing with PatchMatch - Connelly Barnes

Video Tapestries

Sta

r W

ars

– C

ou

rtes

y o

f Lu

casfi

lm L

td.

[Barnes et al, Video Tapestries with Continuous Temporal Zoom, SIGGRAPH ‘10]

Page 65: Mid-level Image Editing with PatchMatch - Connelly Barnes

Multi-scale Tapestries

K1

K2 ⋮

Km

Sm

S1

S2

Scale-space Volume (Zoom Animation)

Page 66: Mid-level Image Editing with PatchMatch - Connelly Barnes

Continuous Zoom

Scale-space Volume (Zoom Animation)

Zooming reduces cognitive load

Page 67: Mid-level Image Editing with PatchMatch - Connelly Barnes

Further Examples

Ra

ider

s o

f th

e Lo

st A

rk –

Co

urt

esy

of L

uca

sfilm

Ltd

Page 68: Mid-level Image Editing with PatchMatch - Connelly Barnes

Overview

•  Fast matching in images: the PatchMatch algorithm

–  Randomized algorithm

– Applications: Image editing and video tapestries

•  Matching under lighting and geometric variations

– Dealing with higher dimensional spaces

– Applications: computer vision, stitching and morphing, …

•  Impact

•  Future perspectives

Page 69: Mid-level Image Editing with PatchMatch - Connelly Barnes

k-Nearest Neighbors

Generalized Matching: Motivation

Rotations and Scales

[Barnes et al, The Generalized PatchMatch Correspondence Algorithm, ECCV ‘10]

Page 70: Mid-level Image Editing with PatchMatch - Connelly Barnes

Scales and Rotations

• Converges efficiently: extend random

search window from (x, y) to (x, y, θ, s)

Time [sec]

Ave

rag

e E

rro

r

40 sec

Page 71: Mid-level Image Editing with PatchMatch - Connelly Barnes

Arbitrary Descriptors

•  Any distance function (pairwise comparisons), e.g:

– SIFT, a popular computer vision descriptor

– Patches invariant to lighting changes

•  Convergence is output sensitive

Page 72: Mid-level Image Editing with PatchMatch - Connelly Barnes

k-Nearest Neighbors

•  Benchmarked 11 algorithms. Winner: heap.

•  Store k correspondences in heap, highest distance match on

top. If new candidate better, pop heap, push new candidate.

… …

50

10 20

25

Compare candidate

Av

era

ge

Err

or

[Lo

we

r is

be

tte

r]

Page 73: Mid-level Image Editing with PatchMatch - Connelly Barnes

Overview

•  Fast matching in images: the PatchMatch algorithm

–  Randomized algorithm

– Applications: Image editing and video tapestries

•  Matching under lighting and geometric variations

– Dealing with higher dimensional spaces

– Applications: computer vision, stitching and morphing, …

•  Impact

•  Future perspectives

Page 74: Mid-level Image Editing with PatchMatch - Connelly Barnes

Nonlocal Means Denoising

Noisy input

Page 75: Mid-level Image Editing with PatchMatch - Connelly Barnes

Nonlocal Means Denoising

Buades et al (11x11 search window), PSNR 28.9 dB

Page 76: Mid-level Image Editing with PatchMatch - Connelly Barnes

Nonlocal Means Denoising

Our kNN search (k=32), PSNR 29.1 dB

Page 77: Mid-level Image Editing with PatchMatch - Connelly Barnes

Nonlocal Means Denoising

Combine both, PSNR 30.9 dB

Page 78: Mid-level Image Editing with PatchMatch - Connelly Barnes

Nonlocal Means Denoising

Noisy Input

Page 79: Mid-level Image Editing with PatchMatch - Connelly Barnes

Nonlocal Means Denoising

Local Search

Page 80: Mid-level Image Editing with PatchMatch - Connelly Barnes

Nonlocal Means Denoising

Our kNN (Global)

Page 81: Mid-level Image Editing with PatchMatch - Connelly Barnes

Nonlocal Means Denoising

Combine both

Page 82: Mid-level Image Editing with PatchMatch - Connelly Barnes

Nonlocal Means Denoising

Ground truth

Page 83: Mid-level Image Editing with PatchMatch - Connelly Barnes

Nonlocal Means Denoising

Page 84: Mid-level Image Editing with PatchMatch - Connelly Barnes

Nonlocal Means Denoising

Local window search [Buades et al], PSNR: 27.8 dB

Global search [our kNN], PSNR: 27.4 dB

Combine local+global [our kNN], PSNR: 28.4 dB

State of the art [BM3D], PSNR: 29.9 dB

Page 85: Mid-level Image Editing with PatchMatch - Connelly Barnes

Detecting Forgeries

Original image (undoctored)

Page 86: Mid-level Image Editing with PatchMatch - Connelly Barnes

Detecting Forgeries

Doctored image (input)

Page 87: Mid-level Image Editing with PatchMatch - Connelly Barnes

Detecting Forgeries

kNN, neighbor 1

x

y

Legend

Page 88: Mid-level Image Editing with PatchMatch - Connelly Barnes

Detecting Forgeries

kNN, neighbor 2

x

y

Legend

Page 89: Mid-level Image Editing with PatchMatch - Connelly Barnes

Detecting Forgeries

Mask of Likely Forgery

Page 90: Mid-level Image Editing with PatchMatch - Connelly Barnes

Object Detection

•  Detect a template in a scene:

Template Scene

Page 91: Mid-level Image Editing with PatchMatch - Connelly Barnes

Object Detection

•  Label transfer:

Labeled

Photo

Known

Label

Unlabeled

Photo Transferred

Label

Page 92: Mid-level Image Editing with PatchMatch - Connelly Barnes

Overview

•  Fast matching in images: the PatchMatch algorithm

–  Randomized algorithm

– Applications: Image editing and video tapestries

•  Matching under lighting and geometric variations

– Dealing with higher dimensional spaces

– Applications: computer vision, stitching and morphing, …

•  Impact

•  Future perspectives

Page 93: Mid-level Image Editing with PatchMatch - Connelly Barnes

Stitching and Morphing

[Darabi et al, Image Melding: Combining Inconsistent Images…, SIGGRAPH ‘12]

Improvements:

(1) Match across geometrical changes, (2) Use image gradients

Page 94: Mid-level Image Editing with PatchMatch - Connelly Barnes

Source 1 Source 2

Our result Source 2 Source 1

Texture Transition

Page 95: Mid-level Image Editing with PatchMatch - Connelly Barnes

Source 1 Source 2

Morphing Result

Page 96: Mid-level Image Editing with PatchMatch - Connelly Barnes

Morphing for Fluid Animation

[NPR Fluids, under review, with Mark Browning at Princeton]

Page 97: Mid-level Image Editing with PatchMatch - Connelly Barnes

Overview

•  Fast matching in images: the PatchMatch algorithm

–  Randomized algorithm

– Applications: Image editing and video tapestries

•  Matching under lighting and geometric variations

– Dealing with higher dimensional spaces

– Applications: computer vision, stitching and morphing, …

•  Impact

•  Future perspectives

Page 98: Mid-level Image Editing with PatchMatch - Connelly Barnes

Interactivity Matters!

•  Minutes to second: now a creation tool

– Demos of our research: 8 million views on YouTube

– #1 feature of Photoshop CS5

– Award PC Magazine

Page 99: Mid-level Image Editing with PatchMatch - Connelly Barnes

Research Impact

1.  PatchMatch Stereo - Stereo Matching with Slanted Support Windows, Bleyer et al, BMVC 2011

2.  PMBP: PatchMatch Belief Propagation for Correspondence Field Estimation, Besse et al, BMVC 2012

3.  PatchMatch-Based Content Completion of Stereo Image Pairs, Morse et al, IEEE 3DIMPVT 2012

4.  PatchMatchGraph: Building a Graph of Dense Patch Correspondences for Label Transfer, Gould, ECCV 2011

5.  Parallel-Friendly Patch Match Based on Jump Flooding, Yu et al 2012

6.  Feature match: an efficient low dimensional PatchMatch technique, Ramakanth, Indian Conf. on Vision 2012

7.  Mixed-Resolution Patch-Matching, Sureka et al, ECCV 2012

8.  Non-parametric Texture Transfer Using MeshMatch, Chen et al, Adobe TR 2012

9.  TreeCann - k-d tree Coherence Approximate Nearest Neighbor algorithm, Olonetsky et al, ECCV 2012

10.  Coherency sensitive hashing, Korman et al, ICCV 2011

11.  Computing nearest-neighbor fields via Propagation-Assisted KD-Trees, He et al, CVPR 2012

Direct Follow-Ons

Page 100: Mid-level Image Editing with PatchMatch - Connelly Barnes

1.  PatchMatch Stereo - Stereo Matching with Slanted Support Windows, Bleyer et al, BMVC 2011 2.  PMBP: PatchMatch Belief Propagation for Correspondence Field Estimation, Besse et al, BMVC 2012 3.  PatchMatch-Based Content Completion of Stereo Image Pairs, Morse et al, IEEE 3DIMPVT 2012 4.  PatchMatchGraph: Building a Graph of Dense Patch Correspondences for Label Transfer, Gould, ECCV 2011 5.  Parallel-Friendly Patch Match Based on Jump Flooding, Yu et al 2012 6.  Feature match: an efficient low dimensional PatchMatch technique, Ramakanth, Indian Conf. on Vision 2012 7.  Mixed-Resolution Patch-Matching, Sureka et al, ECCV 2012 8.  Non-parametric Texture Transfer Using MeshMatch, Chen et al, Adobe TR 2012 9.  TreeCann - k-d tree Coherence Approximate Nearest Neighbor algorithm, Olonetsky et al, ECCV 2012 10.  Coherency sensitive hashing, Korman et al, ICCV 2011 11.  Computing nearest-neighbor fields via Propagation-Assisted KD-Trees, He et al, CVPR 2012

Direct Follow-Ons

12.  RepFinder: finding approximately repeated scene elements for image editing, Cheng et al, SIGGRAPH 2010 13.  A high-quality video denoising algorithm based on reliable motion estimation, Liu and Freeman, ECCV 2010 14.  Regenerative morphing, Shechtman et al, CVPR 2010 15.  Synthesizing structured image hybrids, Risser et al, SIGGRAPH 2010 16.  NRDC: Non-Rigid Dense Correspondence with Applications for Image Enhancement, HaCohen et al, SIGGRAPH 2011 17.  Transforming image completion, Mansfield et al, BMVC 2011 18.  Randomized motion estimation, Boltz and Nielsen, ICIP 2010 19.  Decoupled coarse-to-fine matching and nonlinear regularization for efficient motion estimation, Mariano and Sapiro, ICIP 2012 20.  Object Removal by Depth-guided Inpainting, He, Bleyer, Gelautz, Australian Association for Pattern Recognition 2011 21.  Interactive images: cuboid proxies for smart image manipulation, Zheng, Chen, Cheng, Zhou, Hu, Mitra, SIGGRAPH 2012 22.  A global sampling method for alpha matting, He, Rhemann, Rother, Tang, Sun, CVPR 2011 23.  ImageAdmixture: Putting Together Dissimilar Objects from Groups, Cheng et al, TVCG 2012 24.  Statistics of Patch Offsets for Image Completion, He et al, TVCG 2012 25.  Interactive image completion with perspective constraint, Hao et al VRCAI 2012 26.  Super-Resolution-based Inpainting, Le Meur et al, ECCV 2012 27.  Robust patch-based hdr reconstruction of dynamic scenes, Sen et al, SIGGRAPH Asia 2012

Papers Using Components of PatchMatch Algorithm

Page 101: Mid-level Image Editing with PatchMatch - Connelly Barnes

Conclusion

•  Patch nearest neighbor problem central to vision/graphics

•  New approach (PatchMatch) based on statistical sampling

•  Changing the way people look at image processing

•  Applications:

Image

Editing Video

Tapestries

Computer

Vision

Stitching and

Morphing

Page 102: Mid-level Image Editing with PatchMatch - Connelly Barnes

Collaborators

Frédo Durand (MIT)

Saman Amarasinghe (MIT)

Adam Finkelstein (Princeton)

Szymon Rusinkiewicz (Princeton)

Maneesh Agrawala (Berkeley)

Pradeep Sen (U. New Mexico)

Dan B Goldman (Adobe)

Eli Shechtman (Adobe)

Sylvain Paris (Adobe)

Jonathan Ragan-Kelley (MIT)

Andrew Adams (MIT)

Jingwan Lu (Princeton)

Mark Browning (Princeton)

Sam Ritter (Princeton)

David E Jacobs (Berkeley)

Jason Sanders (Berkeley)

Soheil Darabi (U. New Mexico)

Stephen DiVerdi (Google)