• 沒有找到結果。

Image stitching

N/A
N/A
Protected

Academic year: 2022

Share "Image stitching"

Copied!
83
0
0

加載中.... (立即查看全文)

全文

(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

background estimation

(8)

Panorama creation

(9)

Why panorama?

• Are you getting the whole picture?

Compact Camera FOV = 50 x 35°

(10)

Why panorama?

• Are you getting the whole picture?

Compact Camera FOV = 50 x 35°

Human FOV = 200 x 135°

(11)

Why panorama?

• Are you getting the whole picture?

Compact Camera FOV = 50 x 35°

Human FOV = 200 x 135°

Panoramic Mosaic = 360 x 180°

(12)

Panorama examples

• Similar to HDR, it is a topic of computational pho tography, seeking ways to build a better camera using either hardware or 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/

http://maps.google.com.tw/

(13)

What can be globally aligned?

• In image stitching, we seek for a matrix to glob ally warp one image into another. Are any two i mages of the same scene can be aligned this wa y?

– Images captured with the same center of pro jection

– A planar scene or far-away scene

(14)

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!

(15)

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

(16)

Changing camera center

• Does it still work? synthetic PP PP1

PP2

(17)

What cannot

• The scene with depth variations and the camera has movement

(18)

Planar scene (or a faraway one)

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

• This is how big aerial photographs are made

PP1

PP3

PP2

(19)

Motion models

• Parametric models as the assumptions on the re lation between two images.

(20)

2D Motion models

(21)

Motion models

Translation

2 unknowns

Affine

6 unknowns

Perspective

8 unknowns

3D rotation

3 unknowns

(22)

A case study: cylindrical panorama

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

mosaic projection cylinder

(23)

Cylindrical panoramas

• Steps

Reproject each image onto a cylinder Blend

Output the resulting mosaic

(24)

applet

• http://graphics.stanford.edu/courses/cs178/ap plets/projection.html

(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

(28)

Where should the synthetic camera be

• The projection plane 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)

Gradient-domain stitching

(44)

Gradient-domain stitching

(45)

Assembling the panorama

• Stitch pairs together, blend, then crop

(46)

Problem: Drift

• Error accumulation

small errors accumulate over time

(47)

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 const raint

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

(x1,y1)

copy of first image

(xn,yn)

(48)

End-to-end alignment and crop

(49)

Rectangling panoramas

video

(50)

Rectangling panoramas

(51)

Rectangling panoramas

(52)

Viewer: panorama

+

+

+ +

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

(53)

Viewer: texture mapped model

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

(54)

365-GB panorama (biggest on the earth)

Mont Blanc / Canon 70D / 70,000 images / 2-week shooting / 2-month processing

video web

London

(55)

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

(56)

Determine pairwise alignment?

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

• We will study the “Recognising panorama” pape r published in ICCV 2003

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

(57)

Determine pairwise alignment

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

• It is possible to use more complicated models s uch 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

' '

(58)

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

 

(59)

Normal equation

Given an overdetermined system

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

Why?

b Ax

b A

Ax

A

T

T

(60)

Normal equation

nxm, n equations, m variables

 

2

)

( xAxb E

 

 

 

 

 

 

 

 

 

 

 

 

 

 

n m

nm n

m

b b

x x

a a

a a

: : : :

...

: :

: :

: :

...

1

1

1

1 11

(61)

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

(62)

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

(63)

Normal equation

Ax b

2

(64)

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

(65)

Determine pairwise alignment

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

• For translation model, it is easier.

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

   

 

n

i

i i

i

i x m y y

x m

E

1

' 2 2

' 2 1

1

0 m

E

(66)

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 majority of them are generated from a model with paramet ers , try to recover .

(67)

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.

(68)

How to determine k

p: probability of real inliers

P: probability of success after k trials

n samples are all inliers a failure

failure after k trials

n p k

3 0.5 35

6 0.6 97

6 0.5 293 for P=0.99

k

p

n

P  1  ( 1  )

) 1

log(

) 1

log(

p

n

k P

 

(69)

Example: line fitting

(70)

Example: line fitting

n=2

(71)

Model fitting

(72)

Measure distances

(73)

Count inliers

c=3

(74)

Another trial

c=3

(75)

The best model

c=15

(76)

RANSAC for Homography

(77)

RANSAC for Homography

(78)

RANSAC for Homography

(79)

Tools for image stitching

• Hugin

• Image Composite Editor

• AutoStitch

• Google photo

• …

(80)

Applications of panorama in VFX

• Background plates

• Image-based lighting

(81)

Troy (image-based lighting)

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

(82)

Spiderman 2 (background plate)

(83)

Reference

Richard Szeliski, Image Alignment and Stitching: A Tutorial, Found ations and Trends in Computer Graphics and Computer Vision, 2(1) :1-104, December 2006.

R. Szeliski and H.-Y. Shum.

Creating full view panoramic image mosaics and texture-mapped models

, SIGGRAPH 1997, pp251-258.

M. Brown, D. G. Lowe, Recognising Panoramas, ICCV 2003.

參考文獻

相關文件

Having defined the training set (Fig. 18), the network nodes and connections (Fig. 19), the scene candidates (Fig. 20) and the compatibility functions (Fig. 21), we can use the

• void Preprocess(const Scene *scene) Called after scene has been initialized; do scene Called after scene has been initialized; do scene- dependent computation such as photon

• Non-uniform space subdivision (for example, kd tree and octree) is better than uniform grid kd-tree and octree) is better than uniform grid if the scene is

• The scene with depth variations and the camera has movement... Planar scene (or a

• Richard Szeliski, Image Alignment and Stitching: A Tutorial, Foundations and Trends in Computer Graphics and Computer Vision, 2(1):1-104, December 2006. Szeliski

• Richard Szeliski, Image Alignment and Stitching: A Tutorial, Foundations and Trends in Computer Graphics and Computer Vision, 2(1):1-104, December 2006. Szeliski

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

– Change Window Type to Video Scene Editor – Select Add → Images and select all images – Drag the strip to the “1st Frame” in Layer