• 沒有找到結果。

Image stitching

N/A
N/A
Protected

Academic year: 2022

Share "Image stitching"

Copied!
18
0
0

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

全文

(1)

Image stitching

Digital Visual Effects, Spring 2007 Yung-Yu Chuang

2007/4/3

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

Image stitching

• Stitching = alignment + blending

geometrical registration

photometric registration

Applications of image stitching

• Video stabilization

• Video summarization

• Video compression

• Video matting

• Panorama creation

Video summarization

(2)

Video compression Object removal

input video

Object removal

remove foreground

Object removal

estimate background

(3)

Object removal

background estimation

Panorama creation

Why panorama?

• Are you getting the whole picture?

– Compact Camera FOV = 50 x 35°

Why panorama?

• Are you getting the whole picture?

– Compact Camera FOV = 50 x 35°

– Human FOV = 200 x 135°

(4)

Why panorama?

• Are you getting the whole picture?

– Compact Camera FOV = 50 x 35°

– Human FOV = 200 x 135°

– Panoramic Mosaic = 360 x 180°

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

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!

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

(5)

Changing camera center

• Does it still work? synthetic PP PP1

PP2

Planar scene (or far away)

• 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

Motion models

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

2D Motion models

(6)

Motion models

Translation

2 unknowns

Affine

6 unknowns

Perspective

8 unknowns

3D rotation

3 unknowns

A case study: cylindrical panorama

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

mosaic projection cylinder

Cylindrical panoramas

• Steps

Reproject each image onto a cylinder Blend

Output the resulting mosaic

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

(7)

Taking pictures

Kaidan panoramic tripod head

Translation model

Cylindrical projection Cylindrical projection

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

(8)

Cylindrical projection

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

Cylindrical projection

unwrapped cylinder

x y

f

θ

x

z Cylindrical projection

unwrapped cylinder

x y

θ

x y

f

Cylindrical projection

unwrapped cylinder

x y

z

x y

f

s=f

gives less distortion

(9)

f = 180 (pixels)

Cylindrical reprojection

f = 380 f = 280

Image 384x300

top-down view Focal length – the dirty secret…

A simple method for estimating f

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

d f w

p

Input images Cylindrical warping

(10)

Blending

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

Blending

Blending Blending

(11)

Assembling the panorama

• Stitch pairs together, blend, then crop

Problem: Drift

• Error accumulation

small errors accumulate over time

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 (y1yn)/(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)

End-to-end alignment and crop

(12)

Viewer: panorama

++

++

++ ++

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

Viewer: texture mapped model

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

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

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 for each image, find feature matches.

(13)

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

' '

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

M M M M M

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?

Normal equation

( )

2

)

( x = Axb E

⎥ ⎥

⎥ ⎥

⎥ ⎥

⎢ ⎢

⎢ ⎢

⎢ ⎢

=

⎥ ⎥

⎢ ⎢

⎥ ⎥

⎥ ⎥

⎥ ⎥

⎢ ⎢

⎢ ⎢

⎢ ⎢

n m

nm n

m

b b

x x

a a

a a

: : : :

...

: :

: :

: :

...

1

1

1

1 11

nxm, n equations, m variables

(14)

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

ijx b

a E

1

2

1

)

2

(

x Ax b

Normal equation

( ) ∑ ∑

= =

⎥ ⎥

⎢ ⎢

⎡ ⎟⎟ ⎠ −

⎜⎜ ⎞

= ⎛

=

n

i

i m

j

j

ijx 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

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

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

= ∂

(15)

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 them are generated from a model with

parameters Θ, try to recover Θ.

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.

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

= −

293 0.5 6

97 0.6 6

35 0.5 3

k p n for P=0.99

Example: line fitting

(16)

Example: line fitting

n=2

Model fitting

Measure distances Count inliers

c=3

(17)

Another trial

c=3

The best model

c=15

RANSAC for Homography RANSAC for Homography

(18)

RANSAC for Homography Applications of panorama in VFX

• Background plates

• Image-based lighting

Spiderman 2 (background plate) Troy (image-based lighting)

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

參考文獻

相關文件

The overall system is shown in figure 1. An infrared sensitive camera synchronized with infrared LEDs is used as a sensor and produces an image with highlighted pupils. The

We propose a digital image stabilization algorithm based on an image composition technique using four source images.. By using image processing techniques, we are able to reduce

• 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

It is a self calibration technique and called automatic camera tracking calibration technique and called automatic camera tracking or

She is going to buy them a digital camera, because they love taking pictures of..

By analyzing five image with a Macbeth color checker taken under different light sources (Day light, Cool- white, TL-84 light, A light, H light), the distribution plots (in G/R,

We model the HDR- to-LDR image formation pipeline as the (1) dynamic range clipping, (2) non-linear mapping from a camera response function, and (3) quantization1. We then propose