CPSC 641: Image Registration

Slides:



Advertisements
Similar presentations
CSCE 643 Computer Vision: Lucas-Kanade Registration
Advertisements

Optical Flow Estimation
Motion.
Computer Vision Optical Flow
Automatic Image Alignment (direct) : Computational Photography Alexei Efros, CMU, Fall 2006 with a lot of slides stolen from Steve Seitz and Rick.
Motion Estimation I What affects the induced image motion? Camera motion Object motion Scene structure.
Motion Analysis (contd.) Slides are from RPI Registration Class.
Announcements Quiz Thursday Quiz Review Tomorrow: AV Williams 4424, 4pm. Practice Quiz handout.
CSCE 641 Computer Graphics: Image Registration Jinxiang Chai.
Announcements Project1 artifact reminder counts towards your grade Demos this Thursday, 12-2:30 sign up! Extra office hours this week David (T 12-1, W/F.
Feature matching and tracking Class 5 Read Section 4.1 of course notes Read Shi and Tomasi’s paper on.
Announcements Project 1 test the turn-in procedure this week (make sure your folder’s there) grading session next Thursday 2:30-5pm –10 minute slot to.
Optical flow and Tracking CISC 649/849 Spring 2009 University of Delaware.
Motion Computing in Image Analysis
Optical Flow Estimation
Lecture 19: Optical flow CS6670: Computer Vision Noah Snavely
Visual motion Many slides adapted from S. Seitz, R. Szeliski, M. Pollefeys.
Motion Estimation Today’s Readings Trucco & Verri, 8.3 – 8.4 (skip 8.3.3, read only top half of p. 199) Numerical Recipes (Newton-Raphson), 9.4 (first.
1 Stanford CS223B Computer Vision, Winter 2006 Lecture 7 Optical Flow Professor Sebastian Thrun CAs: Dan Maynes-Aminzade, Mitul Saha, Greg Corrado Slides.
Matching Compare region of image to region of image. –We talked about this for stereo. –Important for motion. Epipolar constraint unknown. But motion small.
Automatic Image Alignment via Motion Estimation
Automatic Image Alignment (feature-based) : Computational Photography Alexei Efros, CMU, Fall 2006 with a lot of slides stolen from Steve Seitz and.
KLT tracker & triangulation Class 6 Read Shi and Tomasi’s paper on good features to track
Computational Photography: Image Registration Jinxiang Chai.
Announcements Project1 due Tuesday. Motion Estimation Today’s Readings Trucco & Verri, 8.3 – 8.4 (skip 8.3.3, read only top half of p. 199) Supplemental:
CSCE 641 Computer Graphics: Image Registration Jinxiang Chai.
Optical flow Combination of slides from Rick Szeliski, Steve Seitz, Alyosha Efros and Bill Freeman.
Image Stitching Ali Farhadi CSE 455
Generating panorama using translational movement model.
1 Motion Estimation Readings: Ch 9: plus papers change detection optical flow analysis Lucas-Kanade method with pyramid structure Ming Ye’s improved.
Optical Flow Donald Tanguay June 12, Outline Description of optical flow General techniques Specific methods –Horn and Schunck (regularization)
Motion estimation Digital Visual Effects Yung-Yu Chuang with slides by Michael Black and P. Anandan.
CSCE 643 Computer Vision: Structure from Motion
Motion Segmentation By Hadas Shahar (and John Y.A.Wang, and Edward H. Adelson, and Wikipedia and YouTube) 1.
CSE 185 Introduction to Computer Vision Feature Tracking and Optical Flow.
Visual motion Many slides adapted from S. Seitz, R. Szeliski, M. Pollefeys.
Computer Vision Spring ,-685 Instructor: S. Narasimhan Wean 5403 T-R 3:00pm – 4:20pm Lecture #16.
3D Imaging Motion.
Miguel Tavares Coimbra
Motion Estimation Today’s Readings Trucco & Verri, 8.3 – 8.4 (skip 8.3.3, read only top half of p. 199) Newton's method Wikpedia page
Motion Estimation I What affects the induced image motion?
1 Lucas-Kanade Motion Estimation Thanks to Steve Seitz, Simon Baker, Takeo Kanade, and anyone else who helped develop these slides.
Motion Estimation Today’s Readings Trucco & Verri, 8.3 – 8.4 (skip 8.3.3, read only top half of p. 199) Newton's method Wikpedia page
Motion estimation Digital Visual Effects, Spring 2006 Yung-Yu Chuang 2005/4/12 with slides by Michael Black and P. Anandan.
Optical flow and keypoint tracking Many slides adapted from S. Seitz, R. Szeliski, M. Pollefeys.
1 Motion Estimation Readings: Ch 9: plus papers change detection optical flow analysis Lucas-Kanade method with pyramid structure Ming Ye’s improved.
MASKS © 2004 Invitation to 3D vision Lecture 3 Image Primitives andCorrespondence.
Image Motion. The Information from Image Motion 3D motion between observer and scene + structure of the scene –Wallach O’Connell (1953): Kinetic depth.
Motion estimation Parametric motion (image alignment) Tracking Optical flow.
Motion estimation Digital Visual Effects, Spring 2005 Yung-Yu Chuang 2005/3/23 with slides by Michael Black and P. Anandan.
Invariant Local Features Image content is transformed into local feature coordinates that are invariant to translation, rotation, scale, and other imaging.
Feature Tracking and Optical Flow
Motion and Optical Flow
Lecture 7: Image alignment
Digital Visual Effects Yung-Yu Chuang
A special case of calibration
Image Stitching Slides from Rick Szeliski, Steve Seitz, Derek Hoiem, Ira Kemelmacher, Ali Farhadi.
Features Readings All is Vanity, by C. Allan Gilbert,
Motion Estimation Today’s Readings
Announcements more panorama slots available now
Motion Estimation Thanks to Steve Seitz, Simon Baker, Takeo Kanade, and anyone else who helped develop these slides.
Announcements Questions on the project? New turn-in info online
Coupled Horn-Schunck and Lukas-Kanade for image processing
Announcements more panorama slots available now
Optical flow Computer Vision Spring 2019, Lecture 21
Optical flow and keypoint tracking
Calibration and homographies
Back to equations of geometric transformations
Image Stitching Linda Shapiro ECE/CSE 576.
Image Stitching Linda Shapiro ECE P 596.
Presentation transcript:

CPSC 641: Image Registration Jinxiang Chai

Review Image warping Image morphing

Image Warping Warping function - similarity, affine, projective etc - forward warping and two-pass 1D warping - backward warping Resampling filter - point sampling - bilinear filter - anisotropic filter x u Inverse y v forward S(x,y) T(u,v)

Image Morphing Point based image morphing Vector based image morphing

Image Registration Image warping: given h and f, compute g g(x) = f(h(x)) g? f h Image registration: given h and g, compute f g f h?

Why Image Registration? Lots of uses Correct for camera jitter (stabilization) Align images (mosaics) View morphing Image based modeling/rendering Special effects Etc.

Image Registration How do we align two images automatically? Two broad approaches: Feature-based alignment Find a few matching features in both images compute alignment Direct (pixel-based) alignment Search for alignment where most pixels agree

Outline Image registration - feature-based approach - pixel-based approach

Readings Bergen et al. Hierarchical model-based motion estimation. ECCV’92, pp. 237–252. Shi, J. and Tomasi, C. (1994). Good features to track. In CVPR’94, pp. 593–600. Baker, S. and Matthews, I. (2004). Lucas-kanade 20 years on: A unifying framework. IJCV, 56(3), 221–255.

Outline Image registration - feature-based approach - pixel-based approach

Feature-based Alignment Find a few important features (aka Interest Points) Match them across two images Compute image transformation

Feature-based Alignment Find a few important features (aka Interest Points) Match them across two images Compute image transformation How to choose features Choose only the points (“features”) that are salient, i.e. likely to be there in the other image

Feature-based Alignment Find a few important features (aka Interest Points) Match them across two images Compute image transformation How to choose features Choose only the points (“features”) that are salient, i.e. likely to be there in the other image How to find these features? windows where has two large eigenvalues Harris Corner detector

Feature Detection Two images taken at the same place with different angles Projective transformation H3X3

Feature Matching ? Two images taken at the same place with different angles Projective transformation H3X3

Feature Matching Intensity/Color similarity Distance constraint The intensity of pixels around the corresponding features should have similar intensity SSD, Cross-correlation Distance constraint The displacement of features should be smaller than a user-defined threshold

Feature-space Outlier Rejection Can we now compute H3X3 from the blue points? No! Still too many outliers… What can we do?

Robust Estimation What if set of matches contains gross outliers?

RANSAC Objective Robust fit of model to data set S which contains outliers Algorithm Randomly select a sample of s data points from S and instantiate the model from this subset. Determine the set of data points Si which are within a distance threshold t of the model. The set Si is the consensus set of samples and defines the inliers of S. If the subset of Si is greater than some threshold T, re-estimate the model using all the points in Si and terminate If the size of Si is less than T, select a new subset and repeat the above. After N trials the largest consensus set Si is selected, and the model is re-estimated using all the points in the subset Si

RANSAC Repeat M times: Sample minimal number of matches to estimate two view relation (affine, perspective, etc). Calculate number of inliers or posterior likelihood for relation. Choose relation to maximize number of inliers.

RANSAC Line Fitting Example Task: Estimate best line

RANSAC Line Fitting Example Sample two points

RANSAC Line Fitting Example Fit Line

RANSAC Line Fitting Example Total number of points within a threshold of line.

RANSAC Line Fitting Example Repeat, until get a good result

RANSAC Line Fitting Example Repeat, until get a good result

RANSAC Line Fitting Example Repeat, until get a good result

proportion of outliers e How Many Samples? Choose N so that, with probability p, at least one random sample is free from outliers. e.g. p=0.99 proportion of outliers e s 5% 10% 20% 25% 30% 40% 50% 2 3 5 6 7 11 17 4 9 19 35 13 34 72 12 26 57 146 16 24 37 97 293 8 20 33 54 163 588 44 78 272 1177

proportion of outliers e How Many Samples? Choose N so that, with probability p, at least one random sample is free from outliers. e.g. p=0.99 proportion of outliers e s 5% 10% 20% 25% 30% 40% 50% 2 3 5 6 7 11 17 4 9 19 35 13 34 72 12 26 57 146 16 24 37 97 293 8 20 33 54 163 588 44 78 272 1177 Affine transform

proportion of outliers e How Many Samples? Choose N so that, with probability p, at least one random sample is free from outliers. e.g. p=0.99 proportion of outliers e s 5% 10% 20% 25% 30% 40% 50% 2 3 5 6 7 11 17 4 9 19 35 13 34 72 12 26 57 146 16 24 37 97 293 8 20 33 54 163 588 44 78 272 1177 Projective transform

RANSAC for Estimating Projective Transformation RANSAC loop: Select four feature pairs (at random) Compute the transformation matrix H (exact) Compute inliers where SSD(pi’, H pi) < ε Keep largest set of inliers Re-compute least-squares H estimate on all of the inliers

RANSAC

Outline Image registration - feature-based approach - pixel-based approach

Direct (pixel-based) Alignment : Optical flow Will start by estimating motion of each pixel separately Then will consider motion of entire image

Problem Definition: Optical Flow How to estimate pixel motion from image H to image I?

Problem Definition: Optical Flow How to estimate pixel motion from image H to image I? Solve pixel correspondence problem given a pixel in H, look for nearby pixels of the same color in I

Problem Definition: Optical Flow How to estimate pixel motion from image H to image I? Solve pixel correspondence problem given a pixel in H, look for nearby pixels of the same color in I Key assumptions color constancy: a point in H looks the same in I For grayscale images, this is brightness constancy small motion: points do not move very far This is called the optical flow problem

Optical Flow Constraints Let’s look at these constraints more closely brightness constancy: Q: what’s the equation? A: H(x,y) = I(x+u, y+v)

Optical Flow Constraints Let’s look at these constraints more closely brightness constancy: Q: what’s the equation? A: H(x,y) = I(x+u, y+v) H(x,y) - I(x+u,v+y) = 0

Optical Flow Constraints Let’s look at these constraints more closely brightness constancy: Q: what’s the equation? A: H(x,y) = I(x+u, y+v) H(x,y) - I(x+u,v+y) = 0 small motion: (u and v are less than 1 pixel) suppose we take the Taylor series expansion of I:

Optical Flow Constraints Let’s look at these constraints more closely brightness constancy: Q: what’s the equation? A: H(x,y) = I(x+u, y+v) H(x,y) - I(x+u,v+y) = 0 small motion: (u and v are less than 1 pixel) suppose we take the Taylor series expansion of I:

Optical Flow Equation Combining these two equations

Optical Flow Equation Combining these two equations

Optical Flow Equation Combining these two equations

Optical Flow Equation Combining these two equations

Optical Flow Equation Combining these two equations In the limit as u and v go to zero, this becomes exact

Optical Flow Equation How many unknowns and equations per pixel? A: u and v are unknown, 1 equation

Optical Flow Equation How many unknowns and equations per pixel? Intuitively, what does this constraint mean? A: u and v are unknown, 1 equation

Optical Flow Equation How many unknowns and equations per pixel? Intuitively, what does this constraint mean? The component of the flow in the gradient direction is determined The component of the flow parallel to an edge is unknown A: u and v are unknown, 1 equation

Optical Flow Equation How many unknowns and equations per pixel? Intuitively, what does this constraint mean? The component of the flow in the gradient direction is determined The component of the flow parallel to an edge is unknown A: u and v are unknown, 1 equation This explains the Barber Pole illusion http://www.sandlotscience.com/Ambiguous/barberpole.htm

Optical Flow Equation How many unknowns and equations per pixel? Intuitively, what does this constraint mean? The component of the flow in the gradient direction is determined The component of the flow parallel to an edge is unknown A: u and v are unknown, 1 equation This explains the Barber Pole illusion http://www.sandlotscience.com/Ambiguous/barberpole.htm

Aperture Problem

Aperture Problem Stripes moved upwards 6 pixels Stripes moved left 5 pixels

Solving the Aperture Problem How to get more equations for a pixel? Basic idea: impose additional constraints most common is to assume that the flow field is smooth locally one method: pretend the pixel’s neighbors have the same (u,v) If we use a 5x5 window, that gives us 25 equations per pixel!

RGB Version How to get more equations for a pixel? Basic idea: impose additional constraints most common is to assume that the flow field is smooth locally one method: pretend the pixel’s neighbors have the same (u,v) If we use a 5x5 window, that gives us 25 equations per pixel!

Lukas-Kanade Flow Prob: we have more equations than unknowns

Lukas-Kanade Flow Prob: we have more equations than unknowns Solution: solve least squares problem

Lukas-Kanade Flow Prob: we have more equations than unknowns Solution: solve least squares problem minimum least squares solution given by solution (in d) of:

Lukas-Kanade Flow The summations are over all pixels in the K x K window This technique was first proposed by Lukas & Kanade (1981)

Lukas-Kanade Flow When is this Solvable? ATA should be invertible ATA should not be too small due to noise eigenvalues l1 and l2 of ATA should not be too small ATA should be well-conditioned l1/ l2 should not be too large (l1 = larger eigenvalue)

Edge Bad for motion estimation - large l1, small l2

Low Texture Region Bad for motion estimation: - gradients have small magnitude - small l1, small l2

High Textured Region Good for motion estimation: - gradients are different, large magnitudes - large l1, large l2

Observation This is a two image problem BUT Can measure sensitivity by just looking at one of the images! This tells us which pixels are easy to track, which are hard very useful later on when we do feature tracking...

Errors in Lucas-Kanade What are the potential causes of errors in this procedure? Suppose ATA is easily invertible Suppose there is not much noise in the image

Errors in Lucas-Kanade What are the potential causes of errors in this procedure? Suppose ATA is easily invertible Suppose there is not much noise in the image When our assumptions are violated Brightness constancy is not satisfied The motion is not small A point does not move like its neighbors window size is too large what is the ideal window size?

Iterative Refinement Iterative Lukas-Kanade Algorithm Estimate velocity at each pixel by solving Lucas-Kanade equations Warp H towards I using the estimated flow field - use image warping techniques Repeat until convergence

Revisiting the Small Motion Assumption Is this motion small enough? Probably not—it’s much larger than one pixel (2nd order terms dominate) How might we solve this problem?

Reduce the Resolution!

Coarse-to-fine Optical Flow Estimation Gaussian pyramid of image H Gaussian pyramid of image I image I image H u=10 pixels u=5 pixels u=2.5 pixels u=1.25 pixels image H image I

Coarse-to-fine Optical Flow Estimation Gaussian pyramid of image H Gaussian pyramid of image I image I image H run iterative L-K warp & upsample run iterative L-K . image J image I

Beyond Translation So far, our patch can only translate in (u,v) What about other motion models? rotation, affine, perspective

Warping Function w(x;p) describes the geometric relationship between two images: x Input Image I(x) Template Image H(x)

Warping Functions Translation: Affine: Perspective:

Image Registration Find the warping parameter p that minimizes the intensity difference between template image and the warped input image

Image Registration Find the warping parameter p that minimizes the intensity difference between template image and the warped input image Mathematically, we can formulate this as an optimization problem:

Image Registration Find the warping parameter p that minimizes the intensity difference between template image and the warped input image Mathematically, we can formulate this as an optimization problem: The above problem can be solved by many optimization algorithm: - Steepest descent - Gauss-newton - Levenberg-marquardt, etc. 

Image Registration Find the warping parameter p that minimizes the intensity difference between template image and the warped input image Mathematically, we can formulate this as an optimization problem: The above problem can be solved by many optimization algorithm: - Steepest descent - Gauss-newton - Levenberg-marquardt, etc

Image Registration Mathematically, we can formulate this as an optimization problem:

Image Registration Mathematically, we can formulate this as an optimization problem: Similar to optical flow: Taylor series expansion

Image Registration Mathematically, we can formulate this as an optimization problem: Similar to optical flow: Taylor series expansion

Image Registration Mathematically, we can formulate this as an optimization problem: Similar to optical flow: Taylor series expansion Image gradient

Image Registration Mathematically, we can formulate this as an optimization problem: Similar to optical flow: Taylor series expansion translation affine Image gradient Jacobian matrix ……

Gauss-newton Optimization - This is a quadratic function of Δp - Reaching the minimum when partial derivative reaches zero

Gauss-newton Optimization - This is a quadratic function of Δp - Reaching the minimum when partial derivative reaches zero

Gauss-newton Optimization - This is a quadratic function of Δp - Reaching the minimum when partial derivative reaches zero Rearrange

Gauss-newton Optimization - This is a quadratic function of Δp - Reaching the minimum when partial derivative reaches zero Rearrange A Δp = b Linear equation

Gauss-newton Optimization - This is a quadratic function of Δp - Reaching the minimum when partial derivative reaches zero Rearrange A-1 b

Lucas-Kanade Registration Initialize p=p0: Iterate: 1. Warp I with w(x;p) to compute I(w(x;p))

Lucas-Kanade Registration Initialize p=p0: Iterate: 1. Warp I with w(x;p) to compute I(w(x;p)) 2. Compute the error image

Lucas-Kanade Registration Initialize p=p0: Iterate: 1. Warp I with w(x;p) to compute I(w(x;p)) 2. Compute the error image 3. Warp the gradient with w(x;p)

Lucas-Kanade Registration Initialize p=p0: Iterate: 1. Warp I with w(x;p) to compute I(w(x;p)) 2. Compute the error image 3. Warp the gradient with w(x;p) 4. Evaluate the Jacobian at (x;p)

Lucas-Kanade Registration Initialize p=p0: Iterate: 1. Warp I with w(x;p) to compute I(w(x;p)) 2. Compute the error image 3. Warp the gradient with w(x;p) 4. Evaluate the Jacobian at (x;p) 5. Compute the

Lucas-Kanade Registration Initialize p=p0: Iterate: 1. Warp I with w(x;p) to compute I(w(x;p)) 2. Compute the error image 3. Warp the gradient with w(x;p) 4. Evaluate the Jacobian at (x;p) 5. Compute the 6. Update the parameters

Lucas-Kanade Algorithm Iteration 1: H(x) I(w(x;p)) H(x)-I(w(x;p))

Lucas-Kanade Algorithm Iteration 2: H(x) I(w(x;p)) H(x)-I(w(x;p))

Lucas-Kanade Algorithm Iteration 3: H(x) I(w(x;p)) H(x)-I(w(x;p))

Lucas-Kanade Algorithm Iteration 4: H(x) I(w(x;p)) H(x)-I(w(x;p))

Lucas-Kanade Algorithm Iteration 5: H(x) I(w(x;p)) H(x)-I(w(x;p))

Lucas-Kanade Algorithm Iteration 6: H(x) I(w(x;p)) H(x)-I(w(x;p))

Lucas-Kanade Algorithm Iteration 7: H(x) I(w(x;p)) H(x)-I(w(x;p))

Lucas-Kanade Algorithm Iteration 8: H(x) I(w(x;p)) H(x)-I(w(x;p))

Lucas-Kanade Algorithm Iteration 9: H(x) I(w(x;p)) H(x)-I(w(x;p))

Lucas-Kanade Algorithm Final result: H(x) I(w(x;p)) H(x)-I(w(x;p))

Image Alignment

Lucas-Kanade for Image Alignment Pros: All pixels get used in matching Can get sub-pixel accuracy (important for good mosaicing!) Relatively fast and simple Cons: Prone to local minima Relative small movement

Beyond 2D Registration So far, we focus on registration between 2D images The same idea can be used in registration between 3D and 2D

3D-to-2D Registration The transformation between 3D object and 2D images

Perspective projection 3D-to-2D Registration From world coordinate to image coordinate Viewport projection Perspective projection View transformation u sx u0 v -sy v0 1 1

3D-to-2D Registration Similarly, we can formulate this as an optimization problem: