• 沒有找到結果。

Image stitching

N/A
N/A
Protected

Academic year: 2022

Share "Image stitching"

Copied!
100
0
0

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

全文

(1)

Image stitching

Digital Visual Effects, Spring 2005 Yung-Yu Chuang

2005/3/30

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

(2)

Announcements

• Project #1 was due yesterday.

• Project #2 handout will be available on the web later tomorrow.

• I will set up a webpage for artifact voting soon.

(3)

Outline

• Image stitching

• Motion models

• Direct methods

• Feature-based methods

• Applications

• Project #2

(4)

Image stitching

• Stitching = alignment + blending

geometrical registration

photometric registration

(5)

Applications of image stitching

• Video stabilization

• Video summarization

• Video compression

• Video matting

• Panorama creation

(6)

Video summarization

(7)

Video compression

(8)

Video matting

input video

(9)

Video matting

remove foreground

(10)

Video matting

estimate background

(11)

Video matting

background estimation

(12)

Video matting

alpha matte

(13)

Panorama creation

(14)

Why panorama?

• Are you getting the whole picture?

– Compact Camera FOV = 50 x 35°

(15)

Why panorama?

• Are you getting the whole picture?

– Compact Camera FOV = 50 x 35°

– Human FOV = 200 x 135°

(16)

Why panorama?

• Are you getting the whole picture?

– Compact Camera FOV = 50 x 35°

– Human FOV = 200 x 135°

– Panoramic Mosaic = 360 x 180°

(17)

Panorama examples

• Panorama mode in consumer cameras

• Mars:

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

• Earth:

http://earthobservatory.nasa.gov/Newsroom/BlueMarble/

(18)

2D motion models

• translation: x’ = x + t x = (x,y)

• rotation: x’ = R x + t

• similarity: x’ = s R x + t

• affine: x’ = A x + t

• perspective: x’ ≅ H x x = (x,y,1) (x is a homogeneous coordinate)

• These all form a nested group (closed under composition w/ inv.)

(19)

2D image transformations

(20)

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!

(21)

Mosaic as 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

(22)

Changing camera center

• Does it still work? synthetic PP PP1

PP2

(23)

Planar scene (or far away)

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

• This is how big areal photographs are made

PP1

PP3

PP2

(24)

3D motion models

u

(X,Y,Z) f u

(25)

3D motion models

• Rotational

• Cylindrical

(26)

Direct methods

• Select a motion model and estimate parameters

• Direct methods use pixel-to-pixel matching

• We have covered this last time actually.

• We will show a case study on constructing cylindrical panorama using a direct method.

(27)

A case study: cylindrical panorama

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

3. Compute pairwise alignments using the hierarchical Lucas-Kanade algorithm

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

6. Crop the result and import into a viewer

(28)

Taking pictures

Kaidan panoramic tripod head

(29)

Translation model

(30)

A case study: cylindrical panorama

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

mosaic projection cylinder

(31)

Map 3D point (X,Y,Z) onto cylinder

Cylindrical projection

X Y

Z

unit cylinder

unwrapped cylinder

Convert to cylindrical coordinates

cylindrical image

Convert to cylindrical image coordinates

(32)

f = 180 (pixels)

Cylindrical reprojection

f = 380 f = 280

Image 384x300

top-down view Focal length – the dirty secret…

(33)

A simple method for estimating f

We will discuss more accurate methods next time

(34)

Distortion

• Radial distortion of the image

Caused by imperfect lenses

Deviations are most noticeable for rays that pass through the edge of the lens

No distortion Pin cushion Barrel

(35)

Radial correction

• Correct for “bending” in wide field of view lenses

(36)

Input images

(37)

Cylindrical warping

(38)

Alignment

a rotation of the camera is a translation of the cylinder!

( )

( )

=

y x

y y x

x

y x

y y

x

y x

y x

y x y

x

x

y x I y

x J I

y x I y

x J I v

u I

I I

I I I

, ,

,

2 ,

, ,

2

) , ( )

, (

) , ( )

