image stitching

79
Image Stitching

Upload: edita

Post on 06-Jan-2016

66 views

Category:

Documents


0 download

DESCRIPTION

Image Stitching. Image Stitching. Align the images over each other camera pan ↔ translation on cylinder Blend the images together. Project 2 – image stitching. Take pictures on a tripod (or handheld) Warp images to spherical coordinates Extract features - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Image Stitching

Image Stitching

Page 2: Image Stitching

Richard Szeliski Image Stitching 2

Image Stitching

1. Align the images over each other– camera pan ↔ translation on cylinder

2. Blend the images together

Page 3: Image Stitching

Richard Szeliski Image Stitching 3

Project 2 – image stitching

1. Take pictures on a tripod (or handheld)2. Warp images to spherical coordinates3. Extract features4. Align neighboring pairs using RANSAC5. Write out list of neighboring translations6. Correct for drift7. Read in warped images and blend them8. Crop the result and import into a viewer

Page 4: Image Stitching

Richard Szeliski Image Stitching 4

Matching features

What do we do about the “bad” matches?

Page 5: Image Stitching

Richard Szeliski Image Stitching 5

RAndom SAmple Consensus

Select one match, count inliers

Page 6: Image Stitching

Richard Szeliski Image Stitching 6

RAndom SAmple Consensus

Select one match, count inliers

Page 7: Image Stitching

Richard Szeliski Image Stitching 7

Least squares fit

Find “average” translation vector

Page 8: Image Stitching

Richard Szeliski Image Stitching 8

Assembling the panorama

• Stitch pairs together, blend, then crop

Page 9: Image Stitching

Richard Szeliski Image Stitching 9

Problem: Drift

• Error accumulation– small (vertical) errors accumulate over time– apply correction so that sum = 0 (for 360° pan.)

Page 10: Image Stitching

Richard Szeliski Image Stitching 10

Problem: Drift

• Solution– add another copy of first image at the end– this gives a constraint: yn = y1

– 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)

Page 11: Image Stitching

Full-view (360° spherical) panoramas

Page 12: Image Stitching

Richard Szeliski Image Stitching 12

Full-view Panorama

++

++

++

++

Page 13: Image Stitching

Richard Szeliski Image Stitching 14

Global alignment

• Pairwise matching global energy function that involves all of the per-image pose parameters

• Local adjustments to reduce blurring due to local mis-registration

• Panorama recogition

Page 14: Image Stitching

Bundle Adjustment

• Developed in photogrammetry in 50´s , for general structure from motion (Szeliski and Kang 1994)

• Pairwise alignment

Page 15: Image Stitching

Bundle Adjustment• N features, appears in M images

Page 16: Image Stitching

Bundle Adjustment

• Given initial set of {Rj, Kj}, refine them together

• Xik depends on xij, error-in-variable• Overweighted for feature observed many times

Observed location of feature I in image k

Predicted location of feature I in image k

Page 17: Image Stitching

Bundle Adjustment

• True bundle adjustment to estimate camera pose and 3d points

• Disadvantages – A lot of variables to solve– Slow convergence

Page 18: Image Stitching

Bundle Adjustment

• Sparse matrix techniques• Levenberg-Marquardt

http://www.ics.forth.gr/~lourakis/sba/

Page 19: Image Stitching

20

Non-linear least squares• Linear approximation of residual• allows quadratic approximation of sum- of-squares

J0e

0T1-T

0TT

JJJ

0J2J2J

e

e

JJ 00 ee T

