Image stitching

74  Download (0)

Full text

(1)

Image stitching

Digital Visual Effects Yung-Yu Chuang

with slides by Richard Szeliski, Steve Seitz, Matthew Brown and Vaclav Hlavac

(2)

Image stitching

• Stitching = alignment + blending geometrical

registration

photometric registration

(3)

Applications of image stitching

• Video stabilization

• Video summarization

• Video compression

• Video matting

• Panorama creation

(4)

Video summarization

(5)

Video compression

(6)

Object removal

input video

(7)

Object removal

remove foreground

(8)

Object removal

estimate background

(9)

Object removal

background estimation

(10)

Panorama creation

(11)

Why panorama?

• Are you getting the whole picture?

– Compact Camera FOV = 50 x 35°

(12)

Why panorama?

• Are you getting the whole picture?

– Compact Camera FOV = 50 x 35°

– Human FOV = 200 x 135°

(13)

Why panorama?

• Are you getting the whole picture?

– Compact Camera FOV = 50 x 35°

– Human FOV = 200 x 135°

– Panoramic Mosaic = 360 x 180°

(14)

Panorama examples

• Like HDR, it is a topic of computational

photography, seeking ways to build a better camera mostly in software.

• Most consumer cameras have a panorama mode

• Mars:

http://www.panoramas.dk/fullscreen3/f2_mars97.html

• Earth:

http://www.panoramas.dk/new-year-2006/taipei.html http://www.360cities.net/

(15)

What can be globally aligned?

• In image stitching, we seek for a matrix to

globally warp one image into another. Are any two images of the same scene can be aligned this way?

– Images captured with the same center of projection

– A planar scene or far-away scene

(16)

A pencil of rays contains all views

real

camera synthetic

camera

Can generate any synthetic camera view

as long as it has the same center of projection!

(17)

Mosaic as an image reprojection

mosaic projection plane

• The images are reprojected onto a common plane

• The mosaic is formed on this plane

• Mosaic is a synthetic wide-angle camera

(18)

Changing camera center

• Does it still work? synthetic PP PP1

PP2

(19)

Planar scene (or a faraway one)

• PP3 is a projection plane of both centers of projection, so we are OK!

• This is how big aerial photographs are made

PP1

PP3

PP2

(20)

Motion models

• Parametric models as the assumptions on the relation between two images.

(21)

2D Motion models

(22)

Motion models

Translation

2 unknowns

Affine

6 unknowns

Perspective

8 unknowns

3D rotation

3 unknowns

(23)

A case study: cylindrical panorama

• What if you want a 360 field of view?

mosaic projection cylinder

(24)

Cylindrical panoramas

• Steps

– Reproject each image onto a cylinder – Blend

– Output the resulting mosaic

(25)

Cylindrical panorama

1. Take pictures on a tripod (or handheld) 2. Warp to cylindrical coordinate

3. Compute pairwise alignments

4. Fix up the end-to-end alignment 5. Blending

6. Crop the result and import into a viewer

It is required to do radial distortion correction for better stitching results!

(26)

Taking pictures

Kaidan panoramic tripod head

(27)

Translation model

Try to align this in PaintShop Pro

(28)

Where should the synthetic camera be

• The projection plan of some camera

• Onto a cylinder

real

camera synthetic

camera

(29)

Cylindrical projection

Adopted from http://www.cambridgeincolour.com/tutorials/image-projections.htm

(30)

Cylindrical projection

(31)

Cylindrical projection

Adopted from http://www.cambridgeincolour.com/tutorials/image-projections.htm

(32)

Cylindrical projection

unwrapped cylinder

y x

f

θ

x

(33)

z Cylindrical projection

unwrapped cylinder

y x

θ

x y

f

(34)

Cylindrical projection

unwrapped cylinder

y x

z x y

f s=f

gives less

distortion

(35)

f = 180 (pixels)

Cylindrical reprojection

f = 380 f = 280

Image 384x300

top-down view Focal length – the dirty secret…

(36)

A simple method for estimating f

Or, you can use other software, such as AutoStich, to help.

d f w

p

(37)

Input images

(38)

Cylindrical warping

(39)

Blending

• Why blending: parallax, lens distortion, scene motion, exposure difference

(40)

Blending

(41)

Blending

(42)

Blending

(43)

Assembling the panorama

• Stitch pairs together, blend, then crop

(44)

Problem: Drift

• Error accumulation

– small errors accumulate over time

(45)

Problem: Drift

• Solution

– add another copy of first image at the end

– there are a bunch of ways to solve this problem

• add displacement of (y1 – yn)/(n -1) to each image after the first

• compute a global warp: y’ = y + ax

• run a big optimization problem, incorporating this constraint

– best solution, but more complicated – known as “bundle adjustment”

(x1,y1)

copy of first image

(xn,yn)

(46)

End-to-end alignment and crop

(47)

Viewer: panorama

++

++

++ ++

example: http://www.cs.washington.edu/education/courses/cse590ss/01wi/projects/project1/students/dougz/index.html

