The first step of face morphing is to define the key points for the two faces that need to merge together. I made use of OpenCV instead of matplotlib since this step requires me define the points for two images in same order and OpenCV allows me to create multiple window simultaneously. Here is one set of key points I defined:
As discussed in the class, I first merged the two sets of key points I got above and averaged them into one to get the average shape of our faces. After that, I wrote the function that traverses every triangle I obtained in the previous step's triangulation and then computed the inverse transform matrixes base on the triangle's vertices. After receiving the inverse transfer matrix, I applied them to the pixels within that triangle and used the RectBivariateSpline function to sample the color.
Below are the result while the shape and color blend factor are both setted as 0.5 (so, a average).
For this part, I modified the morph function into a more general one so that the shape blend control is separated from the color one. By linear change both of the shape blend factor and color blend factor between 0 and 1, I obtained a morph sequence shown below (all the pics used to generate this gif is placed in ./morph_sequence):
I used the Danes dataset to get this part done. The first step is read in the key points and perform triangulation on it. Several additional points were added to cover the whole img and avoid generate too skinny triangles. Below is the triangulation result:
After shape mergeing, I averaged the color of all merged faces together and thus obtained the average Dane face:
And the two pics below shows the warp result of my face into mean population face and mean population face into my face (well, seems the algo works really hard to find my left ear...):
For this part, I first calculated the delta between my face and the average Danes face by subtract the key point positons of the mean face from my face, scale it a factor, and finally add it back to my key point positions. Below is the results I obtained:
I first tried to morph a human face into a Ragdoll cat but the reuslt is kind like a... horror picture... So I tried to change my gender instead, the reference image is the average south east asia female face:
Since the Danes face database helped me so much during this project, I chose to make a morphing video base on it to show my respect for all the 37 people who contributed to the Danes database. (There was 1079 frames generated, too big to include, here is the google drive link to access all the images: https://drive.google.com/drive/folders/1JZNU_U50jF5KPrLF2UGTgq_waALClb8m?usp=sharing)
And this link directs to the animated gif: https://drive.google.com/file/d/1lv8xkeaymxkYUn4pUnzQOyb-1YgSpluY/view?usp=sharing
Thanks for reading.