In this assignment I implemented the warping algrithm and created a video of morphing images together.
In the first part of this project, I use ginput() to pick 50 points, in addition to the 4 corners, and save them into a txt file so that they can be loaded the next time I use them. The points are selected in the same order so that they correspond to each other. Then I used Delaunay triangulation to the midway of the two point sets with consistent labeling. This is completed with the Delaunay function.
|My Face||Another women's face|
In the second part of the project, I used the two images to do a morph at the midway. I first find the average shape by taking the average of each correspondance in my point set. Then I implemented a computeAffine function that outputs a transformation matrix between pairs of triangles, and then inverse warp all the pixels using RectBivariateSpline (interpolation). Polygon only checks the pixels inside the polygon so that I do not need to loop over pixels.
The original A and B images and the mid-way face are shown here.
|Original A||Mid||Original B|
In this part I implemented a morph function to generate a warp between 2 images. I used a loop to generate a sequence of morphed images with different fracs. Then I used https://ezgif.com/maker to make the gif.The sequence is generated by first setting both hyperparameters to 0, and then increase by 1/44 in every iteration. In the end both of them are 1.
|Average Face||Me to Average||Average to Me|
|Average Face||Female to Average||Average to Female|
In this part, I produced a caricature by taking the difference between the first female face and the mean female population face, and then multiply it by a factor and add back to the face of the first female. The reason that I did not use my own photo is because my own photo has an alpha channel causing the difference in the dimension of the images.
|Difference||Output = Original + different * 0.6|
I used the first male face in the Danes dataset and try to morph just the shape, just the appearance, and both. The algorithm I used is pretty much the same as in the previous parts, while the hyperparameters various to realize "only shape" and "only appearance". The output I get is as follows.
|Shape Only||Appearance Only||Both|