Using ginput I inputted correspondences for 2 images. I then found the average set of points that corresponded. Lastly, I used those average points to create a Delaunay triangulation. This way the triangulation is equally imperfect for each image.
To compute the midway face, I iterated through all the triangles in the triangulation. For each triangle, I computed a transformation matrix using the 3 (x, y)
coordinates from the original image's triangle and the 3 (x', y')
coordinates from the triangles from the average points. With those points, I applied linear algebra to find the a, b, c, d, e, f values of the transformation matrix.
With the transformation matrix T found, I then found T's inverse in order to perform an inverse warp. Applying T's inverse on all the (x', y')
points of the target image's triangles gave the (x, y)
value in the original image to sample from. On all the pixels within the triangle, I sampled the associated (x, y)
values in the original image and interpolated them to put into the warped image.
I applied the morph sequence by using the same method as the midway face, but by using weighted averages such that the weight towards the final image increased with time.
To generate the mean face of the population, I averaged all their correspondences to find an average shape and then morphed all their faces together. I then added up the images (warped in average shape) and scaled each one by 1/n
, where n
is the number of samples included in the mean.
Below are the outputs from generating a mean neutral face and a mean happy face using 50 samples. There are also some samples of images from the population that had their face geometry warped into the average face.
In the images where I warped my face with the mean face, I struggled with getting a good match, probably because the angle of the photo is slightly different, despite best efforts to recreate a photo that aligned well with the population.
Produce a caricature of your face by extrapolating from the population mean you calculated in the last step. This might work better on a gender specific mean or some other characteristics specific mean.
Using the mean face and my face warped into the average geometry from the previous portion, I created a caricature of my face. The left caricature darkened my face, since my face is a bit darker than the mean image. The left caricature moved my face closer to the mean image by making my face smoother like the mean image and removing my freckles.
0.6 * deviation
)
-0.4 * deviation
)
To modify gender, I first generated a mean image for men using 30 images and then a mean image for women using 36 images. I then used those mean images to generate vectors so that I could move my image in the more "masculine" direction.
In the appearance modification we see the emergence of a slight shadow on the upper lip. In the shape modification my face gets wider, especially around the jawline.