Programming Project #3 (proj3)

Part 1

Here, I present two images where I marked points, along with the triangulation of these points.

My Face
Mom's Face
points_plot with triangulation
average_points_plot with triangulation

In one instance, I used `middle_points`, which are the average values of all points between the two images, and in the other instance, I used their respective points. It is evident that the triangles generated using `middle_points` slightly deviate from the features of the person, for example, the point that should be at the end of the eyebrow appears between the eyebrows. I used images of me and my mother, and I think this shows that except for the eyebrows, our overall facial features are similar, such as the positions of the eyes, nose, and mouth on the face.

Part 2

To compute the mid-way face between me and my mother, I followed the instructions and completed the following steps:

  1. Calculated the average shape for the points that I plotted on my face and my mother's face.
  2. Computed the affine transformation. Using the affine transformation, I calculated the matrix that transforms each triangle in image 1 to the corresponding triangle in image 2, determining how the image is warped.
  3. Implemented a warp function. In the warp function, I found the affine matrix and its inverse, applied the inverse affine transformation to map target pixels back to the source image, and used a polygon mask to ensure that mapped pixels did not exceed the boundaries. Bilinear interpolation was applied to get pixel values from the source image, and these pixel values were filled into the output image.
My Face
Mom's Face

Part 3

Using the warp function from Part 2, I implemented another function: `morphed_im = morph(im1, im2, im1_pts, im2_pts, tri, warp_frac, dissolve_frac);` This function allows me to generate a warped image with different warp_frac and dissolve_frac. By stitching these images together, I created a GIF showing the morphing process from my image to my mother's image.

Morphing GIF
GIF showing the morphing process from my face to my mom's face.

Part 4

In this part, I used facial images and point data from the `FEI Face Database` to calculate the mean face. While processing the images, I found that adding four points at the corners of the image helps with warping.

  1. First, I computed the average points from all images.
  2. Next, I warped each image to the position of the average points.
average_face

When I warped my image to the average face, I noticed my face stretched out. Similarly, when I warped the average face onto my face, the distances between my facial features shrunk.

my_face_to_avg_face
avg_face_to_my_face

Part 5

For this part, to create a caricature effect, I first computed the shape difference between my face and the average face, i.e., the difference in the key feature points. Then, I used a scalar value (alpha) to exaggerate the differences. Based on the newly generated caricature points, I warped the image to get the final effect.

caricature_image

Bells and Whistles

I found an average male face from China on the web. After aligning my face and the average male face, I used the morph function to create images morphing just the shape, just the appearance, and both.

Average Male Face - China
My Face - China
shape_only_image
appearance_only_image
shape_and_appearance_image