Project3 : Image Morphing

Part 1:Project Description

Image morphing is the process of simultaneous object shape averaging and image color cross-dissolving.
In the first step, we need manually define the correspondent points between two images.
Those correspondent points defined can be applied to control the every warped shape in the intermediate image.

Part 2: Face Morphing using Triangulation Mesh(morph.m)

To implement the image triangulation, one is need to divide the source image and destination image into several parts.
In this part, I use the triangulation method to do this. And the Delaunay triangulation method is a good choice because it does not produce triangle with too acute angle.
The Delaunay triangulation is computed based on the weighted warp of the shapes of the source image and destination image.
The next step is to calculate the distortion of each triangle of the triangulation from both source image and destination image.
I do this task use three steps:
1 For each pixel in the intermediate image, determine which triangle it is in
2 Compute its barycentric coordinates
Find equivalent pixel in corresponding triangle both in source image and destination image, and copy its RGB value.
The process can illustrated as such figures:

Experimental Results

I do the morphing experiment from 04-jinwei.jpg to 05-lei.jpg.

Part 3: Computing Mean Face (image_warping.m)

To compute the mean face, there are mainly three things involved:
1 Computing the average shape, it is done by averaging the correspondent points throughout all the images in our data set.
2 Warping all the faces into that shape, so we need to calculate the each distortion of the triangle.
3 Superimposing all the images and averaging the color intensity

This mean face is more like a man. Because in our data set there is only more boys than girls.
And the color transition from face region to background region is so sharp, so we can clearly see the border. May be some color smoothing method can be taken to improve it.

Part 4: Bells and Whistles

1 Image morphing using my own pictures

We can the morphing process is a little weird. I think the main reason for this is that the scale of face between me and superman is a little large.
And the superman nod his head a little which presents a different pose from my pose.

2 Image morphing experiments with objects and animals and other objects

Here the car-tiger morphing is much more better than man-tiger morphing. As is stated before, the more similarity the two shapes have, the better the result is.

3 Producing Caricature using mean face idea.

There may be several ways to produce the caricature effect.I tried the method of scaling the difference of the each shape of the faces.
When I use the mean face idea to produce a caricature, an unregular average needed. So I do the weighted sum of all the shape and average it.
This affects the shape. The weight vector is:[-0.1 -0.2 0.3 1 0.3 -0.5 0.1 0.1 0]

4 PCA basis: Eigenfaces

For each face can be represented as a linear combination of of orthogonal basis vectors. Here I compute the eigenfaces that maximize the variance of the data.

5 Feature-based Face Morphing(morph_field.m)

Besides triangulation mesh morphing method, there are some other alternative image morphing methods. Here I chosen the feature-based morphing method.
This method uses lines to make a connectiong between the features in the source image and the features in the destination image.
It is based on fields of influence around the two dimensional control points. It applies the reverse mapping as its ways of warping.

5.1 Transformation between one pair of lines

A pair of lines (one defined relative to the source image, the other defined relative to the destination image) defines a mapping from one image to the other

u is the position along the line, and v is the distance from the line.

5.2 Transformation between multiple pair of lines

Because there are many features in images between which multiple pairs of lines are applied.
And multiple pairs of lines specify more complex transformations. So we need to define a weighted coefficient for each line.
The weight assigned to each line should be strongest when the pixel is exactly on the line, and weaker the further the pixel if from it. So we define the weight equation as follows:

where length is the length of the line, dist is the distance from the pixel to the line, and a,b and p are constants that defined by users. We make it a=1 b=1 p=0.5

Pseudocode

Comparison with Triangulation mesh morphing method

As the morphing process proceeds, we can easily see that the color transition from face region to the background region is more smoothing in this method.
This method is more expressive and intuitive.
The disadvantage for this method is speed problems.
The complexity of this method is O(M*N*L), where M*N is the dimension of the image and L is the line segment that you specified. The more line you define, the slower is the speed.

Triangulation mesh morphing Feature-based morphing