ULaval

HW3: Faces morphing (Part A)

GIF-4105/7105 H2017

Author: Henrique Weber

The goal of this assignment is to gradually morph one image until it is transformed into another one. In order to do that we can perform the following steps:

All these steps will be illustrated bellow together with the results.

Morphing

In this part I manually selected all the pair of points in the input images. Four aditional points were inserted in the borders of the images in order to guarantee the whole image would be transformed. Once the points were selected the Delaunay algorithm was used to create a triangle grid using the points as vertices.
Next the mytsearch algorithm was used to locate the triangle to which every pixel in the image was attributed to. In parallel, the affine transformation that takes one triangle from the source image and transform it to its correspondent in the target image was calculated resulting in a 3x3 matrix. As indicated in the exercise definition I used the inverse transformation to get appropriate RGB color for all points.
The last step is to morph gradually the images. For that two parameters can be changed gradually, namely the warp_frac and dissolve_frac. For the warp_frac I just linearly increased its value from 0 to 1. For the dissolve_frac I chose a logarithmically spaced function (in MATLAB logspace) to go from 0 to 1 so that it takes a while to start integrating the target image into the final result.

Result 1: Morphing between Henrique and Carl

In order to morph our faces I used the points provided by Carl and mine plus 10 points around the mouth in order to produce a better result. The only regions that remained badly alligned were the hair and the shoulder.




Source

Target

Average triangulation

Source "deformed" to target

Target "deformed" to source

Final morphing

Result 2: Morphing between Steve Tyler (Source) and a monkey (Source).

This was a good result since the image are quite similar and the color transition was smooth enough to create a good result. The only bad deformation ocurred on the monkey teeths where I put some points but could not achieve the result I expected.




Source

Target

Average triangulation

Source "deformed" to target

Target "deformed" to source

Final morphing

Result 3: Morphing between Old beetle (Source) and new beetle (Source).

This one did not give the result I expected. My guess is that since both objects are not in the same place in the image the affine transformation was too "strong" causing some undesired deformation on both images.




Source

Target

Average triangulation

Source "deformed" to target

Target "deformed" to source

Final morphing

Result 4: Morphing between Henry Waxman (Source) and Phantom of the Opera (Source).

This one was another successful result since the comparison between Henry and this old version of the Phantom of the Opera was made by someone on the internet, even with very similar pictures! Therefore it was not hard to get the feature points and morph both images.




Source

Target

Average triangulation

Source "deformed" to target

Target "deformed" to source

Final morphing

Result on my own photos 1: Morphing between spoon and fork.

In this example I thought that creating many points between the fork tips would create a nice transition but the result was really bad. What worked better in the end was to use a smaller number of points at the upper region of the cutleries.




Source

Target

Average triangulation

Source "deformed" to target

Target "deformed" to source

Final morphing

Result on my own photos 2: Morphing between flip-flop and leaf.

In this example both objects have the same background and even similar silhouette. Therefore the result was good and a little amount of points were necessary to create the desired effect.




Source

Target

Average triangulation

Source "deformed" to target

Target "deformed" to source

Final morphing

Bells and Whistles: morphing a low-pass filtered image with a high-pass filtered image.

Here I morphed the high pass filtered photo of Albert Einstein with the low pass filtered photo of Marilyn Monroe. Curiously the result in my opinion is worse than the original one and I believe this is because now both Albert and Marilyn are brought to a common image. In this case it is hard to spot Einstein from the high frequences and Monroe from the low frequences because they represent deformed versions of their original pictures.




Source

Target

Average triangulation

Source "deformed" to target

Target "deformed" to source

Final morphing

HW3: Faces morphing (Part B)

In this part of the assignment the goal is to find "mean faces" of datasets. By doing this we can also find a feminine face and male face and perform nice combinations!

1. Computing the "average face"

The average face shape of the class

The result for the average class face using the points generated by the students was pretty bad. Probably the point location was not accurate enough and as a result the standard deviation between the points was high.
On the other hand the result generated by the algorithm was much better! We can clearly see a face in there, and a male one since the class was mainly composed by men.




Average shape using points generated by the students.

Mean face using points generated by the students.

Average shape using points generated by the algorithm.

Mean face using points generated by the algorithm.

The average face shape of the Utrecht database

For the Utrecht database we were asked to use the algorithm that detects points automatically. It generates 68 points around the face and ignores the hair. It generated a clear face probably because we used a lot of different pictures.




Average shape of the Utrecht database.

Mean face of the Utrecht database.

Part 2: Masculinizing and feminizing your own face

In this part the idea is to morph my own image with the average of the men and the average of the women. Since the difference in the hair is too visible I decidec to crop it out for a more clear result. The difference between my feminine face, my masculine face and original face are quite visible! The feminine face tends to have more round shapes and the masculin more straight shapes, and also the masculine has a bigger nose than the feminine one. Another thing I found interesting is that the average masculine face was almost identic to the avereage face of the whole database!




Average feminin face.                                                

Morph between my face (50%) and the average feminine face (50%).

Average masculin face.                                         

Morph between my face (50%) and the average masculine face (50%).

Bells and Whistles

The average face of the At&T database (Source)

Just to check if the average face would differ that much by using a specific database, I tested on another dataset. This one has 10 pictures of 40 different people. The automatic feature points algorithm could recognize 390 out of 400 pictures. The average face differs a little bit from the Utrecht database but still keeps a similar shape.

Face of a man on the dataset.

Face of a woman on the dataset.

Average shape of the dataset.

Mean face of the database.

Changing my smile

For this part I took the average shape of the smiling faces from the Utrecht database and extracted its mouth (described by 20 points). I then replace the 20 points that represented my mouth by these points I extracted from the average face. I also translated these points to the centroid position of my mouth in order to avoid that my mouth got translated to the centroid of the average mouth. The result for the smile looks funny (looks like I'm being forced to smile) and the serious face looks weird (my mouth looks like serious but my overall face is still smiling).

Average smile face.

My face being forced to smile.

Average serious face.

My face being forced to be serious.

Principal Components Analysis (PCA)

Here the idea is to try to see the directions to which the data (in this case, aligned faces) changes the most. For that, we can extract the mean from all faces in the dataset, followed by the calculation of the eigenvectors and eigenvalues. The results are faces that better explain the dataset (in this case, the Utrecht database). It is interesting to see that different atributes are concentrated in some of the eigenfaces. For example a feminine and old appearance is present in eigenfaces 1 and 5 while a beard is most visible at the eigenface 4. Images are shown in grayscale since it simplified the pca calculation.

Mean face.

Eigenface 1.

Eigenface 2.

Eigenface 3.

Eigenface 4.

Eigenface 5.

Modifing the average face

Inspired by the work of Mark-Andre Gardner(Source) I decided to modify the average face of the database by adding the eigenfaces multiplied by a constant to account for the different scales between them. From the results we can see the most apparent atributes of the eigenfaces were nicely inserted into the average face. For example, the mean face + eigenface 5 has a aspect of a fairly old woman.

Mean face with eigenface 1.

Mean face with eigenface 2.

Mean face with eigenface 3.

Mean face with eigenface 4.

Mean face with eigenface 5.

Mean face with eigenface 6.