(48)

Viewer: texture mapped model

example: http://www.panoramas.dk/

(49)

Cylindrical panorama

1. Take pictures on a tripod (or handheld) 2. Warp to cylindrical coordinate

3. Compute pairwise alignments

4. Fix up the end-to-end alignment 5. Blending

6. Crop the result and import into a viewer

(50)

Determine pairwise alignment?

• Feature-based methods: only use feature points to estimate parameters

• We will study the “Recognising panorama”

paper published in ICCV 2003

• Run SIFT (or other feature algorithms) for each image, find feature matches.

(51)

Determine pairwise alignment

• p’=Mp, where M is a transformation matrix, p and p’ are feature matches

• It is possible to use more complicated models such as affine or perspective

• For example, assume M is a 2x2 matrix

• Find M with the least square error

 

n

i

p Mp

1

' 2



 



 

 



 

y x m

m

m m

y x

22 21

12 11

' '

(52)

Determine pairwise alignment

• Overdetermined system



 



 

 



 

y x m

m

m m

y x

22 21

12 11

' '

' 1 22

1 21

1

' 1 12

1 11

1

y m

y m

x

x m

y m

x









































' ' ' 2

' 1

' 1

22 21 12 11 2

2

1 1

1 1

0 0

0 0

0 0

0 0

0 0

n n n

n n

n

y x x y x

m m m m

y x

y x

y x

y x

y x

 

(53)

Normal equation

Given an overdetermined system

b Ax

b A

Ax

A

T

T

the normal equation is that which minimizes the sum of the square differences between left and right sides

Why?

(54)

Normal equation

 

2

)

( xAxb E

 

 

 

 

 

 

 

 

 

 

 

 

 

 

n m

nm n

m

b b

x x

a a

a a

: : : :

...

: :

: :

: :

...

1

1

1

1 11

nxm, n equations, m variables

(55)

Normal equation

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

n m

j

j nj

i m

j

j ij m

j

j j

n i

m j

j nj m

j

j ij m

j

j j

b x

a

b x

a

b x

a

b b b

x a

x a

x a

1 1

1 1

1 1

1 1 1

1

: : :

:

: :

b

Ax

   

 

 

  

 

 

n

i

i m

j

j

ij

x b

a E

1

2

1

)

2

( x Ax b

(56)

Normal equation

   

 

 

  

 

 

n

i

i m

j

j

ij

x b

a E

1

2

1

)

2

( x Ax b

 

 

1

0 x

E

 

n

i

i i n

i

j m

j

ij

i

a x a b

a

1

1

1 1

1

2

2

1

1 1

2

i

n i

i m

j

j

ij

x b a

  a

 

 

  

 

) (

2

0 A Ax A b

x

T

T

 

  E

b A

Ax

A

T

T

(57)

Normal equation

 

   

   

 

    A b x A b x b b

Ax A

x

b b b

A x

Ax b

Ax A

x

b Ax

b A

x

b Ax

b Ax

b Ax

b Ax

b Ax

T T T T

T T

T

T T

T T

T T

T T

T

T T

T 2

b A Ax

x A

T

T

2

2 

 

E

(58)

Determine pairwise alignment

• p’=Mp, where M is a transformation matrix, p and p’ are feature matches

• For translation model, it is easier.

• What if the match is false? Avoid impact of outliers.

   

 

n

i

i i

i

i x m y y

x m

E

1

' 2 2

' 2 1

1

0 m

E

(59)

RANSAC

• RANSAC = Random Sample Consensus

• An algorithm for robust fitting of models in the presence of many data outliers

• Compare to robust statistics

• Given N data points xi, assume that mjority of t hem are generated from a model with paramet ers , try to recover .

(60)

RANSAC algorithm

Run k times:

(1) draw n samples randomly

(2) fit parameters  with these n samples (3) for each of other N-n points, calculate

its distance to the fitted model, count the number of inlier points, c

Output  with the largest c

How many times?

How big?

Smaller is better

How to define?

Depends on the problem.

(61)

How to determine k

p: probability of real inliers

P: probability of success after k trials

k

p

n

P  1  ( 1  )

n samples are all inliers a failure

failure after k trials

) 1

log(

) 1

log(

p

n

k P

 

n p k

3 0.5 35

6 0.6 97

6 0.5 293 for P=0.99

(62)

Example: line fitting

(63)

Example: line fitting

n=2

(64)

Model fitting

(65)

Measure distances

(66)

Count inliers

c=3

(67)

Another trial

c=3

(68)

The best model

c=15

(69)

RANSAC for Homography

(70)

RANSAC for Homography

(71)

RANSAC for Homography

(72)

Applications of panorama in VFX

• Background plates

• Image-based lighting

(73)

Troy (image-based lighting)

http://www.cgnetworks.com/story_custom.php?story_id=2195&page=4

(74)

Spiderman 2 (background plate)

Figure

Updating...

References

Related subjects :