Faking 3D, part 1

January 7, 2010

I recently had the pleasure of playing a computer game, for the first time, in 3D.

The game was Trackmania, which also has a free edition available. The 3D feature can be activated when you pause the game, and it turns the picture into an anaglyph for red-cyan glasses, which are bundled with the game if you buy a copy, though you can get them cheaply at a number of places online.

Even with the old-style coloured glasses, the effect is rather stunning.

It’s not a monochrome image, because the cyan filter (for the right eye) transmits both green and blue, so you can make colours by changing the ratio of green and blue in the right-eye image (making you feel like a dichromat!) Even the uncomfortable feeling that you’re focusing two images of different colours starts to fade after a while, as your eye and brain adjust the hues that you perceive – try looking through one eye after wearing the glasses for a while!

This set me thinking about all the 3D video technologies that have sprung up over the last few decades, and are achieving a renaissance more recently. And there’s a lot of science behind them! Although all the major 3D schemes are listed in the Wikipedia article, it’s hard to find a straightforward representation of how they all work.

The idea of stereoscopy is to make each eye see a slightly different image, so if you want to focus on one feature of the image with both eyes, you have to go either cross-eyed or wall-eyed, as you would if you were focusing on something closer or farther away. Then, your brain furnishes you with the 3D illusion by translating the directions of your eyes into a feeling of depth.1

The only differences between the systems are how they show different images to your two eyes. Let’s explore them, starting with the coloured glasses.

Fig. 1: Anaglyph TV, with coloured 3D glasses

1. Coloured glasses block some colours (wavelengths) of light from entering each eye – an anaglyph is just a red image and a cyan image on top of each other. For red-cyan glasses, the colours transmitted from the visible light spectrum into each eye are something like the picture below:

Fig. 2a: The transmitted spectrum of red-cyan 3D glasses

But any pair of complementary (non-overlapping) colour filters will do, and there are several variants around that give you different experiences of colour. For example, there is a rather smart form of colour filter used by Dolby, that lets in several “spikes” of colour to each eye:

Fig. 2b: The transmitted spectrum of Dolby 3D glasses

Because both filters let in a mix of colours from the spectrum, neither of the glasses looks visibly tinted, and you get to experience more colour in the 3D image. Even better, if the projected image you’re looking at contains exactly the right frequencies to be transmitted by the glasses, the screen will seem much brighter than the daylight or the surroundings!

2. Other schemes like RealD use glasses that filter polarisation, not colour. To understand polarisation, you need to know that light is a transverse wave – like the waves on water or a guitar string, the up-and-down motion is in a different direction to the direction the wave is travelling.

In a water wave, it’s the water’s surface that moves up and down; on a guitar, the string itself moves up and down. In a light wave, there are electric (E) and magnetic fields (H), little arrows which point at right angles to the direction the light travels.


Light and its electric and magnetic fields

We usually just think about the E-field (the H-field always points perpendicular to it). In real white light, the E-field in the light rays approaching your eyes will be waving around rather chaotically, all over the place.

Fig. 4a: The electric field of unpolarised light

But what if we could separate the up-and-down movements from the left-to-right movements?

Fig. 4b: Linearly polarised light

The two types of light are called linear polarisations, because the E-field’s arrow moves along a straight line. You can separate them out using a sheet of Polaroid plastic, which contains tiny needle-like bits of metal, all aligned in the same direction – say the . Inside the needles there are electrons, which are dragged around by the electric field, and this has the effect of stopping the E-field in one direction.

A polarised 3D projection system (Fig. 5) requires two projectors, with x and y polarising filters in front of them – or a single projector where the polarisation can be rotated between frames. It must also have a screen which reflects the light to you, but leaving the polarisation intact.

Fig. 5: Polarised 3D projection system

To confuse things a little, RealD films don’t use linear polarisations but circular ones. You can understand these by thinking about the movement of the E-field: sometimes it will momentarily tend to turn clockwise, other times anticlockwise. Circular polarisations rotate in only one direction.

Fig. 4c: Circularly-polarised light

The projector generates frames containing only left (L) or right (R) circularly polarised light, and the screen reflects the light back to the viewer. Then, the glasses only allow one circular polarisation through.

But how can we deal in circularly polarised light? In two easy steps. First linearly polarise light, then shine it through a quarter-wave plate which converts linear to circularly polarised light. The glasses have another quarter-wave plate on the front surface which converts circular light back to linear, and then a piece of Polaroid which transmits ony the correct linear polarisation.

Circular polarisations have one big advantage: you can tilt your head sideways while you’re watching the picture, and nothing will appear to change. Using linearly polarised light, if you tilted your head away from horizontal, the right-eye image would start to leak into your left eye (and vice-versa), which spoils the 3D effect.

More coming soon…

– – –

1 All forms of stereoscopy have a limitation that stop them looking quite like a real 3D object: the light rays are always emerging from pixels that are the same distance from your face. In order to form a clear image on your retina, the lens in your eye needs to focus by changing shape – a different shape for every distance. Your perception of depth is about yuor lens, not just about pointing your pupils in the right directions! Importantly for pirates though, even people with one eye can still perceive distances to some degree.


report writing

May 16, 2009

I’ve settled for a “sketchy” understanding of the vast amount of literature that relates to my project. This has let me try to remember the take-home messages of a hundred papers or so, piece them together and attain a certain level of “proper” conversation with my supervisor. But it’s not helping with the literature review part of my report, which demands quite a lot more precision.


some physics, why not

May 8, 2009

Mostly for my benefit, I’m looking for a simple way to compare the canonical and grand canonical ensembles in statistical physics. How about this…

– – –

The canonical ensemble is a load of “systems”, each of which has a set of energy levels, and can exchange energy with all the other systems.

The probability of a system being in the ith state, whose energy is E_i, is:

P_i = \exp(-E_i / kT) / Z

where Z is the system’s partition function.

The systems don’t have to be identical, but different systems have different Z’s.

– – –

The grand canonical ensemble is a load of “systems”, each of which has a set of “legal” particle numbers: N_1, N_2, N_3, … (probably 0, 1, 2…) and has a set of energy levels for each particle number, and can exchange energy and particles with all the other systems.

The probability of a system being in state (r,s), meaning it has N_s particles and total energy E_r, is:

P_{r,s} = exp(-E_r - \mu N_s) / X

where X is the system’s grand partition function. \mu is called chemical potential. Now to explain that…

One in a thousand

January 30, 2009

Say that one in every n people has some rare, special quality. (For argument’s sake I’ll use albinism – but it works for anything, visible or not, and it doesn’t even have to be people.) After you meet n people, what is the chance that you’ve met an albino?

You could be tempted to say it’s a near certainty. After all, if one in a thousand people are albinos, you expect to have met one after 1000 people, two after 2000 people, and so on…

But in truth, the answer isn’t 1: it’s around 63%, or 1 - 1/e.

Surprising? What if you were to then meet a further n people? Then you’re quite a lot more likely to have seen an albino – 86% or 1 - 1/e^2 – but still not guaranteed. Only after meeting 3n does the likelihood reach 95% – so you can safely say you’ve “probably” met one.

The maths behind this is below; it’s not hard, but not terribly gripping either. But it does (sort of) give the lie to a lot of casual remarks you might make, or hear in advertising campaigns.

For example, you may surf ten websites without ensuring yourself a malware infection (especially if you choose wisely.) And if you have three friends, it doesn’t have to be true that one of them will experience cancer.

But in a crowded room, it can still be sobering to choose your favourite statistic and map it on to your fellows.

– – –

The probability of one randomly-assigned person being albino is 1/n, so the probability that they aren’t is (1 - 1/n).

Drawing n people from a world population of 6 billion, we can assume the composition of the pool isn’t changed by each draw – and so we use unconditional probabilities. After an draws, the probability that none are albino is (1 - 1/n)^{an}.

Thus, the likelihood of finding one or more is P_{n,a} = 1 - (1 - 1/n)^{an}.

As n increases, this converges quickly to a limiting value, which we find by taking the limit n = \infty and taking the logarithm:

\ln (1 - P_{n,a}) = n \ln (1 - 1/an) \approx n [-1/n] = -a

where we use the approximation \ln(1+\delta) \approx \delta. Hence P_{n,a} = 1 - e^{-a}.