, (

(39)

LucasKanadeStep

void LucasKanadeStep(CByteImage& img1, CByteImage& img2, float t[2]) { // Transform the image

Translation(img2, img2t, t);

// Compute the gradients and summed error by comparing img1 and img2t double A[2][2], b[2];

for (int y = 1; y < height-1; y++) { // ignore borders for (int x = 1; x < width-1; x++) {

// If both have full alphas, then compute and accumulate the error double e = img2t.Pixel(x, y, k) - img1.Pixel (x, y, k);

// Accumulate the matrix entries

double gx = 0.5*(img2t.Pixel(x+1, y, k) - img2t.Pixel(x-1, y, k));

double gy = 0.5*(img2t.Pixel(x, y+1, k) - img2t.Pixel(x, y-1, k));

A[0][0] += gx*gx; A[0][1] += gx*gy;

A[1][0] += gx*gy; A[1][1] += gy*gy;

b[0] += e*gx; b[1] += e*gy;

} }

(40)

LucasKanadeStep (cont.)

// Solve for the update At=b and update the vector double det = 1.0 / (A[0][0]*A[1][1] - A[1][0]*A[1][0]);

t[0] += (A[1][1]*b[0] - A[1][0]*b[1]) * det;

t[1] += (A[0][0]*b[1] - A[1][0]*b[0]) * det;

}

(41)

PyramidLucasKanade

void PyramidalLucasKanade(CByteImage& img1, CByteImage& img2, float t[2], int nLevels, int nLucasKanadeSteps)

{

CBytePyramid p1(img1); // Form the two pyramids CBytePyramid p2(img2);

// Process in a coarse-to-fine hierarchy for (int l = nLevels-1; l >= 0; l--)

{

t[0] /= (1 << l); // scale the t vector t[1] /= (1 << l);

CByteImage& i1 = p1[l];

CByteImage& i2 = p2[l];

for (int k = 0; k < nLucasKanadeSteps; k++) LucasKanadeStep(i1, i2, t);

t[0] *= (1 << l); // restore the full scaling t[1] *= (1 << l);

} }

(42)

Gaussian pyramid

(43)

Blending

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

(44)

Blending

(45)

Blending

(46)

Blending

(47)

Assembling the panorama

• Stitch pairs together, blend, then crop

(48)

Problem: Drift

• Error accumulation

small errors accumulate over time

(49)

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)

(50)

End-to-end alignment and crop

(51)

Viewer: panorama

++

++

++ ++

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

(52)

Viewer: texture mapped model

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

(53)

Feature-based methods

• Only use feature points to estimate parameters

• We will study the “Recognising panorama”

paper published in ICCV 2003

(54)

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 Θ.

(55)

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.

(56)

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

(57)

Example: line fitting

(58)

n=2

(59)

Model fitting

(60)

Measure distances

(61)

Count inliers

c=3

(62)

Another trial

c=3

(63)

The best model

c=15

(64)

Recognising Panoramas

• 1D Rotations (θ)

– Ordering ⇒ matching images

(65)

Recognising Panoramas

• 1D Rotations (θ)

– Ordering ⇒ matching images

(66)

Recognising Panoramas

• 1D Rotations (θ)

– Ordering ⇒ matching images

(67)

Recognising Panoramas

• 1D Rotations (θ)

– Ordering ⇒ matching images

• 2D Rotations (q, f)

– Ordering ⇒ matching images

(68)

Recognising Panoramas

• 1D Rotations (θ)

– Ordering ⇒ matching images

• 2D Rotations (q, f)

– Ordering ⇒ matching images

(69)

Recognising Panoramas

• 1D Rotations (θ)

– Ordering ⇒ matching images

• 2D Rotations (q, f)

– Ordering ⇒ matching images

(70)

Recognising Panoramas

(71)

Overview

• SIFT Feature Matching

• Image Matching

• Bundle Adjustment

• Multi-band Blending

(72)

Nearest Neighbour Matching

• Find k-NN for each feature

– k ≈ number of overlapping images (we use k = 4)

• Use k-d tree

– k-d tree recursively bi-partitions data at mean in the dimension of maximum variance

– Approximate nearest neighbours found in O(nlogn)

(73)

Overview

