Sometimes, you might want to take pictures with cameras further away from each other. This makes the object/expanse seem smaller than it really is, but renders greater depth information that can be used for analysis purposes or to allow us to see stereoptically over distances we normally can't (like a landscape) because our eyes are just too close together in comparison to the distance.
Anaglyphs - Types
There are a few different kinds of 3d glasses, but they all come down to the same principle: the display, in some way or another, shows both images, and it's the role of the glasses to filter the results so that the left eye sees only the left-eye component and the right eye sees only the right-eye component. Anaglyphs are a really crude method of doing this, but probably also the cheapest and the only way that works on normal media such as paper or a computer monitor (stereograms, stereoscopy or ChromoDepth notwithstanding).
Red/cyan anaglyph glasses filter out the image so that the left eye sees only the red component of the image and the right eye sees only the blue and green components. Thus, to produce a red/cyan anaglyph, you take only the red channel of the left-eye image and add to it only the blue and green channels of the right-eye image. This, of course, immediately results in an insane psychalgia of binocular color rivalry, but it does work.
Red/cyan (aka IYF) isn't the only option for anaglyphs. Other flavors of anaglyph are:- Red/green: this completely excludes blue, so you can have red, green, black, yellow, reddish yellows and greenish yellows, but nothing else. Not very good for skin tones, unless, perhaps, you're a Simpsons character. Works better with printing (as in children's books and comics) than computer monitors because the green of computer monitors leaks through the red filter.
- Green/magenta (aka TrioScopic): should be about as effective as red/cyan; I don't know which is better, but since our eyes are most sensitive to red, it should be a better channel to single out in opposition to a combination of the other two channels with regard to lightness rivalry. On the other hand, red is the worst color when it comes to definition -- especially when using paper glasses -- so it may not be the best color to restrict a whole ocular to.
- Red/blue: completely excludes green. Not as good as red/cyan.
- Blue/yellow: yellow is red+green, so this covers the whole gamut, like magenta/green and red/cyan do. It's somewhat newer and might be better than red/cyan, but is apparently less popular than amber/blue. (There may not even be a blue/yellow, except as another name for amber/blue. I'm not sure yet.)
- Amber/dark blue (aka ColorCode 3D): Full-color and shows red better than red/cyan, but can only be viewed well in a dark room, and apparently some skill on the part of the anaglyph maker is required to make blue and yellow show up. One person claimed that green/magenta is better than amber/blue because not much detail is carried in the blue channel on most video systems. One of the benefits of amber/blue is that we're least sensitive to blue light, so a amber/blue anaglyph appears more like a normal picture when viewed without 3d glasses. The blue filter passes 450-nm wavelengths, and the amber filter passes wavelengths ≥ 500 nm, which is red, green and a little bit of blue, so calculating left/right colors for ColorCode isn't as simple as just separating sRGB channels.
- Red/clear: Not really popularized. See an example at http://abdownload.free.fr/Anaglyphs/13/13987_Body.html
- Dark red/cyan+a little red (aka Anachrome): Like red/cyan, but the red is darker and the cyan lets some of the red through. Shows red better than red/cyan, but the image is darker and there's more lightness rivalry. This is a little-known format.
Red/cyan seems to be by far the most popular nowadays. One caveat regarding red/cyan is that for some reason the eye doesn't focus on the red perfectly, thus giving the left eye less detail. Only the non-paper (plastic) variety of red/cyan glasses, which you have to pay for, lenses the red side to correct for this problem. Also, red hues show up really badly with red/cyan.
In case I didn't make it clear, the method used to create the anaglyphic image must correspond with the colors used in the glasses, so the crux here is that the user won't be able to appreciate your production if they don't have the kind of glasses your application requires. (Some cases might be "good enough," such as viewing a red/blue anaglyph using red/cyan glasses and vice versa, but some mismatches won't work at all.)
As of this writing, 3D HDTVs (using shutter glasses) are just coming out. I hear that some graphics cards have HDMI output, so it might not be too difficult to use a 3D HDTV as a computer monitor. However, HDTV-3D viewing requires twice as many frames per second (120), and I'm not sure if current HDMI-capable graphics cards support that. I'm not even sure HDMI supports that. But even if not, it may become a possibility in the near future, and this would be a *much* better alternative than using anaglyphs -- except that you *may* need either total control of the device (such as in full-screen mode), or for the OS to be 3D-aware.
Anaglyphic Perspective Projection
In a nutshell, it's the algorithm I explained in "Flat Perspective Projection," except that you create two images. In one, D is 1.25" left of center of screen, and in the other D is 1.25" right of the center. This is because human eyes are, on average, spaced 2.5" apart (though yes, it does vary). The fact that the user's eyes won't necessarily actually be positioned along the lines of Dleft and Dright doesn't really matter...much. For a red/cyan anaglyph, remove the blue and green channels from the left image and remove the red channel from the right image, and combine the results. (Generally red/cyan glasses have red on the left. That's not because the original patent had red on the left, but because it didn't.. :P)
Just apply the logic given for a flat projection to the above model, once for each blue line. That's all there is to it. The formula automatically accounts for things with a negative depth, too -- i.e., things that pop out in front of the screen.
For any of the other type of anaglyph glasses, it's pretty much the same idea: just restrict each component image to whatever channels the filter for that eye passes. So for green/magenta, for example, have its left image restricted to the green channel and its right image restricted to the red and blue channels, since red+blue = magenta. An exception is amber/blue, for which the formula is this: restrict the left channel to red, and for the right use no red or green but make the blue channel red*15%+green*15%+blue*7%. Why? I dunno. Also, an alternative way to color for red/cyan glasses is that, for the red, instead of just taking the red channel you use the overall lightness of all three channels (as if saturated to greyscale). I don't know what the difference it makes is.
There are a number of advanced techniques some have developed for making anaglyphs which reduce lightness rivalry, reduce "ghost images" (due to cross-leakage of color), improve color rendition, etc. I don't know much about them, but here are the links I have.
Motion-tracking??
Obviously as a person moves their perspective changes, so ideally so should the image being displayed. Can you imagine the 3D image looking fixed in space no matter how you move? You could even look at it from a different direction to "look around" an object.
3D glasses happen to be almost ideal for tracking using just a webcam and a somewhat straightforward algorithm. Just scan the image for a pure red blob (intensity-variant), then scan proximally to that for a pure cyan blob.
Distance between the red and cyan blobs will tell you distance from the camera.Their location in the field of view (combined with distance) will tell you where the glasses are actually located, which will give you Dleft, Dright, and viewer_distance
. Angle between them will tell you if there's any rotation, i.e. if their head is cocked. If there is then the two D's could equally be rotated around each other so that the 3D still works, but I think it would require the use of sine and cosine in the projection formula, making it slightly more complicated.The person can also change the way he's facing, which would be indicated by skewing of the shapes. You don't really need to know the way he's facing for its own sake, but this has to be watched out for because skewing could easily be misinterpreted as further distance from the camera using a more naive algorithm.
It would be a bit difficult to pull off, but possible and would make for a really impressive display. Some caveats, though:
- You'd have to know where the camera is positioned or have some calibration method to be able to determine where the glasses are. A calibration method might involve telling the person put their face in a certain spot and then click. Otherwise, an educated guess that they start off at normal viewing distance and in line with the center of the screen might at least have cool, if mildly inaccurate, results.
- You have to know the camera's angle of view. That, together with its current resolution, will allow you to make meaningful size and distance inferences. I don't know if there's a way to find that other than looking up the specific model. A typical guess for this might work somewhat, not sure.
Making an assumption based on the calibration frame might also work, at least if the camera is in a predictable spot like centered on top of the monitor. (Calculate distance from camera using assumed viewer distance, monitor dimensions and camera's location relative to the monitor, then based on assumed distance between color filters, distance from camera and pixels between the filters, calculate the camera's angle of view per pixel.)
- You may want to use a camera resolution that supports at least 30fps. Otherwise the display update will be too jerky and that's just lame. However, the lower the resolution you use the less finely you can deduce position. That's probably less of an issue -- a little bit of position-inaccuracy will be hardly noticeable.
This method could apply to normal visualizations as well as 3D. Somebody's actually done something similar on the Wii (not in 3D vision), but by switching the roles of the controller and the sensor bar and wearing the sensor bar on his head, rather than using a webcam. It's pretty neat and he made a little test program for it:
http://www.youtube.com/watch?v=Jd3-eiid-Uw. HOWEVER I DID NOT GET ANY OF MY IDEAS FROM HIM. :P`