In this assignment you will implement and experiment with Beier and Neely's morphing algorithm to be discussed in the lecture and the upcoming tutorial.
The goals of this assignment are:
While the due date for the assignment is 2 weeks away, it is strongly advised that you read the paper and go through the supplied code in the next 3-4 days, and then begin coding as soon as possible. As usual, plan to spend some time looking at the code already supplied (methods, classes, etc), as you will have to depend on it for your implementation.
For this part of the assignment, you will be implementing the method as described in the paper by Beier & Neely's 1992 paper on "Feature Based Image Metamorphosis" covered in class next week. Given two source images, I0 and I1, the user specifies a set of corresponding lines in them to establish correspondence between "features" in one image and "features" in the other:
These corresponding "line pairs" are then used to warp the input images so that pixels "follow" the lines closest to them. To produce an intermediate image between I0 and I1, the line pairs are interpolated to create an in-between position for the lines. This is done using linear interpolation with a single interpolation parameter t. In this interpolation, t=0 produces a set of lines whose position is identical to that of image I0 while for t=1 they are identical to image I1.
Warping the source images toward this interpolated set of lines produces two images, WarpedI0 and WarpedI1, shown here with the interpolated lines overlayed:
Here are the same images without the interpolated lines:
The final morph is just a blend between the two images using t as the blending parameter:
The main component of the morphing technique is an image warping algorithm called Field Warping that you will have to implement. First, read through Beier & Neely's paper to understand the overall method and the context. Again, as in Assignments 2 and 3, an important skill that you will need to develop while reading research papers such as this one is to focus only on those parts of the paper that you must fully understand to complete the assignment---you can ignore parts of the paper that require background knowledge you don't have, or you can ask me or the TAs to explain those parts of the paper in more detail. Specifically, read Sections 1 & 2 for background and motivation behind the work. The Sections you are asked to fully understand and implement are Sections 3.2 and 3.3.
For this part you will have to do the following:
I suggest you use the above order in tackling these tasks. Specifically:
The helper code is packaged into the tarfile warp.tar.gz. The following sequence of commands will add files to your existing CS320 directory under your home directory on CDF and will unpack the code:
> cd ~
> tar xvfz warp.tar.gz
> rm warp.tar.gz
This will create the directory ~/CS320/Assignments/Warp along with files and subdirectories needed for the assignment. All the code that you turn in should be in those directories as well, exactly as specified in the details below. The relevant pieces of the code are in the directory src/morphing.
The goal of this part of the assignment is to implement the two core routines of the Beier-Neely morphing algorithm. The supplied source code adds a lot of "machinery" for interactively manipulating and editing lines, and visualizing the morphing results. The good news is that this code contains all the necessary graphical user interface that is necessary, so you can focus only on what really matters: the morphing algorithm itself. In this respect, the supplied code mirrors the implementation of the inpainting code from Assignment 2 and 3, the file morphing.cxx handles all the mundane interface-related code and the basic defintion of the morphing class, and you can pretty much avoid studying it too closely as long as you know the "specs" of the various methods in file morphing/morphing.h. The three files to look at closely are morphing/morphing.h, morphing/linepairs.h and morphing/morphing_algorithm.cxx (which is where your code should go). The top-level routine that calls your code is morphing.morph_iteration(), also located in that file, which runs the morphing algorithm for a single setting of the parameter t and saves the results to disk. Your task is to implement two routines: the morphing.field_warp() routine that implements basic field warping as described in the paper and morphing.compute_morph() which combines two warping steps and a cross-dissolve to compute the final morph for a given value of t. Compared to Assignment 3, there is somewhat less code to write, although you should try and take efficiency into consideration because the field_warp() routine can be very slow if not implemented carefully. There may be points deducted for unreasonably ineficient implementations.
viscomp -no_gui -morphing -msource0 <I0> -msource1 <I1> -mlines <lines file>
to save the results to disk, use the following additional flags
-mwarp -mbase <basefilename for results>
the first option above makes the program output the warpedI0 and warpedI1 images as well.
Type 'viscomp -help' to see the other options, that allow setting the algorithm's parameters, and creating a whole sequence of morphs between images I0 and I1. You can try converting such a sequence into a movie with a sequence-to-movie converter program (e.g. the program mpeg_encode on CDF allows you to create mpeg movies from image sequences). This is not a requirement, but it would make you appreciate your results (and any potential warping/morphing bugs you may have) more clearly.
See PartB/README_B.txt for details.
This is your chance to run wild :) and try to do something creative with the 4 implementations you did in this class (alpha matting, inpainting, blending, warping).
You have two mutually exclusive options (i.e. choose either, but not both):
Important: The bonus part is no substitute for the actual assignment! Submitting a half-finished Morphing implementation with a really cool visual effect does not mean that you will automatically get bonus points to substitute for deficiencies in your Morphing algorithm. The final determination of how many points you will receive will be made in light of what you implemented for the Morphing section. My suggestion is that you do not tackle this part until you have the Morphing part in reasonably good shape!
If you make a claim for bonus points, you must provide good documentation/evidence (eg. images, comments and details that explain level of effort in image acquisition or coding) to support your claims. Put all of this in the partC directory.
Once you are done with the above, edit the file 320/Assignments/Warp/CHECKLIST.txt (also available here) to specify which components of the assignment you have completed, along with notes about parts that you were not able to complete, if any.
Pack up your portion of the code with the following commands:
> cd ~/CS320/Assignments
> tar cvfz assign4.tar.gz Warp/CHECKLIST.txt Warp/partB/{README_B.txt,*.jpg} Warp/partA/bin/viscomp Warp/partA/src/Makefile Warp/partA/src/morphing Warp/partC
Finally, you should use CDF's assignment submission system to submit your assignment:
> submit -c csc320h -a Assign4 assign4.tar.gz
Note that the system has been configured (1) to accept only files whose name is assign4.tar.gz and (2) to not accept submissions that are more than 4 days late. Just do 'man submit' at the unix prompt to get more info on this process.
In evaluating your assignment, the first thing we will look for are the files CHECKLIST.txt and README_B.txt.
Then we will make sure that your code compiles (just by typing "make" in the partA/src directory).
Then we will run your code on test examples in both the interactive and the non-interactive modes.
Finally, we will look at your code. It must be well commented: if the TA has doubts about the correctness of a specific implementational feature and there is not enough documentation/comments for the TA to decide, you will lose points. Good luck, and I hope you learn a lot and enjoy doing this assignment!