Morphing aligorithm explained

The idea is: For a point X in the destination image (the one were trying to calculate), find the point X' to sample in the source image.

Lets first look at a simple case where there is only one line. First we get the lines position in the destination image. This is just a weighted average of the line's position in the first and last image. Then calculate the transformation that is done to make the destination line into the source. This transformation is made up by a rotation, translation and a scaling of the line. If you've read some algebra you know that this is effectively specified as a transformation matrix M. Multiply the destination point X with the matrix to get the source point to samlpe X'.

If you have more then one line you do the above calculation for each line and get points X1' X2' X3' and so on. Now calculate the distance from the X point to each line and use that as a weight wi = 1 / (distance * distance). Find the weighted average X' of the Xi' points and sample that point. Repeat all this for all points in the destination image.