# Project 4. Face Morphing. Andrew Zhang. cs194-26-agx

## Defining Correspondances.

I wrote a correspondance label helper tool that loads two images side by side, so that they can be labelled simultaneous (instead of labelling one image first, then the next).
I used about 100 correspondances for my two tests below.

## Midway Face

Below one can see a few midway faces. There is one of Katz + Stoica and one of myself and stoica. Focus on the center image for the stoica katz blend; the other frames
are for debug purposes (2nd to the left and 4th to the right sum to the middle image). As we can see, the midway face is quite nice; if one looks closely, they can see
Katzs gray hair and Stoicas distinctive hairline.
If one looks and the 2nd image, we can see that Katzs chin is becoming more like that of Stoicas, a bit less pointy. Similarly looking at the fourth image, we see that Stoica's chin is now pointed, and his smile is more pronounced! The glasses do not quite merge right, however I could not fix this; labelling them would have created spacially inconsistant points.

### Midway Face Improvements

My original code generated frames at 42 seconds per frame for a 1000x800 frame. I later managed to bring this down to 1.2 seconds by aggressively avoiding for loops.
To do this I used tensorproducts instead of looping over affine transforms and a scipy subroutine call to take advantage of a parallel B-spline evaluation. I documented
this improvment and helpful StackOverflow posts on Piazza.

## Morph Sequence

We note that visual color artifacts are caused by heavy gif compression (256 colors).

Gif of myself to Prof Stoica. And of Katz to Stoica

## Mean Face

I calculated the mean face of the Danish Face image data. First, I took the average of all correspondances between all the photographs. Then I mapped
the Danish faces to this mean correspondance by using the morph function, setting warp frac to 1 and dissovle frac to 0. That way we use the
structural data of the mean correspondances but use the color of the proper Danish face. I also made sure to scale the color channels appropriately
to avoid an overly bright image.

This is the average Danish male.

This is a Danish male mapped to the mean. Left is normal face, right is mapped.

## Caricature

I made a caricature of myself using a mean Danish male face. I labelled this face and mine, then proceeded to find the difference
between the mean Danish face and my own, and added this difference to my face to project myself farther from the mean.

Results are posted below!

## Bells And Whistles

I worked with other students to make this video