In this project, I played around with morphing and cross-dissolving to generate new images based on different faces and populations.
I decided to create a morphing sequence using pictures of myself (Left) and my sister Lin (Right), possibly to see what we would look like if we were identical twins.
I first manually defined 91 corresponding points on each image using plt.ginput
, and then calculated the mid-point of the corresponding points for the two images to create a triangulation (using the Delaunay triangulation algorithm from the python scipy
library) for morphing.
The mid-way face was computed by first calculating the average shape from the keypoints of the two images. An affine transformation was applied for each triangle in the Delaunay triangulation to warp both faces into the average shape. This process involved the computeAffine
function, which constructs a system of linear equations based on triangle coordinates and solves it using np.linalg.solve
to determine the transformation parameters. The inverse transformation matrix was then used to map pixels from the original images to create the warped versions. While scipy.interpolate.griddata
was initially considered for bilinear interpolation, it proved inefficient, and scipy.ndimage.map_coordinates
was used instead for faster interpolation between the four nearest neighbors. Finally, the pixel values of the warped faces were averaged to produce the mid-way face.
Lastly, a morphing sequence from my face to Lin’s was created with 45 intermediate images. The intermediate shape was created based on the warp_frac parameter and cross-dissolves the pixel values according to dissolve_frac. By varying these parameters across frames, I generated a continuous morph sequence from my face to Lin’s with both shape and appearance transitions smoothly.
Using the spatially normalized happy face data from the FEI Face Database, an average happy face was generated. The average shape was calculated by averaging the correspondence points across all faces. Each face was then warped to this average shape (examples shown below):
Then, final average happy face was obtained by averaging the pixel values of the warped faces. In addition, 1) My face warped into the average geometry, and 2) the average face warped into my geometry were also displayed.
A caricature was created by exaggerating the differences between the original face and the population mean. The keypoints were extrapolated by scaling the difference between the original keypoints and the mean, and the face was morphed to these new keypoints, with positive alpha exaggerating my feature, and negative alpha exaggerating the population mean feature.
I experimented with changing the gender of my face by morphing my face to match the average Chinese male face. First, the set of correspondences are first defined on both images. Then, I tried 1) only morphing the shape by warping my face to match shape of the average Chinese male face, 2) only morphing the appearance which is done by warping the average Chinese male face to match my face shape and then cross-dissolve the pixel values. 3) morphing both shape and appearance to obtain the final result.
I also created a series of transformation from my childhood photos to now by defining the same set of correspondence points for each photo and warping and cross-dissolve between the adjacent ones: