Image Stitching Ali Farhadi CSE 576 Several slides from Rick Szeliski, Steve Seitz, Derek Hoiem, and Ira Kemelmacher.

Slides:



Advertisements
Similar presentations
Photo Stitching Panoramas from Multiple Images Computer Vision CS 543 / ECE 549 University of Illinois Derek Hoiem 02/28/12.
Advertisements

Image alignment Image from
Image alignment Image from
Mosaics con’t CSE 455, Winter 2010 February 10, 2010.
Photo Stitching Panoramas from Multiple Images Computer Vision CS 543 / ECE 549 University of Illinois Derek Hoiem 03/3/15.
Lecture 14: Panoramas CS4670: Computer Vision Noah Snavely What’s inside your fridge?
Announcements Project 2 Out today Sign up for a panorama kit ASAP! –best slots (weekend) go quickly...
Announcements Project 1 artifact voting ( announce later today) Project 2 out today (help session at end of class) IMPORTANT: choose Proj 2 partner.
Lecture 8: Geometric transformations CS4670: Computer Vision Noah Snavely.
Lecture 7: Image Alignment and Panoramas CS6670: Computer Vision Noah Snavely What’s inside your fridge?
Automatic Panoramic Image Stitching using Local Features Matthew Brown and David Lowe, University of British Columbia.
Lecture 11: Structure from motion CS6670: Computer Vision Noah Snavely.
Lecture 9: Image alignment CS4670: Computer Vision Noah Snavely
Announcements Project 2 out today panorama signup help session at end of class Today mosaic recap blending.
Announcements Project 1 artifact voting Project 2 out today panorama signup help session at end of class Guest lectures next week: Li Zhang, Jiwon Kim.
1Jana Kosecka, CS 223b Cylindrical panoramas Cylindrical panoramas with some slides from R. Szeliski, S. Seitz, D. Lowe, A. Efros,
Optical Flow Estimation
Lecture 8: Image Alignment and RANSAC
More Mosaic Madness : Computational Photography Alexei Efros, CMU, Fall 2005 © Jeffrey Martin (jeffrey-martin.com) with a lot of slides stolen from.
Image Warping and Mosacing : Rendering and Image Processing Alexei Efros …with a lot of slides stolen from Steve Seitz and Rick Szeliski.
Announcements Project 1 Grading session this afternoon Artifacts due Friday (voting TBA) Project 2 out (online) Signup for panorama kits ASAP (weekend.
Automatic Image Alignment (feature-based) : Computational Photography Alexei Efros, CMU, Fall 2006 with a lot of slides stolen from Steve Seitz and.
Image Stitching II Ali Farhadi CSE 455
Announcements Project 1 artifact voting Project 2 out today (help session at end of class)
Image warping/morphing Digital Video Special Effects Fall /10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.
Image Stitching Ali Farhadi CSEP 576 Several slides from Rick Szeliski, Steve Seitz, Derek Hoiem, and Ira Kemelmacher.
Feature Matching and RANSAC : Computational Photography Alexei Efros, CMU, Fall 2005 with a lot of slides stolen from Steve Seitz and Rick Szeliski.
Announcements Midterm due Friday, beginning of lecture Guest lecture on Friday: Antonio Criminisi, Microsoft Research.
Image Stitching Ali Farhadi CSE 455
CSE 185 Introduction to Computer Vision
CSC 589 Lecture 22 Image Alignment and least square methods Bei Xiao American University April 13.
Prof. Alex Berg (Credits to many other folks on individual slides)
Mosaics Today’s Readings Szeliski, Ch 5.1, 8.1 StreetView.
Image stitching Digital Visual Effects Yung-Yu Chuang with slides by Richard Szeliski, Steve Seitz, Matthew Brown and Vaclav Hlavac.
Example: line fitting. n=2 Model fitting Measure distances.
CS4670 / 5670: Computer Vision KavitaBala Lecture 17: Panoramas.
Computer Vision : CISC 4/689 Going Back a little Cameras.ppt.
10/19/10 Image Stitching Computational Photography Derek Hoiem, University of Illinois Photos by Russ Hewett.
10/27/15 Image Stitching Computational Photography Derek Hoiem, University of Illinois Photos by Russ Hewett.
Mosaics part 3 CSE 455, Winter 2010 February 12, 2010.
Image Stitching Computational Photography
776 Computer Vision Jan-Michael Frahm Spring 2012.
Image Stitching II Linda Shapiro CSE 455. RANSAC for Homography Initial Matched Points.
Mosaics Today’s Readings Szeliski and Shum paper (sections 1 and 2, skim the rest) –
CS559: Computer Graphics Lecture 7: Image Warping and Panorama Li Zhang Spring 2008 Most slides borrowed from Yungyu ChuangYungyu Chuang.
Image Stitching Computer Vision CS 691E Some slides from Richard Szeliski.
776 Computer Vision Jan-Michael Frahm Spring 2012.
Image warping/morphing Digital Visual Effects, Spring 2006 Yung-Yu Chuang 2005/3/15 with slides by Richard Szeliski, Steve Seitz and Alexei Efros.
Lecture 16: Image alignment
Image Stitching II Linda Shapiro EE/CSE 576.
CS4670 / 5670: Computer Vision Kavita Bala Lecture 20: Panoramas.
COSC579: Image Align, Mosaic, Stitch
Lecture 7: Image alignment
RANSAC and mosaic wrap-up
Image Stitching Slides from Rick Szeliski, Steve Seitz, Derek Hoiem, Ira Kemelmacher, Ali Farhadi.
Idea: projecting images onto a common plane
Announcements Project 2 out today (help session at end of class)
Image Stitching II Linda Shapiro EE/CSE 576.
Image Stitching II Linda Shapiro CSE 455.
2D transformations (a.k.a. warping)
Image Stitching Computer Vision CS 678
Announcements Project 1 Project 2 Vote for your favorite artifacts!
Announcements Project 1 artifact voting Project 2 out today
Image Stitching II Linda Shapiro EE/CSE 576.
Computational Photography
Calibration and homographies
Back to equations of geometric transformations
Image Stitching Linda Shapiro ECE/CSE 576.
Image Stitching II Linda Shapiro ECE P 596.
Image Stitching Linda Shapiro ECE P 596.
Presentation transcript:

Image Stitching Ali Farhadi CSE 576 Several slides from Rick Szeliski, Steve Seitz, Derek Hoiem, and Ira Kemelmacher

Combine two or more overlapping images to make one larger image Add example Slide credit: Vaibhav VaishVaibhav Vaish

How to do it? Basic Procedure 1.Take a sequence of images from the same position 1.Rotate the camera about its optical center 2.Compute transformation between second image and first 3.Shift the second image to overlap with the first 4.Blend the two together to create a mosaic 5.If there are more images, repeat

1. Take a sequence of images from the same position Rotate the camera about its optical center

2. Compute transformation between images Extract interest points Find Matches Compute transformation ?

3. Shift the images to overlap

4. Blend the two together to create a mosaic

5. Repeat for all images

How to do it? Basic Procedure 1.Take a sequence of images from the same position 1.Rotate the camera about its optical center 2.Compute transformation between second image and first 3.Shift the second image to overlap with the first 4.Blend the two together to create a mosaic 5.If there are more images, repeat ✓

Compute Transformations Extract interest points Find good matches Compute transformation ✓ Let’s assume we are given a set of good matching interest points ✓

mosaic PP Image reprojection The mosaic has a natural interpretation in 3D – The images are reprojected onto a common plane – The mosaic is formed on this plane

Example Camera Center

Image reprojection Observation – Rather than thinking of this as a 3D reprojection, think of it as a 2D image warp from one image to another

Motion models What happens when we take two images with a camera and try to align them? translation? rotation? scale? affine? Perspective?

Recall: Projective transformations (aka homographies)

Parametric (global) warping Examples of parametric warps: translation rotation aspect affine perspective

2D coordinate transformations 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)

