Project 3: Face Morphing and Modeling a Photo Collection

Tej Bade, tbade12@berkeley.edu

Part 1. Defining Correspondences

The first step in morphing a photo of a face into another is defining the important features of the face for both images (as a set of points called correspondences) and computing a triangulation to break up each image into a set of triangles. Each of these triangles will be morphed separately in the following parts. I used the online tool given in the project spec to define correspondences and extract the locations of these points. Then, I computed the Delaunay triangulation of the averages of these points using scipy.spatial.Delaunay. The source and target images with the correspondences and triangulations are shown below.

Triangulation of my face
Triangulation of George’s face

Part 2. Computing the “Mid-way Face”

To compute the mid-way face we start by averaging the correspondences from both images and using the same triangulation as before on these correspondences to get an “average shape.” For each of the triangles in the average image, we separately compute the affine transformation matrices that map the triangles in the source and target images into that triangle.

We then use the skimage.draw.polygon to get all of the pixel locations within each triangle in the average image (given the triangle vertices) and use the inverse of the transformation matrix to get the corresponding pixel locations in the source and target images. Since the pixels might fall between two pixels after the inverse transformation, we use scipy.interpolate.RegularGridInterpolator (with method set to “linear”) to perform interpolation and get the values for each color channel.

We then construct the midway image by cross-dissolving, which means averaging the interpolated color values in both images and setting that to the color value of the pixel in the average image. This morphing method produces a “mid-way face” of the two images.

My face
George’s face
Mid-way face

Part 3. The Morph Sequence

To create a sequence of morphed images that gradually transition from one image to a second image, we can use the method from part 2 but with a weighted average for both the midway shape and the cross-dissolving computations. The following gif was created from 46 frames, where the first image is my face and the last image is George’s face.

Part 4. The “Mean Face” of a Population

In this part we use the Danes dataset, which is a dataset of 37 faces of Dane men and women along with annotations containing the correspondences. To construct the average face of the faces, we first compute the average shape using the correspondences for each image. We then individually warp each of the photos into the average shape. Here are some examples of the Dane images (left) and their warped versions (right).

I then cross-dissolve by taking the average of the color values across all warped photos. This gives us the average or mean face below.

Average face

I then warped my face to the geometry of the average face and the average face to my face. Before I did this, I had to reuse the correspondence tool and number the correspondences of one of the Dane faces in order to have matching correspondences of my face. Below are the correspondences for both my face and the first Dane face.

Then, I warped my face into the shape of the average face and vice versa. The results are shown below.

Myself warped onto average
Average warped onto myself

Part 5. Caricatures: Extrapolating from the Mean

To create a caricature, we use the equation image1+(1)image2⍺ * image1 + (1-⍺) * image2 to get a shape that exaggerates the features of one image over the other when <0⍺ < 0 or >1⍺ > 1. I made two caricatures of my face by setting image1 to my face and image2 to the average Dane face and then warping my face into the shape defined by the formula above. I used two alpha values: -0.5 and 2.5.

alpha = -0.5
alpha = 2.5

Part 6. Bells and Whistles

Changing Gender

Since I am a South Indian man, I took an image of the average South Indian woman from here and used the correspondence tool to extract the correspondences for both images. Both my face and the average South Indian woman face are displayed below.

My face
Average South Indian woman face

I first morphed face shape by using my morphing method from part 3 but with my appearance and the average face shape. I then morphed appearance by using the average face appearance and my face shape. Finally, I morphed both (which is the same as the mid-way face computation).

Morphing only shape
Morphing only appearance
Morphing both shape and appearance