Image warping and stitching

Similar documents
Image warping and stitching

Image warping and stitching

N-Views (1) Homographies and Projection

Local features and image matching May 8 th, 2018

Image Warping and Mosacing

CS6670: Computer Vision

Homographies and RANSAC

Image Stitching. Slides from Rick Szeliski, Steve Seitz, Derek Hoiem, Ira Kemelmacher, Ali Farhadi

Mosaics. Today s Readings

CS4670: Computer Vision

Homographies and Mosaics

Announcements. Mosaics. Image Mosaics. How to do it? Basic Procedure Take a sequence of images from the same position =

Announcements. Mosaics. How to do it? Image Mosaics

Affine and Projective Transformations

Epipolar Geometry and Stereo Vision

Warping. 12 May 2015

Fitting a transformation: Feature-based alignment April 30 th, Yong Jae Lee UC Davis

Image stitching. Digital Visual Effects Yung-Yu Chuang. with slides by Richard Szeliski, Steve Seitz, Matthew Brown and Vaclav Hlavac

CS 2770: Intro to Computer Vision. Multiple Views. Prof. Adriana Kovashka University of Pittsburgh March 14, 2017

Image warping , , Computational Photography Fall 2017, Lecture 10

Mosaics wrapup & Stereo

Feature Matching and RANSAC

More Mosaic Madness. CS194: Image Manipulation & Computational Photography. Steve Seitz and Rick Szeliski. Jeffrey Martin (jeffrey-martin.

CSE 527: Introduction to Computer Vision

Panoramas. Why Mosaic? Why Mosaic? Mosaics: stitching images together. Why Mosaic? Olivier Gondry. Bill Freeman Frédo Durand MIT - EECS

6.098 Digital and Computational Photography Advanced Computational Photography. Panoramas. Bill Freeman Frédo Durand MIT - EECS

CS4670: Computer Vision

Agenda. Rotations. Camera models. Camera calibration. Homographies

Agenda. Rotations. Camera calibration. Homography. Ransac

Automatic Image Alignment (feature-based)

Single-view 3D Reconstruction

Midterm Examination CS 534: Computational Photography

Automatic Image Alignment

calibrated coordinates Linear transformation pixel coordinates

Scene Modeling for a Single View

Scene Modeling for a Single View

Single-view metrology

CS4670: Computer Vision

Camera Geometry II. COS 429 Princeton University

Prof. Kristen Grauman

Local features: detection and description May 12 th, 2015

Computer Vision Lecture 17

Warping, Morphing and Mosaics

Automatic Image Alignment (direct) with a lot of slides stolen from Steve Seitz and Rick Szeliski

EE795: Computer Vision and Intelligent Systems

Automatic Image Alignment

Camera Calibration. COS 429 Princeton University

Computer Vision Lecture 17

Today s lecture. Image Alignment and Stitching. Readings. Motion models

Introduction to Computer Vision. Week 3, Fall 2010 Instructor: Prof. Ko Nishino

1 Projective Geometry

Broad field that includes low-level operations as well as complex high-level algorithms

Projective Geometry and Camera Models

Instance-level recognition I. - Camera geometry and image alignment

Image Warping and Morphing. Alexey Tikhonov : Computational Photography Alexei Efros, CMU, Fall 2007

Lecture 16: Computer Vision

Image stitching. Announcements. Outline. Image stitching

Image stitching. Digital Visual Effects Yung-Yu Chuang. with slides by Richard Szeliski, Steve Seitz, Matthew Brown and Vaclav Hlavac

Image Warping and Morphing. Alexey Tikhonov

More Single View Geometry

EE795: Computer Vision and Intelligent Systems

Local features and image matching. Prof. Xin Yang HUST

Image Rectification (Stereo) (New book: 7.2.1, old book: 11.1)

Epipolar Geometry and Stereo Vision

Miniature faking. In close-up photo, the depth of field is limited.

Computer Vision I Name : CSE 252A, Fall 2012 Student ID : David Kriegman Assignment #1. (Due date: 10/23/2012) x P. = z

Geometric camera models and calibration

Image Features: Local Descriptors. Sanja Fidler CSC420: Intro to Image Understanding 1/ 58

Lecture 16: Computer Vision

Pinhole Camera Model 10/05/17. Computational Photography Derek Hoiem, University of Illinois

CS5670: Computer Vision

Projective Geometry and Camera Models

Epipolar Geometry Prof. D. Stricker. With slides from A. Zisserman, S. Lazebnik, Seitz

Structure from Motion

There are many cues in monocular vision which suggests that vision in stereo starts very early from two similar 2D images. Lets see a few...

Stereo and Epipolar geometry

Scene Modeling for a Single View

Instance-level recognition

Stitching and Blending

Image formation. Thanks to Peter Corke and Chuck Dyer for the use of some slides

More Single View Geometry

CS664 Lecture #16: Image registration, robust statistics, motion

Image Warping and Morphing. Alexey Tikhonov

Image Warping. Many slides from Alyosha Efros + Steve Seitz. Photo by Sean Carroll

Structure from motion

METRIC PLANE RECTIFICATION USING SYMMETRIC VANISHING POINTS

Multiple View Geometry

Epipolar Geometry and Stereo Vision

COSC579: Scene Geometry. Jeremy Bolton, PhD Assistant Teaching Professor

Instance-level recognition

COMP 558 lecture 19 Nov. 17, 2010

2D Transforms. Lecture 4 CISC440/640 Spring Department of Computer and Information Science

Recap: Features and filters. Recap: Grouping & fitting. Now: Multiple views 10/29/2008. Epipolar geometry & stereo vision. Why multiple views?

Local features: detection and description. Local invariant features

Index. 3D reconstruction, point algorithm, point algorithm, point algorithm, point algorithm, 253

Two-view geometry Computer Vision Spring 2018, Lecture 10

Instance-level recognition part 2

BIL Computer Vision Apr 16, 2014

CS 1674: Intro to Computer Vision. Midterm Review. Prof. Adriana Kovashka University of Pittsburgh October 10, 2016

Structure from Motion. Prof. Marco Marcon

Transcription:

Image warping and stitching May 4 th, 2017 Yong Jae Lee UC Davis

Last time Interactive segmentation Feature-based alignment 2D transformations Affine fit RANSAC 2

Alignment problem In alignment, we will fit the parameters of some transformation according to a set of matching feature pairs ( correspondences ). x i x i ' T Slide credit: Adapted by Devi Parikh from Kristen Grauman 3

Main questions T Alignment: Given two images, what is the transformation between them? Slide credit: Kristen Grauman T Warping: Given a source image and a transformation, what does the transformed output look like? 4

Motivation for feature-based alignment: Recognition Slide credit: Kristen Grauman 5 Figures from David Lowe

Motivation for feature-based alignment: Medical image registration Slide credit: Kristen Grauman 6

Motivation for feature-based alignment: Image mosaics Slide credit: Kristen Grauman Image from http://graphics.cs.cmu.edu/courses/15-463/2010_fall/ 7

Parametric (global) warping Examples of parametric warps: translation rotation aspect affine perspective 8 Source: Alyosha Efros

Parametric (global) warping T p = (x,y) p = (x,y ) Transformation T is a coordinate-changing machine: p = T(p) What does it mean that T is global? Is the same for any point p can be described by just a few numbers (parameters) Let s represent T as a matrix: p = Mp x y ' ' = M x y 9 Source: Alyosha Efros

Homogeneous coordinates To convert to homogeneous coordinates: homogeneous image coordinates Converting from homogeneous coordinates Slide credit: Kristen Grauman 10

2D Affine Transformations Affine transformations are combinations of Linear transformations, and Translations Parallel lines remain parallel = w y x f e d c b a w y x 1 0 0 ' ' ' Slide credit: Kristen Grauman 11

Projective Transformations Projective transformations: Affine transformations, and Projective warps Parallel lines do not necessarily remain parallel = w y x i h g f e d c b a w y x ' ' ' Slide credit: Kristen Grauman 12

Fitting an affine transformation Assuming we know the correspondences, how do we get the transformation? ), ( i i y x ), ( i x i y + = 2 1 4 3 2 1 t t y x m m m m y x i i i i = i i i i i i y x t t m m m m y x y x 2 1 4 3 2 1 1 0 0 0 0 1 0 0 Slide credit: Kristen Grauman 13

RANSAC loop: RANSAC: General form 1. Randomly select a seed group of points on which to base transformation estimate (e.g., a group of matches) 2. Compute transformation from seed group 3. Find inliers to this transformation 4. If the number of inliers is sufficiently large, re-compute estimate of transformation on all of the inliers Keep the transformation with the largest number of inliers Slide credit: Kristen Grauman 14

RANSAC example: Translation Putative matches 15 Source: Rick Szeliski

RANSAC example: Translation Select one match, count inliers 16

RANSAC example: Translation Select one match, count inliers 17

RANSAC example: Translation Find average translation vector 18

RANSAC pros and cons Pros Simple and general Applicable to many different problems Often works well in practice Cons Lots of parameters to tune Doesn t work well for low inlier ratios (too many iterations, or can fail completely) Can t always get a good initialization of the model based on the minimum number of samples 19 Lana Lazebnik

Today Image mosaics Fitting a 2D transformation Homography 2D image warping Computing an image mosaic 20

HP frames commercial http://www.youtube.com/watch?v=2rpl5vpeo Qk 21

Mosaics... image from S. Seitz Obtain a wider angle view by combining multiple images. Slide credit: Kristen Grauman 22

Panoramic Photos are old Sydney, 1875 Beirut, late 1800 s Slide credit: James Hays

How to stitch together a panorama (a.k.a. mosaic)? Basic Procedure Take a sequence of images from the same position Rotate the camera about its optical center Compute transformation between second image and first Transform the second image to overlap with the first Blend the two together to create a mosaic (If there are more images, repeat) but wait, why should this work at all? What about the 3D geometry of the scene? Why aren t we using it? 24 Source: Steve Seitz

Pinhole camera Pinhole camera is a simple model to approximate imaging process, perspective projection. Image plane Virtual image pinhole If we treat pinhole as a point, only one ray from any given point can enter the camera. Slide credit: Kristen Grauman Fig from Forsyth and Ponce 25

Mosaics: generating synthetic views real camera synthetic camera Can generate any synthetic camera view as long as it has the same center of projection! 26 Source: Alyosha Efros

Mosaics... image from S. Seitz Obtain a wider angle view by combining multiple images. Slide credit: Kristen Grauman 27

Image reprojection mosaic PP The mosaic has a natural interpretation in 3D The images are reprojected onto a common plane The mosaic is formed on this plane Mosaic is a synthetic wide-angle camera 28 Source: Steve Seitz

Image reprojection Basic question How to relate two images from the same camera center? how to map a pixel from PP1 to PP2 Answer Cast a ray through each pixel in PP1 Draw the pixel where that ray intersects PP2 PP2 Observation: Rather than thinking of this as a 3D reprojection, think of it as a 2D image warp from one image to another. PP1 29 Source: Alyosha Efros

Image reprojection: Homography A projective transform is a mapping between any two PPs with the same center of projection rectangle should map to arbitrary quadrilateral parallel lines aren t preserved but must preserve straight lines called Homography PP2 wx' wy' w p = * * * * * * H * x * y * 1 p PP1 30 Source: Alyosha Efros

The projective plane Why do we need homogeneous coordinates? represent points at infinity, homographies, perspective projection, multi-view relationships What is the geometric intuition? a point in the image is a ray in projective space -y (0,0,0) -z x (x,y,1) (sx,sy,s) image plane Each point (x,y) on the plane is represented by a ray (sx,sy,s) all points on the ray are equivalent: (x, y, 1) (sx, sy, s)

Homography ( ) x 1, y 1 ( ) x 2, y 2 ( x ) 1, y 1 ( x ) 2, y 2 ( x, y ) n n ( x, ) n y n To compute the homography given pairs of corresponding points in the images, we need to set up an equation where the parameters of H are the unknowns Slide credit: Kristen Grauman 32

Solving for homographies wx' h = wy' h w h p = Hp Upto a scale factor. Constraint Frobenius norm of H to be 1. 00 10 20 h h h 01 11 21 h h h 02 12 22 x y 1 Problem to be solved: min Ah b 2 s.t. h = 1 where vector of unknowns h = [h 00,h 01,h 02,h 10,h 11,h 12,h 20,h 21,h 22 ] T 2 33

Solving for homographies = 1 22 21 20 12 11 10 02 01 00 i i i i y x h h h h h h h h h w wy ' wx '

Solving for homographies A h 0 2n 9 9 2n Defines a least squares problem: Since h is only defined up to scale, solve for unit vector ĥ ( i. e., h 2 = 1) Solution: ĥ = eigenvector of A T A with smallest eigenvalue Works with 4 or more points

Homography ( x, y) wx wy w, w ( x y ) =, To apply a given homography H Compute p = Hp (regular matrix multiply) Convert p from homogeneous to image coordinates wx' wy' w p = * * * * * * H * x * y * 1 Slide credit: Kristen Grauman 36 p

Today RANSAC for robust fitting Lines, translation Image mosaics Fitting a 2D transformation Homography 2D image warping Computing an image mosaic 37

Image warping T(x,y) y y x f(x,y) x g(x,y ) Given a coordinate transform and a source image f(x,y), how do we compute a transformed image g(x,y ) = f(t(x,y))? Slide from Alyosha Efros, CMU 38

Forward warping T(x,y) y y x f(x,y) x g(x,y ) Send each pixel f(x,y) to its corresponding location (x,y ) = T(x,y) in the second image Q: what if pixel lands between two pixels? Slide from Alyosha Efros, CMU 39

Forward warping T(x,y) y y x f(x,y) x g(x,y ) Send each pixel f(x,y) to its corresponding location (x,y ) = T(x,y) in the second image Q: what if pixel lands between two pixels? A: distribute color among neighboring pixels (x,y ) Slide from Alyosha Efros, CMU Known as splatting 40

Inverse warping y T -1 (x,y) y x f(x,y) x g(x,y ) Get each pixel g(x,y ) from its corresponding location (x,y) = T -1 (x,y ) in the first image Q: what if pixel comes from between two pixels? 41 Slide from Alyosha Efros, CMU

Inverse warping y T -1 (x,y) y x f(x,y) x g(x,y ) Get each pixel g(x,y ) from its corresponding location (x,y) = T -1 (x,y ) in the first image Q: what if pixel comes from between two pixels? A: Interpolate color value from neighbors Slide from Alyosha Efros, CMU nearest neighbor, bilinear >> help interp2 42

Bilinear interpolation Sampling at f(x,y): Slide from Alyosha Efros, CMU 43

Recap: How to stitch together a panorama (a.k.a. mosaic)? Basic Procedure Take a sequence of images from the same position Rotate the camera about its optical center Compute transformation (homography) between second image and first using corresponding points. Transform the second image to overlap with the first. Blend the two together to create a mosaic. (If there are more images, repeat) 44 Source: Steve Seitz

Source: Steve Seitz Image warping with homographies image plane in front black area where no pixel maps to image plane below 45

Image rectification p p Slide credit: Kristen Grauman 46

Analysing patterns and shapes What is the shape of the b/w floor pattern? The floor (enlarged) Automatically rectified floor Slide from Antonio Criminisi 47

Analysing patterns and shapes Automatic rectification From Martin Kemp The Science of Art (manual reconstruction) Slide from Antonio Criminisi 48

Analysing patterns and shapes What is the (complicated) shape of the floor pattern? Automatically rectified floor St. Lucy Altarpiece, D. Veneziano Slide from Criminisi 49

Analysing patterns and shapes Automatic rectification From Martin Kemp, The Science of Art (manual reconstruction) Slide from Criminisi 50

Julian Beever: Manual Homographies http://users.skynet.be/j.beever/pave.htm

Changing camera center Does it still work? synthetic PP PP1 PP2 52 Source: Alyosha Efros

Recall: same camera center real camera synthetic camera Can generate synthetic camera view as long as it has the same center of projection. 53 Source: Alyosha Efros

Or: Planar scene (or far away) PP1 PP3 PP2 PP3 is a projection plane of both centers of projection, so we are OK! This is how big aerial photographs are made 54 Source: Alyosha Efros

55

RANSAC for estimating homography RANSAC loop: 1. Select four feature pairs (at random) 2. Compute homography H (exact) 3. Compute inliers where SSD(p i, Hp i )< ε 4. Keep largest set of inliers 5. Re-compute least-squares H estimate on all of the inliers 56 Slide credit: Steve Seitz

Robust feature-based alignment 57 Source: L. Lazebnik

Robust feature-based alignment Extract features 58 Source: L. Lazebnik

Robust feature-based alignment Extract features Compute putative matches 59 Source: L. Lazebnik

Robust feature-based alignment Extract features Compute putative matches Loop: Hypothesize transformation T (small group of putative matches that are related by T) 60 Source: L. Lazebnik

Robust feature-based alignment Extract features Compute putative matches Loop: Hypothesize transformation T (small group of putative matches that are related by T) Verify transformation (search for other 61 matches consistent with T) Source: L. Lazebnik

Robust feature-based alignment Extract features Compute putative matches Loop: Hypothesize transformation T (small group of putative matches that are related by T) Verify transformation (search for other 62 matches consistent with T) Source: L. Lazebnik

Summary: alignment & warping Write 2d transformations as matrix-vector multiplication (including translation when we use homogeneous coordinates) Fitting transformations: solve for unknown parameters given corresponding points from two views (affine, projective (homography)). Perform image warping (forward, inverse) Mosaics: uses homography and image warping to merge views taken from same center of projection. Slide credit: Kristen Grauman 63

Next time: which features should we match? Slide credit: Kristen Grauman 64

Questions? 65