I used 13 keypoints on primarily the center of the face to determien correspondences between Picture A & B. I took the average of the two sets of keypoints and then found the Delaunay triangulation which I applied to both pictures.

In the previous portion, we determined the average of each keypoint location between the two faces. We warp each face into this average face shape by computing an affine transformation for each individual triangle. An affine transformation is uniquely defined by 3 source points and 3 destination points. We use the 3 keypoints for the source and destination triangles to determine the affine transformation. https://stackoverflow.com/questions/22954239/given-three-points-compute-affine-transformation how I mathematically defined the matrices and solved the system of linear equations. Once we have the affine transformation, we iterate through the points in midway point (destination) triangle and use the inverse affine transformation to find the corresponding point in the original image. Since this corresponding point likely isn't an integer value. We can use the scipy interp2d library to find the interpolated point that we can use in the destination image. Now that I have converted face A and face B to mid-way shape and have colors for each channel, I can cross-dissolve the 2 images by taking the average for each channel.

This portion is very similar to the previous portion. The difference is in our averaging. Previously, I took a simple average of the first and second image. Here, we will take a weighted average. The weighted average of the keypoint locations is alpha * keypointA + (1 - alpha) * keypointB. The weighted average for the cross-dissolve is similar; alpha * imA + (1-alpha) * imB. Since we are doing a morph from A to B over 45 frames, we will set alpha to 1 / frame_number.

We compute the average face shape by reading in all of the keypoints for all of the images and then converting them to pixels and then averaging them. Next, we morph each image using the previously described strategy from imA to the mean face shape. We then take the average of all the faces (after morphing) to determine the average face shape of the population.

Now that I have morphed my face into the average face shape. I computed the difference between my morphed face and the average face. I multiply the difference by alpha (in my case 1.7) and add that to my morphed image to create a caricature.