CS 294 026 Project 3 Face Morphing

Author: Tiancheng Sun

Defining Correspondences

The first step of face morphing is to define the key points for the two faces that need to merge together. I made use of OpenCV instead of matplotlib since this step requires me define the points for two images in same order and OpenCV allows me to create multiple window simultaneously. Here is one set of key points I defined:

dx
And here is the triangulation result from another set of data (I forgot to record the key point data I shown above...)
dx dy

Computing the "Mid-way Face"

As discussed in the class, I first merged the two sets of key points I got above and averaged them into one to get the average shape of our faces. After that, I wrote the function that traverses every triangle I obtained in the previous step's triangulation and then computed the inverse transform matrixes base on the triangle's vertices. After receiving the inverse transfer matrix, I applied them to the pixels within that triangle and used the RectBivariateSpline function to sample the color.
Below are the result while the shape and color blend factor are both setted as 0.5 (so, a average).

dx dy dy

The Morph Sequence

For this part, I modified the morph function into a more general one so that the shape blend control is separated from the color one. By linear change both of the shape blend factor and color blend factor between 0 and 1, I obtained a morph sequence shown below (all the pics used to generate this gif is placed in ./morph_sequence):

dx

The "Mean Face" of a population

I used the Danes dataset to get this part done. The first step is read in the key points and perform triangulation on it. Several additional points were added to cover the whole img and avoid generate too skinny triangles. Below is the triangulation result:

dx
After gained all the points, I averaged their value and get the averge face shape data for the Danes database. Below is some result of the database faces merged into the average shape:
dx dx dx dx dx dx
The first row shows the face before shape mergeing, the second row is the result after shape merging

After shape mergeing, I averaged the color of all merged faces together and thus obtained the average Dane face:

dx
The two imgs below shows the key point I defined for me and the new mean population face
dx dx

And the two pics below shows the warp result of my face into mean population face and mean population face into my face (well, seems the algo works really hard to find my left ear...):

dx dx

Caricatures: Extrapolating from the mean

For this part, I first calculated the delta between my face and the average Danes face by subtract the key point positons of the mean face from my face, scale it a factor, and finally add it back to my key point positions. Below is the results I obtained:

dx dx
Left img: factor = + 1.f, right img: factor = - 1.5f

Bells and Whistles

Change age/gender/ethnicity/smile/etc of your (or your friend's) face.

I first tried to morph a human face into a Ragdoll cat but the reuslt is kind like a... horror picture... So I tried to change my gender instead, the reference image is the average south east asia female face:

dx dx
These three pics below demos the blend happens on shape only, color only, and both:
dx dx dx

Make a morphing music video on a theme

Since the Danes face database helped me so much during this project, I chose to make a morphing video base on it to show my respect for all the 37 people who contributed to the Danes database. (There was 1079 frames generated, too big to include, here is the google drive link to access all the images: https://drive.google.com/drive/folders/1JZNU_U50jF5KPrLF2UGTgq_waALClb8m?usp=sharing) And this link directs to the animated gif: https://drive.google.com/file/d/1lv8xkeaymxkYUn4pUnzQOyb-1YgSpluY/view?usp=sharing
Thanks for reading.