J)λdiag(JJJN' TT

N

(extra term = descent term)

Minimization corresponds to finding zeros of derivative

Levenberg-Marquardt: extra term to deal with singular N(decrease/increase if success/failure to descent)

Page 20: Image Stitching

21

Bundle Adjustment

U1

U2

U3

WT

W

V

P1 P2 P3 M

• Jacobian of has sparse block structure

– cameras independent of other cameras,– points independent of other points

J JJN T

12xm 3xn(in general much larger)

im.pts. view 1

m

i

n

jjiijD

1 1

2M̂P̂,m

Needed for non-linear minimization

Page 21: Image Stitching

22

Bundle AdjustmentEliminate dependence of camera/motion parameters on structure parametersNote in general 3n >> 11m

WT V

U-WV-1WT

NI0WVI 1

11xm 3xn

Allows much more efficient computations

e.g. 100 views,10000 points,

solve 1000x1000, not 30000x30000Often still band diagonaluse sparse linear algebra algorithms

Page 22: Image Stitching

Up Vector Selection

• Keep the upright direction at the final stitched image

• Multiply each roation by a global rotation Rg

Page 23: Image Stitching

Up Vector Selection

• rg1 is the smallest eigenvector of the scatter or moment matrix spanned by the individual camera rotation x-vectors

• Full rotation matrix Rg

Page 24: Image Stitching

Parallax Removal

• Blurry or ghosting – Unmodeled radial distortion– 3D parallax: failure to rotate the camera around

its optical center– Small scene motion, large scale scene motion

• Different approaches for them

Page 25: Image Stitching

Parallax Removal

• Based on bundle adjustment, compute 3D point location, then reproject it to images

Deghosting a mosaic with motion parallax (Shum and Szeliski 2000) c 2000 IEEE: (a) composite with parallax; (b) after a single deghosting step (patch size 32); (c) after multiple steps (sizes 32, 16 and 8)

Page 26: Image Stitching

Recognizing Panoramas

Matthew Brown & David LoweICCV’2003

Page 27: Image Stitching

Richard Szeliski Image Stitching 28

Recognizing Panoramas

[Brown & Lowe, ICCV’03]

Page 28: Image Stitching

Richard Szeliski Image Stitching 29

Finding the panoramas

• Find all pairwise image overlaps • Find connected components in the overlap graph

Page 29: Image Stitching

Richard Szeliski Image Stitching 30

Finding the panoramas

Page 30: Image Stitching

Richard Szeliski Image Stitching 31

Finding the panoramas

Page 31: Image Stitching

Richard Szeliski Image Stitching 32

Get you own free copy

http://get.live.com/photogallery/overview

Page 32: Image Stitching

Richard Szeliski Image Stitching 33

Rec.pano.: system components

1. Feature detection and description– more uniform point density

2. Fast matching (hash table)3. RANSAC filtering of matches4. Intensity-based verification5. Incremental bundle adjustment

• [M. Brown, R. Szeliski, and S. Winder. Multi-image matching using multi-scale oriented patches, CVPR'2005]

Page 33: Image Stitching

Richard Szeliski Image Stitching 37

Probabilistic Feature Matching

Page 34: Image Stitching

Richard Szeliski Image Stitching 38

RANSAC motion model

Page 35: Image Stitching

Richard Szeliski Image Stitching 39

RANSAC motion model

Page 36: Image Stitching

Richard Szeliski Image Stitching 40

RANSAC motion model

Page 37: Image Stitching

How well does this work?

Test on 100s of examples…

Page 38: Image Stitching

How well does this work?

Test on 100s of examples…

…still too many failures (5-10%)for consumer application

Page 39: Image Stitching

Richard Szeliski Image Stitching 44

Matching Mistakes: False Positive

Page 40: Image Stitching

Richard Szeliski Image Stitching 45

Matching Mistakes: False Positive

Page 41: Image Stitching

Richard Szeliski Image Stitching 46

Matching Mistake: False Negative• Moving objects: large areas of disagreement

Page 42: Image Stitching

Richard Szeliski Image Stitching 47

Matching Mistakes

• Accidental alignment– repeated / similar regions

• Failed alignments– moving objects / parallax– low overlap– “feature-less” regions

(more variety?)

• No 100% reliable algorithm?

Page 43: Image Stitching

Richard Szeliski Image Stitching 48

How can we fix these?

• Tune the feature detector• Tune the feature matcher (cost metric)• Tune the RANSAC stage (motion model)• Tune the verification stage• Use “higher-level” knowledge

– e.g., typical camera motions

• → Sounds like a big “learning” problem– Need a large training/test data set (panoramas)

Page 44: Image Stitching

Direct vs. Feature-based Alignment• Feature-based

– Confused in too textural or not textured enough region

– Features should be distributed evenly over the image– Relies on robust feature detection and matching

schemes

• Direct– Limited range of convergence, even hierarchical

framework– Work for video, fail for partially overlapping images

Page 45: Image Stitching

Image Compositing

• How to produce the final mosaic image?– Compositing surface (flat, cylindrical, spherical,

etc)– View (reference image)– Select and blend pixels to minimize visible seams,

blur, and ghosting

• Surface parameterization, pixel and seam selection, blending, exposure compensation…

Page 46: Image Stitching

Compositing Surface

• If only a few images --- flat panorama– select one image as reference and warp all the

others to the reference coordinate system– Still perspective projection

Page 47: Image Stitching

Compositing Surface

• Large field of view– Large distortion– Usually use a cylindrical or

spherical projection– Environment map

• Tradeoff between – keeping local appearance

undistorted, and – providing a reasonably uniform

sampling of the environment mosaic plane

Page 48: Image Stitching

View Selection

• Which part of the scene will be centered in the final composition– Average depth– Middle image in a 360 panorama– Image that contains the object of greatest interest – User control

Page 49: Image Stitching

Coordinate Transformations

• Mapping between input and output pixels– Flat surface: homography– Analytic form (cylindrical, spherical…)

• Pixel in panorama -> 3D view ray -> image• Precompute lookup tables

XY

Z

cylindrical image

Page 50: Image Stitching

Sampling Issues

• Low-resolution panorama than input images– Prefilter input images to avoid aliasing

Page 51: Image Stitching

Pixel Selection and Weighting (De-ghosting)

• Without perfect registration and identically exposed – Visible seams dues to exposure difference– Blurring due to mis-registration– Ghosting due to moving objects

• Which pixels to user? How to blend them?

Page 52: Image Stitching

Richard Szeliski Image Stitching 57

Image feathering

• Weight each image proportional to its distance from the edge (distance map [Danielsson, CVGIP 1980]

• 1. Generate weight map for each image• 2. Sum up all of the weights and divide by sum:

weights sum up to 1: wi’ = wi / ( ∑i wi)

Page 53: Image Stitching

Richard Szeliski Image Stitching 58

Image Feathering

Page 54: Image Stitching

Richard Szeliski Image Stitching 59

Feathering

01

01

+

=

Page 55: Image Stitching

Richard Szeliski Image Stitching 60

Effect of window size

0

1 left

right0

1

Page 56: Image Stitching

Richard Szeliski Image Stitching 61

Effect of window size

0

1

0

1

Page 57: Image Stitching

Richard Szeliski Image Stitching 62

Good window size

0

1

“Optimal” window: smooth but not ghosted

• Doesn’t always work...

Page 58: Image Stitching

Feathering and Center-Weighting

( ) ( )( )

( )

k kk

kk

w x I xC x

w x

Warped images

W_k: simple 0 or 1

Simple averaging: exposure difference, misregistration and scene movement are all visible

If rapidly moving objects are the only problem, taking median filter to remove them (Irani and Anandan 1998)

Page 59: Image Stitching

Feathering and Center-Weighting

• Weight on distance to image center

• Feathering: weighted averaging with a distance map

• Bluring, ghosting still exist

( ) arg min{ | ( ) is in valid}k kw x Iy

y x + yy

Feathered average

Page 60: Image Stitching

Feathering and Center-Weighting• Improve feathering

– Raise distance map value with larger power• Tradeoff between visible exposure difference and blur

– , • Select pixel with largest weight

( )pkw x

p ( )( ) ( ), arg max ( )l x kk

C x I x l w x

Page 61: Image Stitching

Feathering and Center-Weighting

• Have hard edges when exposure varyP=10 p=∞

Page 62: Image Stitching

Feathering and Center-Weighting

• Seam placement: optimal seam selection• Moving object produce most visible artifacts:

ghost– Region of difference where overlapping image

disagree– Construct a graph– Weighted vertex cover: find the smallest set of

vertexes without disagreement

Uyttendaele, Eden, and Szeliski (2001)

Page 63: Image Stitching

Seam Selection

Computation of regions of difference (RODs) (Uyttendaele, Eden, and Szeliski2001) c 2001 IEEE: (a) three overlapping images with a moving face; (b) corresponding RODs; (c) graph of coincident RODs.

Page 64: Image Stitching

ROD Seam Selection

Weighted ROD vertex cover with feathering

Page 65: Image Stitching

Photomontage

• First, Per-pixel image objective to good composites ( , ( ))D

x

C D x l xData penalty Chosing image l at pixel x

Agarwala, Dontcheva, Agrawala et al. 2004

Page 66: Image Stitching

Photomontage

• Second, seam objective that penalizes differences in labeling between adjacent images

• Optimization: Markov Random Field (MRF)• Poisson image blending

( , )

( , , ( ), ( ))Sx y N

C S x y l x l y

( , , ( ), ( )) ( ) ( ) ( ) ( )x y x yl l l lS x y l x l y I x I x I y I y Seam penalty

Page 67: Image Stitching

Seam Selection

• Graph cuts and Vertex cover both produce similar looking results – Graph cuts are slower because of optimization over all

pixels– Vertex cover is sensitive to thresholds used to determine

regions of difference

Page 68: Image Stitching

Blending

• Compensate for exposure difference and other mis-alignments

• Using weighted blending, hard to get balance between smoothing out exposure variations and preventing blurring

• Laplacian pyramid blending• Gradient domain blending• Exposure compensation

Page 69: Image Stitching

Image Blending

Page 70: Image Stitching

Laplacian Pyramid

• Result in perfect reconstruction when Q is the identity

Page 71: Image Stitching

Laplacian Pyramid

• Actual computation of high-pass filter

• Low-pass images: Gaussian images• High-pass (or band-pass) images: Laplacian Images

Page 72: Image Stitching

Richard Szeliski Image Stitching 77

Pyramid Blending

Burt, P. J. and Adelson, E. H., A multiresolution spline with applications to image mosaics, ACM Transactions on Graphics, 42(4), October 1983, 217-236.

Page 73: Image Stitching

Richard Szeliski Image Stitching 78

Laplacianlevel

4

Laplacianlevel

2

Laplacianlevel

0

left pyramid right pyramid blended pyramid

Page 74: Image Stitching

Richard Szeliski Image Stitching 79

Laplacian Image Blend

1. Compute Laplacian pyramid2. Compute Gaussian pyramid on weight image

(can put this in A channel)3. Blend Laplacians using Gaussian blurred

weights4. Reconstruct the final image

Page 75: Image Stitching

Pyramid Blending

Figure 9.17 h: pyramid blending

Page 76: Image Stitching

Gradient Domain Blending

• Perform blending in gradient domain rather than color domain

Poisson image editing (P´erez, Gangnet, and Blake 2003)

Page 77: Image Stitching

Gradient Domain Editing

• Guided Vector Field:

• Source image• Mixture gradient (source + target image)

Page 78: Image Stitching

Exposure Compensation

• Estimate local correction between source image and a blended composite

• Stitch image in the radiance domain – Convert image into radiance image – Create a stitched, high-dynamic range (HDR)

image

Page 79: Image Stitching

Richard Szeliski Image Stitching 84

Project 2 – image stitching

1. Take pictures on a tripod (or handheld)2. Warp images to spherical coordinates3. Extract features4. Align neighboring pairs using RANSAC5. Write out list of neighboring translations6. Correct for drift7. Read in warped images and blend them8. Crop the result and import into a viewer