CS 631 Assignment #1
Due Date : Feb 22th 1999
Introduction
In this assignment, you will implement a morphing technique that was used in creating the face morphing sequences in Michael Jackson’s Black or White music video. The technique is first described in a paper titled Feature-Based Image Metamorphosis by Beier & Neely. You will read the paper and implement a program that produces image morphing sequences based on methods mentioned in the paper.
The paper can be found on-line at http://www.hammerhead.com/thad/morph.html.
Feature-Based Image Metamorphosis in a Nutshell
Morphing involves two main operations : warping and cross-dissolving. To morph from image I1 to I2, one would try to warp I1 to the shape of I2 and I2 to the shape of I1, and perform cross-dissolve between the sequence of intermediate warping images. When the dissolved images are put together and played back quickly, they will create the illusion of I1 gradually changing to I2.
The essence of this technique lies in how the warping is done, and the paper calls its approach field morphing. Field morphing involves using pairs of corresponding line segments to determine the answer to the question : "Which pixel coordinate in the source image do we sample for each pixel in the destination image?". How this question is answered is well detailed in section 3 of the paper. You should read and understand this section before you start to code your assignment.
Section 3.4 describes how morphing between two images can be done. It tells you how you can interpolate the line segments for intermediate frames, but it does not say how the cross dissolving should be done. However, it is not hard to come up with something sensible. One thing that you can do is to determine the color based on the frame number of the output image. For eg., if there are 10 frames total, and you’re doing output frame 3, the pixels will be 3/10th of frame 3 in warped I1 and 7/10th of frame 7 in warped I2.
Implementation Details
Your program again will have a simple command line interface that looks like the following :
> morph <start-image> <end-image> <line-seq> <out file name> <nii>
where <start-image> is the image that will morph into <end-image>, <line-seq> is the name of an ASCII text file will contain pairs of corresponding line segments defined as pairs of coordinate points, and <out file name> is the base name for the output frames.
Your program will output the number of intermediate frames as specified by <nii> and their frame numbers will be appended to the base <out file name>. For eg., if my <nii> is 10, then 10 intermediate frames will be produced, and let’s say <out file name> is "face", then my output frames will be called face1.pgm, face2.pgm, face3.pgm… face10.pgm. Note that the start and end images do not count as intermediate images.
Both the start and end image will be in the binary PGM format and they will have similar dimensions. You don’t have to worry about ASCII PGM images.
The <line-seq> file should look like the following :
<number of corresponding line pairs>
xL1,src,A yL1,src,A xL1,src,B yL1,src,B xL1,dest,A yL1,dest,A xL1,dest,B yL1,dest,B
xL2,src,A yL2,src,A xL2,src,B yL2,src,B xL2,dest,A yL2,dest,A xL2,dest,B yL2,dest,B
………………
………………
Each row will represent a pair of corresponding line segments. For the above file, (xL1,src,A yL1,src,A xL1,src,B yL1,src,B) will represent a line segment AB in the source image and it will correspond to a line segment AB in the destination image represented by the coordinates (xL1,dest,A yL1,dest,A xL1,dest,B yL1,dest,B).
For example, the following is a line segment text file with 3 line segments :
3
10 10 60 60 18 20 75 74
55 20 120 140 60 32 130 145
23 40 23 100 44 40 44 100
For this file, the line (10,10,60,60) on the start image will correspond to line (18,20,75,74) on the end image.
Instructions: