Project 3: Face Morphing and Modelling a Photo Collection

Defining Correspondences

The first step of face morphing is to define pairs of corresponding points on the two images by hand. In Python, I used ginput() function to define two set of keypoints of two images with the same ordering. In addition, I included the four corners of each image((0, height-1), (width-1, height-1), (0,0), (width-1, 0)) in to the keypoints set.

After defining pairs of corresponding points, I used Dalaunay() in Python to provide a triangulation of these points. In order to lessen the potential triangle deformations, I compute the triangulation at the mean of the two keypoint sets.

Face 1 keypoints

Face 2 keypoints

Computing the "Mid-way Face"

Affine Trasnformation

First, I need to compute Affine Transformation matrixes.

For each triangle, three original points and three transformed points can determine the six parameters in the transformation matrix. After computing the transformation matrix, We can transform each point inside the triangle from one image to another image. When computing the mid-way face, the target geometry is the mean of the two keypoint sets of two input images. For each triangle in target geometry, I computed the inverse warp and find the original triangle in original image.

Averaging the colors

After warp the geometry, target_corlor = 0.5 * color_of_image1 + 0.5 * color_of_image2

Face 1

Face 2

Mid-way Face

The Morph Sequence

Given a warp_frac, I computed the target geometry using: target_points = (1 - warp_frac) * image1_points + warp_frac * image2_points

Then I warped two input images to the target geometry using the computed Affine Transformation matrix.

Given a dissolve_frac, I computed the target color using: target_color = (1 - dissolve_frac) * image1_color + dissolve_frac * image2_color

By applying sequences of warp_frac and dissolve_frac, I can get a sequence of morphing images, which can be showed using .gif image.

Face 1

Face 2

Morph Sequence

The "Mean face" of a population

I use the Danes dataset to compute average faces.

The geometry of average face is the mean of keypoins sets of all images. And the color of average face is the mean of color of all images.

Average face of male(no smile)

Average face of male(smile)

Average face of female

My face warped into the average geometry of male

Average face of male warped into my geometry

caricatures: Extrapolating from the mean

In order to creature, I need to highlight my characteristics. So I extrapolated my face from the population mean by using negtive warp_frac to morph my face.

Caricature

Bells and Whistles: Change Smile

By adding the difference of average smile face and no-smile face to my face geometry, I can change my smile.

No-smile face

Smile face