Featured image

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 Link to heading

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 Link to heading

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 Link to heading

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 Link to heading

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 Link to heading

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 Link to heading

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