Image Warping Given a coordinate transform x’ = h(x) and a source image f(x), how do we compute a transformed image g(x’) = f(h(x))? f(x)f(x)g(x’) xx’ h(x)h(x)

Forward Warping Send each pixel f(x) to its corresponding location x’ = h(x) in g(x’) f(x)f(x)g(x’) xx’ h(x)h(x) What if pixel lands “between” two pixels?

Forward Warping Send each pixel f(x) to its corresponding location x’ = h(x) in g(x’) f(x)f(x)g(x’) xx’ h(x)h(x) What if pixel lands “between” two pixels? Answer: add “contribution” to several pixels, normalize later (splatting)

Richard SzeliskiImage Stitching21 Inverse Warping Get each pixel g(x’) from its corresponding location x’ = h(x) in f(x) f(x)f(x)g(x’) xx’ h -1 (x) What if pixel comes from “between” two pixels?

Richard SzeliskiImage Stitching22 Inverse Warping Get each pixel g(x’) from its corresponding location x’ = h(x) in f(x) What if pixel comes from “between” two pixels? Answer: resample color value from interpolated source image f(x)f(x)g(x’) xx’ h -1 (x)

Interpolation Possible interpolation filters: – nearest neighbor – bilinear – bicubic (interpolating)

Motion models Translation 2 unknowns Affine 6 unknowns Perspective 8 unknowns

Finding the transformation Translation = 2 degrees of freedom Similarity = 4 degrees of freedom Affine = 6 degrees of freedom Homography = 8 degrees of freedom How many corresponding points do we need to solve?

Plane perspective mosaics – 8-parameter generalization of affine motion works for pure rotation or planar surfaces – Limitations: local minima slow convergence difficult to control interactively

Simple case: translations How do we solve for ?

Mean displacement = Simple case: translations Displacement of match i =

Simple case: translations System of linear equations – What are the knowns? Unknowns? – How many unknowns? How many equations (per match)?

Simple case: translations Problem: more equations than unknowns – “Overdetermined” system of equations – We will find the least squares solution

Least squares formulation For each point we define the residuals as

Least squares formulation Goal: minimize sum of squared residuals “Least squares” solution For translations, is equal to mean displacement

Least squares Find t that minimizes To solve, form the normal equations

Solving for translations Using least squares 2n x 22 x 12n x 1

Affine transformations How many unknowns? How many equations per match? How many matches do we need?

Affine transformations Residuals: Cost function:

Affine transformations Matrix form 2n x 6 6 x 1 2n x 1

Solving for homographies

Direct Linear Transforms Defines a least squares problem: Since is only defined up to scale, solve for unit vector Solution: = eigenvector of with smallest eigenvalue Works with 4 or more points 2n × 9 9 2n

Richard SzeliskiImage Stitching41 Matching features What do we do about the “bad” matches?

Richard SzeliskiImage Stitching42 RAndom SAmple Consensus Select one match, count inliers

Richard SzeliskiImage Stitching43 RAndom SAmple Consensus Select one match, count inliers

Richard SzeliskiImage Stitching44 Least squares fit Find “average” translation vector

RANSAC for estimating homography RANSAC loop: 1.Select four feature pairs (at random) 2.Compute homography H (exact) 3.Compute inliers where ||p i ’, H p i || < ε Keep largest set of inliers Re-compute least-squares H estimate using all of the inliers CSE 576, Spring 2008Structure from Motion46

47 Simple example: fit a line Rather than homography H (8 numbers) fit y=ax+b (2 numbers a, b) to 2D pairs 47

48 Simple example: fit a line Pick 2 points Fit line Count inliers 48 3 inliers

49 Simple example: fit a line Pick 2 points Fit line Count inliers 49 4 inliers

50 Simple example: fit a line Pick 2 points Fit line Count inliers 50 9 inliers

51 Simple example: fit a line Pick 2 points Fit line Count inliers 51 8 inliers

52 Simple example: fit a line Use biggest set of inliers Do least-square fit 52

RANSAC Red: rejected by 2nd nearest neighbor criterion Blue: Ransac outliers Yellow: inliers

How many rounds? If we have to choose s samples each time – with an outlier ratio e – and we want the right answer with probability p

Richard SzeliskiImage Stitching55 Rotational mosaics – Directly optimize rotation and focal length – Advantages: ability to build full-view panoramas easier to control interactively more stable and accurate estimates

Richard SzeliskiImage Stitching56 Rotational mosaic Projection equations 1.Project from image to 3D ray (x 0,y 0,z 0 ) = (u 0 -u c,v 0 -v c,f) 2.Rotate the ray by camera motion (x 1,y 1,z 1 ) = R 01 (x 0,y 0,z 0 ) 3.Project back into new (source) image (u 1,v 1 )= (fx 1 /z 1 +u c,fy 1 /z 1 +v c )

Computing homography Assume we have four matched points: How do we compute homography H? Normalized DLT 1.Normalize coordinates for each image a)Translate for zero mean b)Scale so that average distance to origin is ~sqrt(2) –This makes problem better behaved numerically 2.Compute using DLT in normalized coordinates 3.Unnormalize:

Computing homography Assume we have matched points with outliers: How do we compute homography H? Automatic Homography Estimation with RANSAC 1.Choose number of samples N 2.Choose 4 random potential matches 3.Compute H using normalized DLT 4.Project points from x to x’ for each potentially matching pair: 5.Count points with projected distance < t – E.g., t = 3 pixels 6.Repeat steps 2-5 N times – Choose H with most inliers HZ Tutorial ‘99

Automatic Image Stitching 1.Compute interest points on each image 2.Find candidate matches 3.Estimate homography H using matched points and RANSAC with normalized DLT 4.Project each image onto the same surface and blend

RANSAC for Homography Initial Matched Points

RANSAC for Homography Final Matched Points

RANSAC for Homography

Image Blending

Feathering =

Effect of window (ramp-width) size 0 1 left right 0 1

Effect of window size

Good window size 0 1 “Optimal” window: smooth but not ghosted Doesn’t always work...

Pyramid blending Create a Laplacian pyramid, blend each level Burt, P. J. and Adelson, E. H., A multiresolution spline with applications to image mosaics, ACM Transactions on Graphics, 42(4), October 1983, A multiresolution spline with applications to image mosaics

Gaussian Pyramid Laplacian Pyramid The Laplacian Pyramid - = - = - =

Laplacian level 4 Laplacian level 2 Laplacian level 0 left pyramid right pyramid blended pyramid

Laplacian image blend 1.Compute Laplacian pyramid 2.Compute Gaussian pyramid on weight image 3.Blend Laplacians using Gaussian blurred weights 4.Reconstruct the final image

Multiband Blending with Laplacian Pyramid Left pyramidRight pyramidblend At low frequencies, blend slowly At high frequencies, blend quickly

Multiband blending 1.Compute Laplacian pyramid of images and mask 2.Create blended image at each level of pyramid 3.Reconstruct complete image Laplacian pyramids

Blending comparison (IJCV 2007)

Poisson Image Editing For more info: Perez et al, SIGGRAPH 2003 –

Encoding blend weights: I(x,y) = (  R,  G,  B,  ) color at p = Implement this in two steps: 1. accumulate: add up the (  premultiplied) RGB  values at each pixel 2. normalize: divide each pixel’s accumulated RGB by its  value Alpha Blending Optional: see Blinn (CGA, 1994) for details: =7531&prod=JNL&arnumber=310740&arSt=83&ared=87&arAut hor=Blinn%2C+J.Fhttp://ieeexplore.ieee.org/iel1/38/7531/ pdf?isNumber =7531&prod=JNL&arnumber=310740&arSt=83&ared=87&arAut hor=Blinn%2C+J.F. I1I1 I2I2 I3I3 p

Choosing seams Image 1 Image 2 x x im1 im2 Easy method – Assign each pixel to image with nearest center

Choosing seams Easy method – Assign each pixel to image with nearest center – Create a mask: – Smooth boundaries ( “feathering”): – Composite Image 1 Image 2 x x im1 im2

Choosing seams Better method: dynamic program to find seam along well-matched regions Illustration:

Gain compensation Simple gain adjustment – Compute average RGB intensity of each image in overlapping region – Normalize intensities by ratio of averages

Blending Comparison

Recognizing Panoramas Brown and Lowe 2003, 2007 Some of following material from Brown and Lowe 2003 talk

Recognizing Panoramas Input: N images 1.Extract SIFT points, descriptors from all images 2.Find K-nearest neighbors for each point (K=4) 3.For each image a)Select M candidate matching images by counting matched keypoints (m=6) b)Solve homography H ij for each matched image

Recognizing Panoramas Input: N images 1.Extract SIFT points, descriptors from all images 2.Find K-nearest neighbors for each point (K=4) 3.For each image a)Select M candidate matching images by counting matched keypoints (m=6) b)Solve homography H ij for each matched image c)Decide if match is valid (n i > n f ) # inliers # keypoints in overlapping area

Recognizing Panoramas (cont.) (now we have matched pairs of images) 4.Find connected components

Finding the panoramas

Recognizing Panoramas (cont.) (now we have matched pairs of images) 4.Find connected components 5.For each connected component a)Solve for rotation and f b)Project to a surface (plane, cylinder, or sphere) c)Render with multiband blending