Understanding transformations
After we detect two faces and before we blend them, we will try to align the faces based on the eye and nose coordinates. This alignment step is a geometric transformation, which remaps points (or pixels) from one space to another. For example, the following geometric operations are special cases of a transformation:
Translation: This moves the points laterally. It repositions them around a new center.
Rotation: This spins the points around a center.
Scale: This moves the points farther from or nearer to a center.
Mathematically, a transformation is a matrix and a point (or pixel position) is a vector. We can multiply them together to apply the transformation to the point. The output of the multiplication is a new point.
Conversely, given three pairs of points—in our case, the pairs of left eye centers, right eye centers, and nose tips—we can solve for the transformation matrix that maps one set of points onto the other. This is a problem of linear algebra. After...