In this assignment we implemented an image morphing algorithm in order to morph one person's face to another persons. To do this morphing, we find corresponding points on both images and create a triangle mesh from the average of those points of both images. To morph the image we then interpolate the points from one image to another depending on how much we want to morph to create a midway image. Then for each pixel in the midway image, we find the triangle that it is inside and we find the corresponding pixel in the two people images using an affine transform. From those two pixels we then blend their color values to get the final result.
In my implementation, I found feature points by using the cpselect matlab tool. I chose the same points that we need to use for the mean image. I added the four cornerpoints of the image to each set of points to make sure that the whole image is morphed. Afterwards I calculated the delauny triangulation using the average of the points. Then for each morph, I precalculate the affine transform from each midway triangle to its corresponding triangles in the two images. Then I go through each pixel and find whether it is in a triangle using the provided tsearch function. If the pixel is not in a triangle I just blend the pixels in the same position. Otherwise, I use the precalculated affine transforms to find the positions of the pixel in the two images. Then I interpolate the color values of the pixels near those positions and lastly blend together the colors.
I vectorized all the operations except for multiplying the affine matrix. Because I could not find a way to vectorize that multiplication.
Morphing VideoDownload Link
|
|||
Mean FaceOnly 9 students data was available at this time. So the mean is only calculated on those 9.
|