• SIFT Feature Matching

• Image Matching

– For each image, use RANSAC to select inlier features from 6 images with most feature matches

• Bundle Adjustment

• Multi-band Blending

(74)

RANSAC for Homography

(75)

RANSAC for Homography

(76)

RANSAC for Homography

(77)

Probabilistic model for verification

• Compare probability that this set of RANSAC inliers/outliers was generated by a

correct/false image match

• Choosing values for p1, p0 and pmin

(78)

Finding the panoramas

(79)

Finding the panoramas

(80)

Finding the panoramas

(81)

Finding the panoramas

(82)

Overview

• SIFT Feature Matching

• Image Matching

• Bundle Adjustment

• Multi-band Blending

(83)

• Parameterise each camera by rotation and focal length

• This gives pairwise homographies

Homography for Rotation

(84)

Error function

• Sum of squared projection errors

– n = #images

– I(i) = set of image matches to image i

– F(i, j) = set of feature matches between images i,j – rijk = residual of kth feature match between images

i,j

• Robust error function

(85)

Overview

• SIFT Feature Matching

• Image Matching

• Bundle Adjustment

• Multi-band Blending

(86)

Multi-band Blending

• Burt & Adelson 1983

– Blend frequency bands over range ∝ λ

(87)

Low frequency (λ > 2 pixels)

High frequency (λ < 2 pixels)

2-band Blending

(88)

Linear Blending

(89)

2-band Blending

(90)

Results

(91)

Direct vs feature-based

• Direct methods use all information and can be very accurate, but they depend on the fragile

“brightness constancy” assumption

• Iterative approaches require initialization

• Not robust to illumination change and noise images

• In early days, direct method is better.

• Feature based methods are now more robust and potentially faster

• Even better, it can recognize panorama without initialization

(92)

Applications of panorama in VFX

• Background plates

• Image-based lighting

(93)

Spiderman 2 (background plate)

(94)

Troy (image-based lighting)

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

(95)

Project #2 Image stitching

• Assigned: 3/30

• Due: 11:59pm 4/19

• Work in pairs

(96)

Reference software

• Autostitch

http://www.cs.ubc.ca/~mbrown/autostitch/autostitch.html

• Many others are available online.

(97)

Bells & whistles

• Full SIFT implementation

• Recognizing panorama

• Bundle adjustment

• Handle dynamic objects

• Better blending techniques

(98)

Artifacts

• Take your own pictures and generate a stitched image, be creative.

http://www.cs.washington.edu/education/courses/cse590ss/01wi/projec ts/project1/students/allen/index.html

• Common focal point

• Rotate your camera to increase vertical FOV

• Tripod

• Fixed exposure?

Tips for taking pictures

(99)

Submission

• You have to turn in your complete source, the executable, a html report and an artifact.

• Report page contains:

description of the project, what do you learn, algorithm, implementation details, results, bells and whistles…

• Artifacts must be made using your own program.

artifacts voting on forum.

(100)

Reference

• Richard Szeliski, Image Alignment and Stitching, unpublished draft, 2005.

• 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.

參考文獻

相關文件

We focus on this part and propose a search method called pre-selected-pulses replacement method to replace the focused search method in G.729 to reduce the complexity for

The Research on Consuming Intention Affected by Government Housing Policy, Media &amp; Customers’ Preference.. -A Case Study to Taichung County

A cylindrical glass of radius r and height L is filled with water and then tilted until the water remaining in the glass exactly covers its base.. (a) Determine a way to “slice”

mNewLine ; invoke the macro This is how you define and invoke a simple macro. The assembler will substitute &#34;call

For your reference, the following shows an alternative proof that is based on a combinatorial method... For each x ∈ S, we show that x contributes the same count to each side of

In this thesis, we present a Threshold Jumping (TJ) and a Warp-Around Scan (WAS) techniques aim to coordinate simultaneous communications in high density RFID

In this thesis, we propose a novel image-based facial expression recognition method called “expression transition” to identify six kinds of facial expressions (anger, fear,

Results of this study show: (1) involvement has a positive effect on destination image, and groups with high involvement have a higher sense of identification with the “extent