1.1k likes | 1.12k Views
CPSC 641: Image Registration. Jinxiang Chai. Review. Image warping Image morphing. Image Warping. Warping function - similarity, affine, projective etc Image warping - forward warping and two-pass 1D warping - backward warping Resampling filter - point sampling
E N D
CPSC 641: Image Registration Jinxiang Chai
Review Image warping Image morphing
Image Warping Warping function - similarity, affine, projective etc Image warping - forward warping and two-pass 1D warping - backward warping Resampling filter - point sampling - bilinear filter - anisotropic filter x u Inverse y v forward T(u,v) S(x,y)
Image Morphing Point based image morphing Vector based image morphing
h h? Image Registration Image warping: given h and f, compute g g(x) = f(h(x)) g? f Image registration: given h and g, compute f g f
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 transformationH3X3
Feature Matching ? • Two images taken at the same place with different angles • Projective transformation H3X3
Feature Matching • Intensity/Color similarity • 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
How Many Samples? Choose N so that, with probability p, at least one random sample is free from outliers. e.g. p=0.99
How Many Samples? Choose N so that, with probability p, at least one random sample is free from outliers. e.g. p=0.99 Affine transform
How Many Samples? Choose N so that, with probability p, at least one random sample is free from outliers. e.g. p=0.99 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
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?
Optical Flow Constraints Let’s look at these constraints more closely • brightness constancy: Q: what’s the equation? 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? 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? 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?
Optical Flow Equation How many unknowns and equations per pixel? Intuitively, what does this constraint mean?
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
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 • This explains the Barber Pole illusion • http://www.sandlotscience.com/Ambiguous/barberpole.htm