Assignment #4
Due Friday, Mar 24 , 11:55 pm
-----------------------
Submission
Submit your source code file(s), and a word or pdf document answering the questions below on WebCT and make available on the web the executable version. Do not make your source code available on the web! Include, in a comment in the source code, the URL where the executable version can be found. Also, you must allow directory listing for the location where your applet is posted on the web. In particular, there must not be an index.html (or index.htm) file in that directory.
Note that you may do multiple submissions of the assignment on WebCT, but only the last one will be marked, with late days corresponding to it's submission date/time. Also, to do multiple submissions after the due date, you may have to contact me to remove your initial submission before you can resubmit.
Note that all assignments have due times as well as dates (although I usually do allow at least a few hours grace period).
-----------------------
Description: Motion Compensation
You are to write an applet, in Java, to demonstrate motion compensation, as is used in various forms of video compression. You are provided with two frames from a video, a reference frame and a target frame.
You should display both the target and reference frame, the approximation that is computed using the motion vectors, and the difference between the target and the approximation. You should also print out the motion vectors on the console.
You may use any search algorithm you choose, either one of the ones discussed in class, or any of the more advanced ones discussed here.
Once you have your assignment working, run it again with the reference and target frames swapped. Which one of these looks like it would result in better compression? Why?
-----------------------
Tips
Here is source code for a Java class to compute the error between two macroblocks. Note that it works with a one-dimensional array of pixels, but if you are working with two dimensional arrays, the changes are trivial.
Although you can use a PixelGrabber to extract blocks of pixels from an image, this may be very slow, so it might be better to grab the whole image into an array, and then write a utility routine to grab blocks from the array.
Ideally, you should compute motion vectors for all the macroblocks in the target image. However, because this may be too computationally intensive, you may limit this to every n-th macroblock, where you choose n so that your applet runs in a reasonable amount of time (if you have to make n larger than five, e-mail me to let me know). If you skip computing macroblocks, then just use the last motion vector you computed for the ones that you skip.
Unlike in real video compression, you should always compute a motion vector, even if you can't find a good approximation.
The "error image" you compute may include negative values, since it is not really an image, but a difference of images. You should take the absolute value of the red, green and blue values before displaying the error image.
When you calculate the difference of two images, make sure you subtract the red, green and blue values separately, and not just the integer representation of a pixel.
You can assume that the image dimensions are evenly divisible by sixteen, which simplifies things slightly.
-----------------------
|