All the code were written in Matlab, including the GUI.
The critical
routines (McMillan's algorithm) could have been written
in C for
faster performance, but Matlab took a reasonable 1-2
minutes, so I did
not bother re-implementing it.
This assigment was harder than I first thought.
The main difficulty
was understanding the geometric relationships that governed
the view
transformation. McMillan's paper was too brief in this
respect.
Looking at his thesis did not help either. To further
compound the
problem, the image/depth data used (from Paul's conversion
routine)
employed a slightly different convention. For instance,
vvec pointed
up in the data file, but McMillan assumed it pointed
down.
I finally derived my own view transformation algorithm.
This is based
on my GUI which allows the user to fly around the object,
while
keeping the center of the object fixed. In other
words, the allowable
transformations are: rotation about the x and y axes,
and zooming
in/out. The 3D axes is constructed at a point roughly
in the center
of the image. I do not allow translation, and I
assumed that the
camera parameters were constant, i.e. the image plane
is a constant
depth in front of the center of projection. I was
then able to derive
the formula to map the coordinates of the reference image
to any new
viewing position.
Then, I employed Mcmillan's source-scan method to generate
the image.
I also compared it with a Z-buffer algorithm. They
both give almost
identical results, differing only in a few pixels.
Figure shows the absolute difference between
the images generated by McMillan's
algorithm and the Z-buffer algorithm. Black
means 0 difference. The colors
show the pixels which differ, with red being
the greatest difference, and blue being
the least.
For filling holes, I experimented with Gaussian masks
of different
sizes and widths. I finally settled on a 9x9 mask,
with sigma=3.
This was applied 3 times over the image. This successfully
removed the
small holes, but blurred the image slightly.
For more details of my algorithm, please email me at tsim@cs.cmu.edu