# Project 3: Face Morphing

## Overview

In this project, I explored techniques for morphing one face into another by warping image shape and cross-dissolving image colors. The warp is controlled by defining a corresponding set of points and triangles on both images. For the smoothest transformations, these correspondances should match mouths to mouths, eyes to eyes, etc. I started by morphing a photo of my own face into other faces, and then went on to do some experimentation with extrapolation and average faces calculated from public datasets.

## Defining Correspondences

In this section, I chose 46 corresponding points on two photos: one of my face and one of Elrond from Lord of the Rings. I then computed a Delaunay triangulation on the midway shape (the points defined by averaging corresponding points between the two faces). The Delaunay triangulation process produces a reasonable set of corresponding triangles on both faces that seeks to avoid extremely small or large angles.

Below are images of my face and Elrond's face. I have provided the original images, the images overlaid with their own triangulations, and the images overlaid with the triangulation of the mid-way point set.

Original Image Triangulation Midway Triangulation
My Face
Elrond's Face

## Computing the "Mid-way Face"

Before I could morph my face into Elrond's, I needed a way to calculate the mid-way image between these two faces in terms of color and shape. Just as Elrond lives in Middle-earth, I wanted to get to Middle-face. To do this, I wrote a function to generate an affine transformation matrix between any two triangles. Using such matrices, I inversed warped each triangle on both images to the corresponding triangle on the midway triangulation shown above. Within each triangle, I averaged the two images to blend them. The resulting "Middle-face" is shown below.

My Face Elrond's Face Middle-face ("Michaelrond")

## The Morph Sequence

To create the entire morph sequence comprising 46 frames (numbered 0-45), I wrote a function Morph that computes any partway morph between two images im1 and im2 with some distance d from im1 and distance (1 - d) from im2, where d is in [0, 1]. This process is very similar to the mid-way face calculation above, but the result is parameterized to be at any given point along the morph, not just the mid-way point. I then used this Morph function to generate 45 equally-spaced warped images to serve as the frames of the morph sequence.

The result is below:

One-way morph (generated by my code) Back and forth (made later with editing tools)

## The "Mean Face" of a Population

In this section, I used this dataset of Brazilian researcher faces to generate an average face. After that, I morphed each face in the dataset to the average shape, and warped between my facial geometry and the average Brazilian researcher facial geometry.

Average Brazilian Researcher Face My Face
Brazilian Average Warped to My Geometry My Face Warped to Brazilian Average Geometry

I also warped a number of individual faces to the average geometry.

Geometric Warping Examples
Originals
Warped to Average

## Caricatures: Extrapolating from the Mean

For my next trick, I produced a caricature of my face by extrapolating from the population mean that I computed above. To produce this caricature, I essentially computed the "difference" between my face and the mean face and then added some multiple (alpha) of that difference back to my face. Instead of taking the straightforward per-pixel difference between my face and the mean, I used my Morph function to extrapolate further in the direction from the mean face to my face by setting the warp_frac to be > 1.

Apparently, compared to the average Brazilian researcher, I have a very large forehead and ears.

Original (alpha=0) alpha=0.25 alpha=0.5 alpha=0.75 alpha=1.0

## Bells and Whistles #1: Changing the Race and Gender of my Face

I downloaded a few average faces and used them to simulate changing the race and gender of my face. For each average face, I try morphing just the shape, just the appearance, and both.

Me as a Spanish Woman:

Original Morph Shape Morph Appearance Morph Both

Me as a Chinese Woman:

Original Morph Shape Morph Appearance Morph Both

Me as an Israeli Woman:

Original Morph Shape Morph Appearance Morph Both

Me as a West African Woman:

Original Morph Shape Morph Appearance Morph Both

## Bells and Whistles #2: Produce a Face-morphing Music Video with Classmates

I collaborated on a face-morphing video with the following students: Roma Desai, Vanessa Lin, Jason Wang, Jenny Song, Ankit Agarwal, Won Ryu, Briana Zhang, April Sin, Tushar Sharma, (my_name), Ja (Thanakul) Wattanawong, William Loo, Gary Yang, Chendi Wu, Sophia Yan, Jun Gao, Mengti Sun, Ruochen Liu, Xingyu Jin, Lucy Wang, Ken Guan, Ke Huang. Gary helped put all of our parts together, and the result is available below (alternate link):

The part I animated: