Information on Morphing Project

Chris Wyman



Algorithm

Below is a description of algorithm I used in the code for this project, as well as a decription of what files various parts of the program are in. (A hard copy of the code is attached, as I believe you requested).


The calculation is almost exactly the transformation presented in Feature-Based Image Metamorphosis from SIGGRAPH '92, found under the "Transformation with Multiple Pairs of Lines" category, so I won't repeat it in detail here. However, I found it had a few problems that I had to fix to get higher quality images.

First, I had to make sure to interpolate in my images, because at first, when adding 30% of pixel Pi,j from source1 and 70% of pixel Pi',j' from source2 (where i, j, i', and j' were just the results from the paper rounded to the nearest integer), the resuting images were extremely blocky, almost to the point of distraction.

Second, the paper only describes the transformation from one source to the final image, so I tried two methods for getting the correct pixel from the second image. At first, I computed a transformation (using the paper's technique) from source1 to source2. Then, after computing the mapping from the current frame to source1 I performed a lookup to find the corresponding pixel in source2. Unfortunately, this provided strange artifacts, blockiness, and a noticable "pop" before the last frame. To fix this problem, I decided to use the paper's technique twice for every frame (so it's significantly slower now), once to get the corresponding pixel in source1 and once to get the corresponding pixel in source2. This works significantly better and gives no pops in the video.

Features/Program Description

The program takes in up to 20 source images and morphs the first into the second, the second into the third, the third into the fourth, and so on.

The total frame count can be specified on the command line, as well as the parameters a, b, and p from the paper. The a parameter controls how closely control points/lines constrain the result. High values result in smoother results, close to zero ensures that points on a control line remain on a control line. The default is 0.1. The b parameter determines if all control points/lines affect the result of a point or if only controls close to the point in question affect it. The default value is 1.5 (useful range is about [0.5 - 2]). The p value should remain 0, since it adds another variable (line length) that I did not take into consideration when choosing my control points.

The default compilation outputs the morphed frames as files tmp0.ppm, tmp1.ppm, etc. By compiling using -D_INCLUDE_MAKEMOVIE_ on the command line, a movie will automatically be generated and the temporary PPM files removed. However, the -D_INCLUDE_MAKEMOVIE_ depends on running on an SGI with the 'makemovie' program available.

Run the program using "morph -help" to get a description of how to run it.

Effect of Changing the Number of Control Points

The algorithm I used for the morphing generally maps points near the control points to near the control points in the result. When very few control points are used, parts of the image far away from any control point tend to look more like a cross fade than a morph, however close to control points the result is a very natural morph.

Thus, for faces I typically used 20 or 30 control points for the best result. In a few cases, I got natural results from as few as 10 control points, but anything else looked more like a cross fade. However, adding too many control points often gave strange "stretching" effects in the resulting video.

Also, the positioning of the control points is very important. I found important boundaries in the image had to be outlined in control points in order to not give a "halo" area around the boundary that looked like a cross fade. An example of this was the outline of a head.

Results

Some of my results are available at "http://www.cs.utah.edu/~wyman/classes/imp/", and more will be up there tonight (since I forgot to FTP some of them back from my home computer). These are movies in Quicktime format (made with the 'moviemaker' program on SGIs). I have tested them and found them playable in the SGI program 'movieplayer' and also using a Windows copy of Quicktime.

Also, in the electronic copy of the code, I will include some sample command lines and image files to test out the program.

Bugs

I attempted to compile and run my program at home on my Windows box, and for some reason the PPM code is giving strange results. I know it works on SGIs, but other than that, I haven't verified that the output is correct on Suns or Linux boxes. But it might just be a strange Windows thing. (If you need a SGI to run on, try eiger.cs.utah.edu or elbrus.cs.utah.edu, both of which are in the grad lab, I believe.)