Image warping and stitching

Similar documents
Image warping and stitching

Image warping and stitching

Mosaics wrapup & Stereo

N-Views (1) Homographies and Projection

Image Warping and Mosacing

Local features and image matching May 8 th, 2018

Homographies and RANSAC

Mosaics. Today s Readings

Epipolar Geometry and Stereo Vision

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

Homographies and Mosaics

CS6670: Computer Vision

Announcements. Mosaics. How to do it? Image Mosaics

CS4670: Computer Vision

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

Affine and Projective Transformations

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

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

Warping. 12 May 2015

Image warping , , Computational Photography Fall 2017, Lecture 10

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

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

Introduction to Computer Vision

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

Prof. Kristen Grauman

Feature Matching and RANSAC

Automatic Image Alignment (feature-based)

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

CS4670: Computer Vision

CSE 527: Introduction to Computer Vision

EE795: Computer Vision and Intelligent Systems

Agenda. Rotations. Camera models. Camera calibration. Homographies

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

Automatic Image Alignment

Instance-level recognition part 2

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

Agenda. Rotations. Camera calibration. Homography. Ransac

Midterm Examination CS 534: Computational Photography

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

Single-view 3D Reconstruction

EE795: Computer Vision and Intelligent Systems

Camera Geometry II. COS 429 Princeton University

Camera Calibration. COS 429 Princeton University

Computer Vision Lecture 17

Introduction to Computer Vision

Automatic Image Alignment

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

Computer Vision Lecture 17

Instance-level recognition

Epipolar Geometry and Stereo Vision

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

Epipolar Geometry and Stereo Vision

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

Instance-level recognition

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

Local features and image matching. Prof. Xin Yang HUST

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

METRIC PLANE RECTIFICATION USING SYMMETRIC VANISHING POINTS

Warping, Morphing and Mosaics

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

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

Image stitching. Announcements. Outline. Image stitching

CS4670: Computer Vision

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

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

Homography estimation

Multiple View Geometry

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

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

Lecture 16: Computer Vision

Fitting. Lecture 8. Cristian Sminchisescu. Slide credits: K. Grauman, S. Seitz, S. Lazebnik, D. Forsyth, J. Ponce

Lecture 16: Computer Vision

Local features: detection and description May 12 th, 2015

Single-view metrology

Instance-level recognition II.

Local features: detection and description. Local invariant features

Image Transfer Methods. Satya Prakash Mallick Jan 28 th, 2003

calibrated coordinates Linear transformation pixel coordinates

Image Warping and Morphing. Alexey Tikhonov

Fitting. Fitting. Slides S. Lazebnik Harris Corners Pkwy, Charlotte, NC

Lecture 20: Tracking. Tuesday, Nov 27

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

CS 4495 Computer Vision A. Bobick. Motion and Optic Flow. Stereo Matching

Projective Geometry and Camera Models

Step-by-Step Model Buidling

Structure from motion

Computer Vision CS 776 Fall 2018

Camera Calibration. Schedule. Jesus J Caban. Note: You have until next Monday to let me know. ! Today:! Camera calibration

BIL Computer Vision Apr 16, 2014

DD2423 Image Analysis and Computer Vision IMAGE FORMATION. Computational Vision and Active Perception School of Computer Science and Communication

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

RANSAC and some HOUGH transform

Stereo and Epipolar geometry

EECS 442 Computer vision. Fitting methods

Stitching and Blending

Structure from Motion. Prof. Marco Marcon

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

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

Computer Vision I. Announcements. Random Dot Stereograms. Stereo III. CSE252A Lecture 16

1 Projective Geometry

Transcription:

Image warping and stitching Thurs Oct 15 Last time Feature-based alignment 2D transformations Affine fit RANSAC 1

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 matches consistent with T) Source: L. Lazebnik RANSAC: General form RANSAC loop: 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 2

RANSAC example: Translation Putative matches Source: Rick Szeliski RANSAC example: Translation Select one match, count inliers 3

RANSAC example: Translation Select one match, count inliers RANSAC example: Translation Find average translation vector 4

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 Lana Lazebnik Another example Automatic scanned document rotater using Hough lines and RANSAC 5

Gen Hough vs RANSAC GHT Single correspondence -> vote for all consistent parameters Represents uncertainty in the model parameter space Linear complexity in number of correspondences and number of voting cells; beyond 4D vote space impractical Can handle high outlier ratio RANSAC Minimal subset of correspondences to estimate model -> count inliers Represents uncertainty in image space Must search all data points to check for inliers each iteration Scales better to high-d parameter spaces Kristen Grauman Today Image mosaics Fitting a 2D transformation Affine, Homography 2D image warping Computing an image mosaic 6

Mosaics... image from S. Seitz Obtain a wider angle view by combining multiple images. Main questions T Alignment: Given two images, what is the transformation between them? T Warping: Given a source image and a transformation, what does the transformed output look like? 7

8 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 ' ' ' 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 ' ' '

2D transformation models Similarity (translation, scale, rotation) Affine Projective (homography) 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? Source: Stev e Seitz 9

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. Fig f rom Forsy th and Ponce Mosaics... image from S. Seitz Obtain a wider angle view by combining multiple images. 10

Mosaics: generating synthetic views real camera synthetic camera Can generate any synthetic camera view as long as it has the same center of projection! Source: Alyosha Efros 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 Source: Steve Seitz 11

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 Observation: Rather than thinking of this as a 3D reprojection, think of it as a 2D image warp from one image to another. PP1 PP2 Source: Aly osha Ef ros 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 but must preserve straight lines called Homography PP2 wx' wy' w p * * * * * * H * x * y * 1 p PP1 Source: Alyosha Efros 12

Homography x, y 1 1 x, y 1 1 x, y 2 2 x 2, y 2 x, x, n y n 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 Solving for homographies Can set scale factor i=1. So, there are 8 unknowns. Set up a system of linear equations: Ah = b where vector of unknowns h = [a,b,c,d,e,f,g,h] T Need at least 8 eqs, but the more the better Solve for h. If overconstrained, solve using least-squares: >> help lmdivide p = Hp wx' a b c x wy' d e f y w g h i 1 min Ah b 2 BOARD 13

x, y Homography 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 p RANSAC for estimating homography RANSAC loop: 1. Select four feature pairs (at random) 2. Compute homography H 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 Slide credit: Steve Seitz 14

Today Image mosaics Fitting a 2D transformation Affine, Homography 2D image warping Computing an image mosaic Image warping T(x,y) y y x x f(x,y) 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 15

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 Forward warping T(x,y) y y x x f(x,y) 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 ) Known as splatting Slide from Alyosha Efros, CMU 16

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? Slide from Alyosha Efros, CMU Inverse warping y T -1 (x,y) y x x f(x,y) 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 17

Bilinear interpolation Sampling at f(x,y): Slide from Alyosha Efros, CMU 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) Source: Stev e Seitz 18

Image warping with homographies image plane in front black area w here no pixel maps to image plane below Source: Steve Seitz Image rectification p p 19

Automatic rectification 10/14/2015 Analysing patterns and shapes What is the shape of the b/w floor pattern? The floor (enlarged) Slide from Antonio Criminisi Automatically rectified floor Analysing patterns and shapes From Martin Kemp The Science of Art (manual reconstruction) Slide from Antonio Criminisi 20

Analysing patterns and shapes What is the (complicated) shape of the floor pattern? St. Lucy Altarpiece, D. Veneziano Slide from Criminisi Automatically rectified floor Analysing patterns and shapes Automatic rectification From Martin Kemp, The Science of Art (manual reconstruction) Slide from Criminisi 21

Andrew Harp Andy Luong Sung Ju Hwang Ekapol Chuangsuwanich, CMU 22

23

HP frames commercials http://www.youtube.com/watch?v=2rpl5vpeo Qk Changing camera center Does it still work? synthetic PP PP1 PP2 Source: Aly osha Ef ros 24

Recall: same camera center real camera synthetic camera Can generate synthetic camera view as long as it has the same center of projection. Source: Alyosha Efros Or: Planar scene (or far away) PP3 PP1 PP2 PP3 is a projection plane of both centers of projection, so we are OK! This is how big aerial photographs are made Source: Alyosha Efros 25

Boundary extension Wide-Angle Memories of Close- Up Scenes, Helene Intraub and Michael Richardson, Journal of Experimental Psychology: Learning, Memory, and Cognition, 1989, Vol. 15, No. 2, 179-187 26

Creating and Exploring a Large Photorealistic Virtual Space Josef Sivic, Biliana Kaneva, Antonio Torralba, Shai Avidan and William T. Freeman, Internet Vision Workshop, CVPR 2008. http://www.youtube.com/watch?v=e0rbou10rpo Creating and Exploring a Large Photorealistic Virtual Space Current view, and desired view in green Synthesized view from new camera Induced camera motion 27

Summary: alignment & warping Write 2d transformations as matrix-vector multiplication (including translation when we use homogeneous coordinates) Perform image warping (forward, inverse) Fitting transformations: solve for unknown parameters given corresponding points from two views (affine, projective (homography)). Mosaics: uses homography and image warping to merge views taken from same center of projection. Panoramas: main steps 1. Collect correspondences (manually for now) 2. Solve for homography matrix H Least squares solution 3. Warp content from one image frame to the other to combine: say im1 into im2 reference frame Determine bounds of the new combined image Where will the corners of im1 fall in im2 s coordinate frame? We will attempt to lookup colors for any of these positions we can get from im1. Compute coordinates in im1 s reference frame (via homography) for all points in that range Lookup all colors for all these positions from im1 Inverse warp : interp2 (watch for nans) 4. Overlay im2 content onto the warped im1 content. Careful about new bounds of the output image: minx, miny 28

Panoramas: main steps 1. Collect correspondences (manually for now) 2. Solve for homography matrix H Least squares solution 3. Warp content from one image frame to the other to combine: say im1 into im2 reference frame Determine bounds of the new combined image: Where will the corners of im1 fall in im2 s coordinate frame? We will attempt to lookup colors for any of these positions we can get from im1. Compute coordinates in im1 s reference frame (via homography) for all points in that range: H -1 Lookup all colors for all these positions from im1 Inverse warp : interp2 (watch for nans : isnan) 4. Overlay im2 content onto the warped im1 content. Careful about new bounds of the output image: minx, miny H im1 im2 (Assuming we have solved for the H that maps points from im1 to im2.) wx2 x1 wy2 H y1 w 1 29

im1 im2 Panoramas: main steps 1. Collect correspondences (manually for now) 2. Solve for homography matrix H Least squares solution 3. Warp content from one image frame to the other to combine: say im1 into im2 reference frame Determine bounds of the new combined image: Where will the corners of im1 fall in im2 s coordinate frame? We will attempt to lookup colors for any of these positions we can get from im1. Inverse warp: Compute coordinates in im1 s reference frame (via homography) for all points in that range. Lookup all colors for all these positions from im1 (interp2) 4. Overlay im2 content onto the warped im1 content. 30

H -1 im1 im2 (Assuming we have solved for the H that maps points from im1 to im2.) im1 im2 im1 warped into reference frame of im2. Use interp2 to ask for the colors (possibly interpolated) from im1 at all the positions needed in im2 s reference frame. 31

Panoramas: main steps 1. Collect correspondences (manually for now) 2. Solve for homography matrix H Least squares solution 3. Warp content from one image frame to the other to combine: say im1 into im2 reference frame Determine bounds of the new combined image: Where will the corners of im1 fall in im2 s coordinate frame? We will attempt to lookup colors for any of these positions we can get from im1. Inverse warp: Compute coordinates in im1 s reference frame (via homography) for all points in that range. Lookup all colors for all these positions from im1 (interp2) 4. Overlay im2 content onto the warped im1 content. Careful about new bounds of the output image 32

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