# Project 3: Face Morphing

## Overview

In this project, I used correspondence points and Delaunay triangulation in order to morph from one face to another. This involved manually selecting various control points between the two images I wanted to morph and warping the pixels from each of the images to the triangles defined by those control points. The mid-way face was computed using the average of images' control points as the shape to warp to and as the average of the warped image. The morphing sequence used varying steps of warping and dissolving fractions to completely morph from one face to another. I also applied these morphing techniques to create the "mean face" of a popluation and extrapolating from that mean face to produce a caricature.

## Part 1: Defining Correspondences

The process of selecting the images I wanted to correspond involved finding pictures with a uniform background and resizing them to have the same size and aspect ratio; this is to create the best possible result. After obtaining the images, I used the python cpselect tool to define pairs of corresponding points between the two images: of myself and Japanese-American actress Kiko Mizuhara. It took some experimentation to find a good set of control points, involving points framing the face and extra points around key features such as the eyes, nose, and lips. I also realized that I needed to select all four corners of the image so as to be able to warp the image as a whole. After selecting my control points, I used the pre-built Delaunay triangulation function to produce a set of triangles over the control points to be used for warping in the next part.

 Myself Annotated with control points
 Kiko Mizuhara Annotated with control points

## Part 2: Computing the "Mid-way Face"

After selecting the correspondence points, I took the midpoint across the image of myself and Kiko, to use as input into the Dalaunay function. After creating the Dalaunay triangulation, I then created the affine transformation matrices to warp the images to the midpoint. I used the polygon to determine which points belonged to each triangle and then applied inverse warping to each triangle. I chose to do inverse warping as opposed to forward warping as it is less computationally expensive. Finally, I used bilinear interpolation to blend the colors of each triangle into one final image.

 Myself warped to midpoint Kiko warped to midpoint Mid-way face

I also applied the same algorithm to these pictures of Hyunjin from LOONA and Jennie from Blackpink.

 Original Hyunjin Original Jennie Mid-way face

## Part 3: Morphing

The next step was to create a morph sequence from one face to another. This involved the same process as for the mid-way face except with varying levels of warping and cross dissolve fractions. The warping fraction was used a weight for the linear combination of both images when computing the triangulation. For example, the warping fraction is 0.5 when computing the midway face as I am taking the exact midpoint between each of the corresponding points. Similarly, the cross-dissolve fraction is the weight of the warped images to the final morphed image. For example, the cross-dissolve is 0 to begin with, so the final morph is just the first image warp, and the cross-dissilve is 1 to end with, so the final morph is just the second image warp. The way I chose to vary the warping and cross dissolve fractions for this morphing sequence was to keep them equal to each other, with a step size of 1/45.

 Myself to Kiko morph sequence

## Part 3: The "Mean Face" of a Population

I used the FEI face database to create an image of the average Brazilian woman. To do this, I hand selected 29 images of women from the provided database, and parsed their .pts files to extract each of their control points. I then took the average of all these points to use as input points for the triangulation. I used this triangulation to morph each of the individual faces into that average shape and finally averaged out those warped to create the subpopulation mean. Below are images of various woman morpher to the average Brazilian woman face shape.

 Brazilian woman "11a" Brazilian woman "84a" Brazilian woman "37a" Brazilian woman "51a" Brazilian woman "58a"

Below is the result of averaging out all of the warped images as well as the results of morphing the average face to my face shape and morphing my face to my the average face shape.

 Average Brazilian woman Average Brazilian woman in my face shape Me in the average Brazilian woman face shape

## Part 4: Caricatures (Extrapolating from the Mean)

I created a caricature of my face by taking the difference between my face shape and the average Brazilian woman face shape that I calculated in the previous part. I then multiplied that difference by some value, alpha. I tried various values of alpha to control the exaggeration of my features. Finally, I morphed the image of my face to the scaled difference. This takes the points on my face that are different from the average face and amplifies them. As shown below, creating a caricature of my face accentuated the almond shape of my eyes and the heart shape of my chin.

 Caricature with alpha = 1.2 Caricature with alpha = 1.5

## Bells and Whistles

For my bells and whistles I decided to create a music video morphing some of the characters from Game of Thrones:

https://vm.tiktok.com/ZMJ587voa/