Vous êtes sur la page 1sur 3

Combining images

In many contexts, its useful to make new images by


combining elements of several images
Trivial example: video crossfade

Digital compositing

smooth transition from one scene to another


for several frames we compute

CS417 Lecture 3
note: weights sum to 1.0
no unexpected brightening or darkening
no out-of-range results
Cornell CS417 Spring 2003 Lecture 3

2003 Steve Marschner 1

Cornell CS417 Spring 2003 Lecture 3

Foreground and background

2003 Steve Marschner 2

Compositing example: film effects

In many cases just adding is not enough


Example: compositing in film production

[Titanic ; DigitalDomain; vfxhq.com]

shoot foreground and background separately


also include CG elements

Cornell CS417 Spring 2003 Lecture 3

2003 Steve Marschner 3

Cornell CS417 Spring 2003 Lecture 3

2003 Steve Marschner 4

Foreground and background

Foreground and background

In many cases just adding is not enough


Example: compositing in film production

How we compute new image varies with position

shoot foreground and background separately


also include CG elements
this kind of thing has been done in analog for decades
how should we do it digitally?

use background
[Chuang et al. / Corel]

use foreground

Therefore, need to store some kind of tag to say what


parts of the image are of interest
Cornell CS417 Spring 2003 Lecture 3

2003 Steve Marschner 5

Cornell CS417 Spring 2003 Lecture 3

2003 Steve Marschner 6

Binary image mask

Partial pixel coverage

First idea: store one bit per pixel

The problem: pixels near boundary are not strictly


foreground or background

answers question is this pixel part of the foreground?

[Chuang et al. / Corel]

overlap

how to represent this simply?

does not work well near edges

Cornell CS417 Spring 2003 Lecture 3

2003 Steve Marschner 7

Cornell CS417 Spring 2003 Lecture 3

2003 Steve Marschner 8

Alpha compositing

Independent coverage assumption

Formalized in 1984 by Porter & Duff

Simplifying assumption: covered areas are independent

used in essentially identical form since

that is, uncorrelated in the statistical sense

[Porter & Duff 84]

Store fraction of pixel covered, called a


A covers
area a
B shows
through
area (1 - a)

nice clean implementation: 8 more bits makes 32


obviously works for image over solid background
what about image over image over image ?
Cornell CS417 Spring 2003 Lecture 3

2003 Steve Marschner 9

Cornell CS417 Spring 2003 Lecture 3

Independent coverage assumption

2003 Steve Marschner 10

Alpha compositingexample

this

not this

or this

This will cause artifacts

[Chuang et al. / Corel]

Holds in most but not all cases

but well carry on anyway because it is simple and usually


works

Cornell CS417 Spring 2003 Lecture 3

2003 Steve Marschner 11

Cornell CS417 Spring 2003 Lecture 3

2003 Steve Marschner 12

Other compositing operations

Alpha compositingfailures

A or 0

positive correlation:
too much foreground
Cornell CS417 Spring 2003 Lecture 3

negative correlation:
too little foreground
2003 Steve Marschner 13

A or B or 0

A
B

B or 0

1 x 2 x 3 x 2 = 12 reasonable choices
Cornell CS417 Spring 2003 Lecture 3

[Porter & Duff 84]

[Chuang et al. / Corel]

[Cornell PCG]

Generalized form of
compositing equation:

2003 Steve Marschner 14

Vous aimerez peut-être aussi