Part 1: Morphing my face to another

First, I found some image of meryl streep from the website of the photographer that was linked in the project description. This will be my morph. I chose this because she looked very different from me. source

Here are the pictures:

drawingdrawing

Keypoints

Next, I highlighted some points in both images. This will be the keypoints.

Triangulation

Next, I found the average of those points and found the Delaunay triangulation for them. Here is the triangulation on both faces.

Visualizing the triangles

Affine transformation from 6 points?

I started with the equation from lecture.

$$\begin{bmatrix} x'\\ y'\\ 1 \end{bmatrix} = \begin{bmatrix} a &b &c \\ d &e &f \\ 0 &0 &1 \end{bmatrix} \begin{bmatrix} x\\ y\\ 1 \end{bmatrix}$$

That is just for 2 points. We can modify it to solve for $a$ to $f$:

$$\begin{bmatrix} Ax' & Bx' & Cx' \\ Ay' & By' & Cy' \end{bmatrix} = \begin{bmatrix} a &b &c \\ d &e &f \end{bmatrix} \begin{bmatrix} Ax & Bx & Cx\\ Ay & By & Cy\\ 1 & 1 & 1 \end{bmatrix}$$

To solve it with numpy, we need it in the format of $A \cdot x = b$ where $x$ is the matrix from $a$ to $f$

$$ \begin{bmatrix} Ax & Ay & 1\\ Bx & By & 1\\ Cx & Cy & 1 \end{bmatrix} \begin{bmatrix} a & d\\ b & e\\ c & f \end{bmatrix} = \begin{bmatrix} Ax' & Ay' \\ Bx' & By' \\ Cx' & Cy' \end{bmatrix} $$

Then, the transformation matrix is just the transposition of $x$, with 0,0,1 added to the bottom.

Part 1.2: Mid-way Face

I first found the triangulation and points for the mid way face, by taking the average of both faces

Warping and combining

In terms of interpolation, I used nearest neighbor. This is for practical reasons - the other ones are much slower.

Part 1.2: The Morph Sequence

In this part, I used the same code from 1.1 but used a loop instead.

Making the vid

drawing

Part 2 - Faces of Danes

Data is from source

After I imported the data, I showed the points so I can accordingly highlight my own face

And here is my own face, with the same points as the danes.

drawing

Getting the average face shape

Triangulate the average points

I calculated the average points of the danes, then got a triangulation.

I also added the four corners to the points. This is so that the triangles could cover most of the image. I don't know if this was the best way to do so; however, if I didn't do it, some images will have double faces.

Part 2.1 Morphing faces to the mean

We could morph faces to the avg points by reusing the morph function from before. We can use the same image for both image parameters, but use the avg points for one of the points parameters

Creating the mean face

Wow, what a good looking face.

Getting myself involved

First, I morphed my face to the mean shape. Then, I morphed the mean face to my shape

Oh dear!! I think my image was too different from the original.

Part 2.2 - Caricature

Shape

First, I exaggerated the shape of my face

Pixels

Then, I exaggerated the pixels of my face.

To do this, I first morphed the mean face to my exaggerated shape:

Then I used the difference to boost the deviation of my face.

Part 3: Bells and whistles

Part 3.1 Changing gender

Getting the mean points of men, women, and the difference

Getting the mean pixels of men, women, warped to average. And the difference.

Morphing myself - shape only

Morphing myself to the shape of an average female danish computer vision scientist.

Morphing myself - pixels only

Then, I morphed the average female face to my shape, and used its pixels to shift my pixels towards the female side.

Then I combined the results of the previous two steps

Part 3.2 PCA!

We do pca on the faces that are already warped to the average.

These are the components. I think the standout feature here... is whether or not the image is of my own face.

I tried not including my face in the PCA at first - however, the result of that made it nearly impossible to recreate my face from the principle components

My own coefficients, expectedly, was very heavy on the first component.

The coefficients of the average face:

Reconstructing my exaggerated face from pca