Skip to main content

Face Morphing

·322 words·2 mins·
Author
Mark Ogata
AI and Robotics Researcher at BAIR
Table of Contents

For Fall 2024, I am taking an image processing class. One assignment involves face morphing without neural networks! Here’s an example:

Morphing from a girl to my face

In this project, I also created intermediate morphs, caricatures of myself, and computed the average face of a population.

Here’s an amazing example of super-smooth face morphing to music.

Part 1: Source Images and Feature Extraction
#

These are my source images:

Man
Woman

First, I used the dlib library to extract facial landmarks from both images. Then, I computed the halfway points for each landmark pair to determine the morph points, and applied Delaunay triangulation to create a triangle mesh for the morph.

Triangulation and feature points

Part 2: Midway Face Calculation
#

I computed the “midway face” by applying affine transformations to morph each triangle in both images toward the midpoint shape. Here is the 50/50 blend between the two images:

Man
Woman
Midway Face

Part 3: Morph Video
#

To create a morphing animation, I varied the weights from 100% one image to 100% the other:

  • output = image1 * alpha + image2 * (1 - alpha)

This generates a smooth transition from one face to another. Here are some examples:

Man to Woman Morphing

Woman to Girl Morphing

Part 4: Average Face Calculation
#

I computed the average face from a Danish face dataset by averaging each landmark position across faces.

Here’s the average face shape of a Dane with feature points overlaid:

Average Danish Face with Landmarks

And here’s the computed average Danish face:

Average Danish Face

Next, I morphed several individual faces from the dataset into the average Danish shape:

Example Morph to Average Dane 1
Example Morph to Average Dane 2
Example Morph to Average Dane 3

Here’s my face warped to the average Danish face shape:

My Face as a Dane

And here’s the average Danish face warped to my face shape:

Dane Face as Mark

Part 5: Caricature
#

By extrapolating away from the average Danish face shape, I created a caricature of myself. Setting the weight to -1 (instead of within [0, 1]) exaggerates my unique features:

Caricature of Myself

Extra Credit
#

Here’s a video of me morphing from a kid to 21 years old, synced to music.

View the code for this project on GitHub

Related

Filters and Frequencies
·659 words·4 mins
Colorizing the Prokudin-Gorskii Photo Collection
·240 words·2 mins
RGB to Depth AI
·184 words·1 min