CS-194-26 Project 3

Abhinav Ayalur

Overview

In this project, we used triangulation and affine transformation to morph faces into each other. This was done through taking 2 images, marking corresponding keypoints in each one, and then using that to align the two images together. We then found the average face among a population, then warped our image to that average. Finally, for our bells and whistles, I morphed my face into that of the average NFL player.

Defining Correspondences

I adapted the input code from project 1 to be able to select keypoints. Then, I used Delaunay triangulation to generate triangles across the image.

Images

Me

George Clooney

Marked points on me

Marked points on Clooney

Triangles drawn on me

Triangles drawn on Clooney

Computing the Midway Face

To compute the midway face, I had to first get the average of the keypoints of myself and Clooney. Then, I used Delaunay triangulation to get the triangles for the image. For each of the triangles and over each original image, I would use the the average keypoints involved in each triangle corner and the corresponding keypoints of the original image to calculate a transformation matrix between the original image triangle and the average image triangle. If A is my average points, C are my input points, and B is the transformation matrix from C to A, we can see that A = B*C, and so B = A * inv(C). We performed this calculation to get all of the transformation matrices. After this, I used polygon to get all the coordinates within each average triangle, and then use my matrices to reproject them to the original image. Then, I used RectBivariateSpline to sample from the original image, and put those sample points into the new image. I did this for both images, multiplying by 0.5 for each to account for the fact I'm adding in 2 images, and I got my results below.

Images

Me

George Clooney

The midway image of myself and George Clooney!

The Morph Sequence

For the morph sequence, I made my code from before more generic, where I could specify 2 images, and then a warp fraction between them and a dissolve fraction between them which would give me a weight to apply with respct to which image to show more and which image to warp more. I went linearly from 0 to 1 for both warp and dissolve, and the results are below!

GIF

My warp sequence from Clooney to Me!

Mean Face of a Population

To compute the mean face of the population, I used the Dane face dataset, specifically looking for male images facing forward. I modified my code from before to be able to take any number of images and average between all of them, giving them equal warp and dissolve weight, and calculating matrices for each of them. My results are below! First I have the average face, then some images from the dataset and their warp into the average face, then my image warped into the average face, then the average faced warped into mine

Images

Average Face of the Danes

Image 0 of the Danes

Image 0 warped into the Average Face

Image 1 of the Danes

Image 1 warped into the Average Face

Image 2 of the Danes

Image 2 warped into the Average Face

Image 3 of the Danes

Image 3 warped into the Average Face

The Average Face warped into my face

My face warped into the Average Face

Extrapolating from the Mean

For the caricature I just did the same thing as warping but made the warp fraction either greater than 1 or less than 0, which produced interesting results.

Images

My face as a super-dane

My face as an anti-dane

Bells and Whistles: I become an NFL player.

For the bells and whistles section, I chose to morph my face into the average NFL player, to see what it would be like to be an elite athlete. I also morphed the average NFL player into me. Finally, I did a 50-50 morph.

Images

Me

The average NFL player face

My face as an NFL player

And NFL player's face as me

Half and half between me and an NFL Player