ANAGLYPH
by Alan Po
Table of Contents
- Introduction
- Design
- Results
- Source Codes
- Acknowledgements
- References
Introduction
When looking at a 3-D object, the image seen by the left eye is slightly different from that
by the right eye due to the little separation in-between. Such pair of images are called
stereo images. Anaglyph is generated by superimposing a pair of stereo images that are
printed in two different colors, usually red for the left image and blue for the right.
When viewed with special glasses that have the corresponding lens colors, red on the left and
blue on the right () for instance, the 2-D anaglyph image appears to be a 3-D object. This
phenomenon can be explained by the fact that the red lens, through which the left eye views,
allows only red light to pass through. Therefore, having a red image and a blue image
printed on a black background, only lights from the red image passes through the red lens into
the left eye, while the blue image just appears black and becomes indistinguishable from
the background. As a result, the left eye sees only the red image that stands out of the
black background but not the blue one. The same thing happens to the right side except that the colors red and
blue are interchanged. In other words, using such special pair of glasses, each eye sees
only the image that is supposed to be seen when viewing the 3-D object; and this causes the
viewer to interpret the 2-D anaglyph image as the original 3-D object.
Design
To generate an anaglyph, the first thing to do is to produce a pair of stereo images, which
can be accomplished by using the camera module in the
Data Explorer (DX).
The camera positions, one for the left eye and one for the right, can be calculated by
vector manipulations. Suppose we are given the vectors from,
to, and up, which are the position of the mid-point between the two eyes,
the up vector of the camera, and the position of the 3-D object respectively. We can then
obtain a unit vector going from from to the position of the right eye by doing cross(
up, (from - to)) / mag(from - to). Therefore, the
positions of the left and right cameras can be found to be from - separation * cross
(up, (from - to)) / (2 * mag(from-to)) and
from + separation * cross(up, (from
- to)) / (2 * mag(from - to))
respectively, where the scalar separation is the distance between two eyes. Having the two
cameras in place, we can generate a pair of stereo images which are then turned into different
colors, usually red for the left image and blue for the right image; and finally, the two
stereo images are superimposed to give the anaglyph image.
The anaglyph macro takes as input the renderal and camera outpus from an image
module that contains the desired object, and then generates an anaglyph image from it.
The eye separation, colors of left and right lenses are defaulted to be one-tenth of the
distance from the view point to the object, pure red and pure blue respectively;
nevertheless, all three of them can be set by the user.
Since the lens colors vary for different pairs of 3-D glasses, a program is also
written for color calibration. Such program produces an image with the word "left"
printed in one color and the word "right" printer in another color, where both colors
can be adjusted by user to match the color of a particular pair of 3-D glasses. Up
to a point where the user's left eye sees only the word "left" and the right eye sees only
the word "right", the colors will be correctly matched. Since it is more convinient to interpret and adjust colors in the HSV space
than in the RGB space, the calibrator allows the user to input HSV vectors which are then
converted to their RGB counterparts and displayed for user's convinence. Using the
results from the color calibration program instead of the default colors will improve
the quality of the anaglyph produced.
Results
Apart from the anaglyph macro, I also wrote a test program that creates an image of
a torus and generates an anaglyph image from it using the macro. Below are the
images of the original object and it's anaglyph. The default eye separation and lens
colors are used. To view the anaglyph, put on the red-blue 3-D glasses,
red on the left and blue on the right.
The original image:
|
The Anaglyph:
|
Source Codes
- The macro
- The color calibrator and it's configuration file
- The test program and it's configuration file
Acknowledgements
This project is written under the instructions of
References
- [1] Quadric Surface Macro by
Professor Bruce Land
- [2] Stereo Camera Macro by
Professor Bruce Land