# Project 3 - Face morphing

## CS 194-26, UC Berkeley

• Computing the "mid-way" face
• The morph sequence
• The "mean face" of a population
• Caricatures: extrapolating from the mean
• Bells and whistles
• ### Computing the "Mid-way" face

Input 1

Mid-way image

Input 2

The mid-way image that came out initially was pretty red. This change of color occured after interpolating color values from the input images onto the midway shape using scipy.interpolate.RectBivariateSpline. This is likely because it is not a nearest-neighbors interpolation, so the color values would necessarily change slightly. The difference turned out to make the midway image so starkly red that I edited the colors a bit before including it here. The reddening effect is seen in the morph .gif below.

### The morph sequence

The gif below moves smoothly between the two input images that have been morphed together. This is done by producing mid-way images of varying warp fractions (the shape-morphing effect) over the interval [0,1], where 0 is the first input image and 1 is the second. The effect of the warp fraction on the resulting warp is modeled by a*P + (1-a)*Q, where P is the first input image, Q is the second and a is the warp fraction. The dissolve fraction, which determines how much of the color values of each image appears in each warped image (the fading effect) is modeled the same way, where a is the dissolve fraction. I queued up all of the warped images in ascending order by warp fraction, followed by the desceding order, to get the loop that moves back and forth between the two inputs below.

Morph sequence from Input 1 to Input 2

### The "mean face" of a population

Here I compute a "mean" face over a dataset of faces of Danish computer scientists. Note: most of the images in the dataset are of males; and the "mean" is merely representative of the 40 particular images in the dataset, and may not accurately stand for the "mean" face of all living Danes.

Some of the input images

The 40 input images of Danes were annotated for their keypoints. Their keypoints in this state do not align, of course, primarily because they have different face shapes. I needed to compute and average of all of these keypoints using interpolation to obtain the keypoints of the "mean" shape, and then warped all of the input images into the new "mean" shape's keypoints. That way, their facial features would roughly align, as seen below.

Interestingly, the second from the left did not change much, meaning they already resemble the average of this dataset!

Warped Danes

The last step was simply to cross-dissolve all of the warped images by summing their pixel values and dividing by the total number of images.

"Mean" of Danish faces

Input 1

Input 1 -> "mean" shape

"Mean" face -> Input 1 shape

"Mean" Danish face

### Caricatures: extrapolating from the mean

Here I create a "caricature" of myself by extrapolating, rather than interpolating a shape of keypoints between my image and the "mean" image of the Danes and warping my face to that extrapolated shape. I extrapolate by performing a weighted average of the keypoints from my image and the "mean" image, and give a greater weight to the keypoints on my own image, resulting in an effect by which my features are "exaggerated." The extrapolation I used is modeled by a*P + b*Q, where P is my image and Q is the mean. The weights I used are a = 1.6 and b = -0.6.

"Caricature" of Input 1

Input 1

"Mean" Danish face

### Bells and Whistles: Presidential Portraits Face Morph

I was interested in using paintings for my own face morphing experiment, meaning I would need to find a set portraits that have been taken in a consistent way in order for the morph to work. I naturally thought to use portraits of the U.S. Presidents from either the NPG or WHHA, the earlier portraits of which incorporate a similar style of portraiture and have relatively uniform dark backgrounds. I used 6 portrait images, all taken at a relatively "1-quarter" angle, for the morph.

It took some time to align each image and choose keypoints that would produce an adequate morph between the presidents' faces. How much of the face that is visible in each image is singular to each image, so some keypoints (for instance, around the nose) were not visible in some of the images.

I created a gif of each president morphed into the next in sequence, beginning and ending with Andrew Jackson to form a "perfect" loop.

Input 1

I then incorporated the sequence into a video to play along with music. I wasn't sure what kind of music would go interestingly with this gif of presidential portraits, but I did like the kind of irony of this particular morph in that it feels in one way like "the faces of America" (as the president, indeed, should be), but also hugely unrepresentative of the true faces of America, especially not of its indigenous peoples. So I found an old 1894 recording of "Ghost Dance," a gambling song of the Paiute, whose pacey rhythm went nicely with the morph speed. I wanted to incorporate the "invisible" faces of America through sound, and titled the video "Face of America."