![]() |
comp 235: The one true way! |
| Purpose | |
|
The one true way for understanding projections can easily applied to projection problems. The projection formula becomes intuitive with some practice. My experience: I have pictured the Russ
Taylor data points so much that I see the image when I close my eyes. Spooky.
|
|
| Table of Contents | |
| The one true way | |
|
The projection calculation translates real world coordinates to coordinates in the image plane. Here is the projection formula. A sample data set of points representing Russ Taylor's head will be used to explain the projection calculation.
All units should be converted into image plane units, which usually means pixels. Scaling Russ's world coordinates by 20 pixels gave good pictures in the 256x256-image plane. Trial and error will determine the scaling for other data sets. The y-x axes define the image plane (x-axis being vertical). The z-axis is positive toward the viewer. Matrix P describes the camera viewing the 3d world objects. The first two columns represent the image plane as unit vectors (one unit being 1 pixel). The third column is the position of the viewer relative to the image plane, which I made perpendicular to the image plane. A non-perpendicular vector would skew the project as it is off axes. The perpendicular length to the image plane from the viewer is the camera focal length. The optimal length for this setup is between 50 and 400 pixels. The cop vector (center of projection) relate the camera coordinates to the world coordinates. I arbitrarily made Russ's head 400 pixels away from the camera. I rotate the camera around Russ's head always at the same distance from the center of his head. This requires rotating all information associated to the camera; the P matrix and cop vector. The cop subtraction shifts the world objects to adjust the camera's view. These computations result in coordinates in the image plane. The next step is to assign color to the coordinates. Color is determined by the intensities of light shining on it determined by the dot product of the light vector and surface normal at a given point. I assumed the light to be infinitely far away and therefore the vector is identical for each data point. Another dot product is needed to determine if the point is in the line of sight of the viewer. Many of these assignments are at first attempt implemented by loops by can be replaced by matrix operations. Matrix operations give incredible speedup to the rendering. The dot product can be thought as a combination of Matlab matrix operations. Assigning the colors and coordinates to the image plane is tricky but can be done be converting matrices with reshape, find, and sub2ind (see Matlab code for more information). The final image plane used ranges from
0 to 256 on both axes. The image is centered about the origin and a simple
shift can account for the difference. It is important to truncate coordinates
that are out side the 256x256 image plane.
The following are mpeg movies generated by Matlab that illustrate changing a given parameter. Rotation Movie: rotation about the head in two different orientations. In this case the light is always at close to the viewer to always have something visible. Lighting Movie: The position of the camera is kept constant by the light is rotated about Russ's head (two different orientations.) Focal Length Movie: The focal length of the camera is adjusted. The image size is inversely proportional to the resulting image. I think the rate of image size is proportional to sin/cos as the field of view is adjusted (fov greatest when image small). Notice the distortion in nose and cheeks. A user can experiment with different parameter
with the interactive GUI. The view orientation and focal length can be
controlled in this demo. A slider controls the focal length. Rotating the
axes of the 3d plot controls changes the camera orientation. Although maneuvering
the Matlab 3d plot is cumbersome, I orient myself by the blue box that
appears when the mouse is pressed over the plot. This plot replaces the
functionality of three sliders. The light source is always by the viewer
to simplify the interface.
|
|
| Matlab code | |
|
Matlab code for the one true way:
The following resources about points in space. Some books: Foley and van Dam, Chapter 5 "Geometrical Transformations" Rogers and Adams "Mathematical Elements
for Computer Graphics" Chapters 2
A UNC tech report:
Some nice web pages... http://www.cs.unc.edu/~mcmillan/comp136/Lecture15/hcoords.html http://www.maths.bath.ac.uk/~pjw/NOTES/graphics/node41.html
|
|
| top *
home
dorian miller, 8/16/2000 |