# CS194 Project 3: Face Morphing

## Part 1: Defining Correspondences

In order to create triangulations on the face, we first have to manually define ordered correspondences. Then we can triangulate the correspondences using delaunay triangulation. Note that each triangle represents a feature.

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

Before computing the "mid-way" face, we have to first know about the average shape of each feature. One way to calculate the average shape is to take an average of the correspondences and triangulate on them. After getting the average shape, we want to warp each triangle in the average shape to both target triangles. This warping transformation can be solved algebraically (each axis has 3 unknowns with 3 equations). After getting the transformation, we can mask each triangle separately to get their coordinates in the average shape basis. These coordinates can be then transformed to both target bases to get the corresponding coordinates. After getting the coordinates, it is just a matter of interpolating the color at each coordinate.

## Part 3: The Morph Sequence

Now, we want to create a morph sequence instead of just half face. Luckily, we already have everything needed implemented in the previous part because the half face is just the interpolated image with alpha = 0.5. In the morph sequence, we need to interpolate from 0 to 1.

## Part 4: The "Mean face" of a population

Why are you so mean? What I mean by "mean face" is actually the average face across a dataset. But how to calculate that "mean face"? Surprisingly, we already have all the tool we need. We first need to calcalate the "mean face" shape. Then we can warp each triangle in the mean face basis to the bases (corresponding triangle) of each image in the dataset. We can then use the known pixel values to calculate the mean across the dataset for each coordinate. Here, we are using the data from FEI Face Database.

It is actually a face!!! It is just unbelievable!!!

Let's try to warp some images in the dataset to the mean shape.

Now, let's warp my face into the mean shape.

Who is that??? To revenge, let's warp the mean face into my shape.

## Part 5: Caricatures: Extrapolating from the mean

As you might remember, we have been using interpolation for both shape and color. Now we want to use extrapolation to create shapes that is abnormal. Here, I am using the mean face from the dataset as the mean.

 alpha = 1.2 alpha = 1.5

## Bells and Whistles

After seeing the "mean face", it's time to see happy face. Let's try to get me smile. Here, we can reuse the FEI Face Database because it has the "mean face" of smile face.

Using the mean "smile face" shape, I can make myself look happy again.

 mean smile shape overlay mean smile shape with me mean shape me smile shape me