# CS 194-26 ~ Project #4 ~ Face Morphing

Matthew Sie : cs194-26-aep

## Part 1a: Mid-way Image

The Mid-way Image was computed by first defining correspondence points between the two input images. Then, the mean of the two point sets, or the midway shape, was calculated so that the Delaunay triangulation could be computed. Using this triangulation, the transformation matrix between each corresponding triangle of the two input images and the midway image was calculated. Using the inverse of these transformation matrices, we were able to iterate over all the pixels, find the corresponding pixel value in both input images, and average the rgb values to get the new value.   ## Part 1b: Morph Sequence

The Morph Sequence was a sequence of 45 frames from input image one to input image two. The same algorithm of morphing as in the previous part was used. However, instead of calculating the mean of the two point sets and the average of the pixel values, we implemented weights to gradually get closer to the target image each frame. The weights were incremented for each frame, so that the values of the target image points and pixel values would be more and more weighted each frame, or iteration. All of the frames were compiled together into a GIF. ## Part 2: Mean Face of a Population

### Part 2a: Morph Faces to Average Shape

Using the IMM Face Database from the Danes website (http://www2.imm.dtu.dk/~aam/datasets/datasets.html) and the included annotated keypoints, we computed the average shape over 9 images of male subjects. We then morphed each image into the average shape using a similar morphing method as used in the parts above, except instead of averaging pixel values, we just use the pixel value from the original image, as we are only morphing to the shape.

--------------------- Original ------------------------------------------------------------------------------------------------------------- Morphed ---------------------                  ### Part 2b: Compute the Average Face

Again, we morphed each of the 9 images to the average shape using the same morphing algorithm. This time, however, we also averaged the pixel rgb values in order to get an average cross-dissolved image. ### Part 2c: My Face versus Average Face

For this part, using the average face image computed above, we defined a new set of correspondence points between that image and the original image of my face (resized to match the dimensions of the average face). Using these correspondence points and new triangulation, we completed used a similar morphing technique as above to morph the image of my face into the shape of the average face, and vice versa.  ## Part 3: Caricatures

For this part, we used the morphing method constructed earlier in the project. In order to accentuate features of the original image, however, we use a negative warp_frac instead of a positive one. I created four different caricatures to observe the affect of the warp_frac value, incrementing by -0.25 each time.

----------------- warp_frac = -0.25 ---------------------------------------- warp_frac = -0.50 ---------------------------------------- warp_frac = -0.75 ---------------------------------------- warp_frac = -1.0 -----------------    ## Part Bells & Whistles: Change Gender

For this part, I obtained an image of a "average female" image. Again, I established new correspondence points between this image and the image of my face (again, resized to match). I then used the morph function to create three version of the morphed image of me changing genders: one in which my face matches the shape of the "average female" image, one in which my face just does a simple cross-dissolve with the "average female" image, and one that does a full, complete morph of both shape and appearance (cross-dissolve).     -------------------------------Shape-----------------------------------------------------------------------Appearance-----------------------------------------------------------------------------Both-------------------------------