Top Banner
Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14
51

Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Dec 17, 2015

Download

Documents

Kevin Hall
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Blending and Compositing

Computational PhotographyDerek Hoiem, University of Illinois

09/23/14

Page 2: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

hybridImage.m

Page 3: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

pyramids.m

Page 4: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Hybrid results

Pooja Bag

Page 5: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Donald Cha

Page 6: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Hao Gao

Page 7: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

This Class

How do I put an object from one image into another?

Page 8: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Image Compositing

Some slides from Efros/Seitz

Page 9: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

News Composites

Original

“Enhanced” Version

http://www.guardian.co.uk/world/2010/sep/16/mubarak-doctored-red-carpet-picture

Page 10: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

News Composites

Original

“Enhanced” Version

Walski, LA Times, 2003

Page 11: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Three methods

1. Cut and paste

2. Laplacian pyramid blending

3. Poisson blending

Page 12: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Method 1: Cut and Paste

Page 13: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Method 1: Cut and PasteMethod:• Segment using intelligent scissors• Paste foreground pixels onto target region

Page 14: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Method 1: Cut and PasteProblems:• Small segmentation errors noticeable• Pixels are too blocky• Won’t work for semi-transparent materials

Page 15: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Feathering

Near object boundary pixel values come partly from foreground and partly from background

Page 16: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Method 1: Cut and Paste (with feathering)

Page 17: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Alpha compositing

+

Output = foreground*mask + background*(1-mask)

Page 18: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Alpha compositing with feathering

Output = foreground*mask + background*(1-mask)

Page 19: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Another example (without feathering)Mattes

Composite by David Dewey

Composite

Page 20: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Proper blending is key

Page 21: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Alpha Blending / Feathering

01

01

+

=Iblend = aIleft + (1-a)Iright

Page 22: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Affect of Window Size

0

1 left

right0

1

Page 23: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Affect of Window Size

0

1

0

1

Page 24: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Good Window Size

0

1

“Optimal” Window: smooth but not ghosted

Page 25: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

How much should we blend?

Page 26: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Method 2: Pyramid Blending

0

1

0

1

0

1

Left pyramid Right pyramidblend

• At low frequencies, blend slowly• At high frequencies, blend quickly

Page 27: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

laplacianlevel

4

laplacianlevel

2

laplacianlevel

0

left pyramid right pyramid blended pyramid

Page 28: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Method 2: Pyramid Blending

Burt and Adelson 1983

Page 29: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Laplacian Pyramid BlendingImplementation:1. Build Laplacian pyramids for each image2. Build a Gaussian pyramid of region mask3. Blend each level of pyramid using region mask from

the same level

4. Collapse the pyramid to get the final blended image

)1(2112iiiii RLRLL

Burt and Adelson 1983

Region mask at level i of Gaussian pyramid

Image 1 at level i of Laplacian pyramid

Pointwise multiply

Page 30: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Simplification: Two-band Blending

• Brown & Lowe, 2003– Only use two bands: high freq. and low freq.– Blends low freq. smoothly– Blend high freq. with no smoothing: use binary alpha

Page 31: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Low frequency

High frequency

2-band Blending

Page 32: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Linear Blending

Page 33: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

2-band Blending

Page 34: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Blending Regions

Page 35: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

© Chris Cameron

Page 36: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Related idea: Poisson BlendingA good blend should preserve gradients of source region without changing the background

Perez et al. 2003

Page 37: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Related idea: Poisson BlendingA good blend should preserve gradients of source region without changing the background

Perez et al. 2003

Project 3!

Page 38: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Method 3: Poisson BlendingA good blend should preserve gradients of source region without changing the background

Treat pixels as variables to be solved– Minimize squared difference between gradients of

foreground region and gradients of target region– Keep background pixels constant

Perez et al. 2003

Page 39: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Example

Source: Evan Wallace

Gradient Visualization

Page 40: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Source: Evan Wallace

+Specify object region

Page 41: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Gradient-domain editing

Creation of image = least squares problem in terms of: 1) pixel intensities; 2) differences of pixel intensities

Least Squares Line Fit in 2 Dimensions

2

2

minargˆ

minargˆ

bAvv

vav

v

v

i

iTi b

Use Matlab least-squares solvers for numerically stable solution with sparse A

Page 42: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Examples

1. Line-fitting: y=mx+b

Page 43: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Examples

2. Gradient domain processing

20 20 20 20

20 80 20 20

20 20 80 20

20 20 20 20

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

10 10 10 10

10 10 10 10

10 10 10 10

10 10 10 10

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

source image background image target image

10 10 10 10

10 v1 v310

10 v2 v410

10 10 10 10

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

Page 44: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Other results

Perez et al. 2003

Page 45: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

What do we lose?

Perez et al. 2003

• Foreground color changes• Background pixels in target region are replaced

Page 46: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Blending with Mixed Gradients• Use foreground or background gradient with

larger magnitude as the guiding gradient

Perez et al. 2003

Page 47: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Project 3: Gradient Domain Editing

General concept: Solve for pixels of new image that satisfy constraints on the gradient and the intensity– Constraints can be from one image (for filtering)

or more (for blending)

Page 48: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Project 3: Reconstruction from Gradients

1. Preserve x-y gradients2. Preserve intensity of one pixel

Source pixels: sVariable pixels: v3. minimize (v(x+1,y)-v(x,y) - (s(x+1,y)-s(x,y))^2 4. minimize (v(x,y+1)-v(x,y) - (s(x,y+1)-s(x,y))^2 5. minimize (v(1,1)-s(1,1))^2

Page 49: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Project 3 (extra): Color2Grayrgb2gray

?

Gradient-domain editing

Page 50: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

Project 3 (extra): NPR• Preserve gradients on edges

– e.g., get canny edges with edge(im, ‘canny’)

• Reduce gradients not on edges• Preserve original intensity

Perez et al. 2003

Page 51: Blending and Compositing Computational Photography Derek Hoiem, University of Illinois 09/23/14.

DVS Camera Links• Pencil balance

– https://www.youtube.com/watch?v=XVR5wEYkEGk

• Quad Copter• https://www.youtube.com/watch?v=LauQ6LWTkxM

• Tennis• https://www.youtube.com/watch?v=G1j2LLY5RIQ&t=27