Image Morphing: 15-463: Computational Photography Alexei Efros, CMU, Fall 2005
Image Morphing: 15-463: Computational Photography Alexei Efros, CMU, Fall 2005
Alexey Tikhonov
Recovering Transformations
?
y x f(x,y) T(x,y) y x g(x,y)
Translation: # correspondences?
?
y x T(x,y) y x
How many correspondences needed for translation? How many Degrees of Freedom? What is the transformation matrix? 1 0 p' x px M = 0 1 p' y p y 1 0 0
Euclidian: # correspondences?
?
y x T(x,y) y x
Affine: # correspondences?
?
y x T(x,y) y x
Projective: # correspondences?
?
y x T(x,y) y x
?
T(x,y) A
Source
C A
Destination
Given two triangles: ABC and ABC in 2D (12 numbers) Need to find transform T to transfer all pixels from one to the other. What kind of transformation is T? How can we compute the transformation matrix: x' a b c x y ' = d e f y 1 0 0 1 1
1 1
(0,0)
(1,0)
T2
change of basis
C A
Source
Destination
Dont forget to move the origin too! Very useful for Project 2
Averaging Points
Q
v=Q-P
Linear Interpolation (Affine Combination): New point aP + bQ, defined only when a+b = 1 So aP+bQ = aP+(1-a)Q
Interpolate whole images: Imagehalfway = (1-t)*Image1 + t*image2 This is called cross-dissolve in film industry But what is the images are not aligned?
Dog Averaging
What to do?
Cross-dissolve doesnt work Global alignment doesnt work
Cannot be done with a global transformation (e.g. affine)
Any ideas?
Feature matching!
Nose to nose, tail to tail, etc. This is a local (non-parametric) warp
Morphing procedure: for every t, 1. Find the average shape (the mean dog)
local warping Cross-dissolve the warped images
Triangular Mesh
1. Input correspondences at key feature points 2. Define a triangular mesh over the points
Same mesh in both images! Now we have triangle-to-triangle correspondences
Triangulations
A triangulation of set of points in the plane is a partition of the convex hull to triangles whose vertices are the points, and do not contain other points. There are an exponential number of triangulations of a point set.
Quality Triangulations
Let (T) = (1, 2 ,.., 3t) be the vector of angles in the triangulation T in increasing order. A triangulation T1 will be better than T2 if (T1) > (T2) lexicographically. The Delaunay triangulation is the best
Maximizes smallest angles
good
bad
Improving a Triangulation
In any convex quadrangle, an edge flip is possible. If this flip improves the triangulation locally, it also improves the global triangulation.
If an edge flip improves the triangulation, the first edge is called illegal.
Illegal Edges
Lemma: An edge pq is illegal iff one of its opposite vertices is inside the circle defined by the other three vertices. Proof: By Thales theorem.
Theorem: A Delaunay triangulation does not contain illegal edges. Corollary: A triangle is Delaunay iff the circle through its vertices is empty of other sites. Corollary: The Delaunay triangulation is not unique if more than three sites are co-circular.
Image Morphing
We know how to warp one image into the other, but how do we create a morphing sequence?
1. Create an intermediate shape (by interpolation) 2. Warp both images towards it 3. Cross-dissolve the colors in the newly warped images
Warp interpolation
How do we create an intermediate warp at time t?
Assume t = [0,1] Simple linear interpolation of each feature pair (1-t)*p1+t*p0 for corresponding features p0 and p1
Other Issues
Beware of folding
You are probably trying to do something 3D-ish
Dynamic Scene