Intro to Computer Vision and Computational Photography, Fall 2021

Project 3: Face Morphing

SOPHIA SONG, CS194-26-ach



Overview

In this project, the goal was to understand how to morph between two faces, learning and applying the concepts of affine transformation, triangulation, inverse warp, and more.

Part 1: Defining Correspondences

First, I chose 29 key points on the face images, being careful to select these points in the same order for both images. Then, I implemented Delauney triangulation; I computed the triangulation at the mean of the two point sets.

Image 1
Image 2
Facial Keypoints
Triangulation of Sophia
Triangulation of George
Mean Triangulation (used in implementation)

Part 2: Midway face

To compute the midway face, I implemented computeAffine in order to compute the transformation matrix between two triangles. After defining this function, I was able to proceed to defining the inverse warp functionality. To successfully inverse warp, I iterated through the triangulation, using the output of the triangulation to identify the vertices of the two corresponding triangles in each image. After extracting these vertices, I generated a mask using polygon in order to identify the pixels that were within these two triangles. Once we had our triangles, we were able to transform our original image into the midway shape using computeAffine. Moreover, after the transformation, I had to interpolate along the rgb channels using interpolate.RectBivariateSpline as the transformed point may not fall into an exact pixel. After doing all of the above steps for each image (Sophia and George), I had then successfully warped each image into the "average shape." Finally, I averaged the colors of these two images together by simplying taking an average pixel wise.

Midway face between Sophia and George

Part 3: Morph

To create the morphing gif, I added two parameters and a wrapper function to my inverse wrap function from Part 2. These two parameters consisted of the warping factor (between 0 and 1) and the dissolve factor (between 0 and 1) that I varied to create the animation. I applied the warping factor against the two sets of facial keypoints while I applied the dissolve factor against the average shapes (ex. Sophia morphed into average shape).

Morph from Sophia to George

Part 4: Mean Face - Danes

Here, I computed the average dane using the Dane dataset. To do this, I read in the facial keypoints annoted for each of the .asf files corresponding to each image. After obtaining the key points for all the Danes, I averaged the points to obtain the average face shape of this whole population. After doing so, I computed a Delauney triangulation on the average face shape. After computing the triangulation, I warped each of the images into this average shape using the inverse warp function defined earlier. Finally, I cross-dissolved all of these warped images to obtain the average Dane.

Average Danish Face
Dane triangulation
Average Dane warped into Sophia geometry
A Danish person warped into the average shape
A second Danish person warped into the average shape
A third Danish person warped into the average shape

Part 5: Caricature

Here, I computed a caricature of myself between my face and the average Dane by interpolating between the two faces, going beyond the average danish face with an alpha factor of 1.5 to arrive at an extrapolation.

Caricature of Sophia using Average Dane