Reply to comment
Face to face
How would it feel to look in a mirror and see not your own reflection but instead how you would look as the opposite sex? You can explore this strange alternate reality at this year's Royal Society Summer Science Exhibition where Peter McOwan and his colleagues from Queen Mary, University of London and University College London will use mathematical wizardry to produce gender reversed images of faces.
Despite the crisp clear details and blended colours, a photo is just a series of dots, called pixels, of different colours. Any photo, including one of your own lovely visage, is represented in a computer as a long string of numbers, each representing the colour at a particular pixel. Just as a string of three numbers marks a point in threedimensional space (it gives its coordinates), so a string of N numbers sits in what mathematicians think of as Ndimensional space: so mathematically you can think of a photo as a point in an Ndimensional space, where N is the number of pixels in the photo.
McOwan and his colleagues are interested in how faces differ and so have gathered thousands of photos of different faces, male and female, young and old and of different ethnicities. After the photos are tweaked slightly to make the major features, such as the eyes, nose and mouth, roughly align, the points corresponding to the photos in Ndimensional space will cluster together. This is because the fact that they all represent faces gives rise to similarities in the coloured pixels (eg similar coloured pixels across the cheeks and forehead, darker pixels in the eye regions and defining the nose shape).
The researchers are only interested in this region of Ndimensional space containing the photos of faces — a region called the face space. And to map out this region they use a statistical technique called principal component analysis or PCA.
The average female and average male face.
First of all the researchers calculate the average face by simply averaging the values at each pixel over all the photos in the set. This new string of numbers represents the average face and the position of the points representing the other faces show how they differ from the average face.
Principal component analysis uses a statistical concept called variance to measure how the set of faces, viewed as points in Ndimensional space, is spread out. It calculates the first principal component to be the direction from the average face in which the set spreads out the most. Then it looks for the second principal component: the direction that is perpendicular to the first component, in which the set spreads out the most. Then for a third principal component, perpendicular to the first two, in which the set spreads out the most, and so on.
Using PCA, McOwan and his colleagues produced a face space in which each face is represented by a string of 20, rather than N, numbers, giving a much more manageable 20 dimensions. These dimensions correspond to the first 20 principal components. Any face is represented by a point in the face space, with the coordinates describing just how that face differs from the average face with respect to each of these principal components.
Faces change as you move along one of the principal components. The leftmost image sits at one end of the principal component vector, then moves closer to the average face (centre image), until finally it reaches the antiface (the rightmost image) of the leftmost image, at the opposite end of the principal component vector.
The researchers have established a female and a male face space using thousands of photos of faces, showing how faces differ from other faces of the same gender. And what's more they can map these male and female face spaces to each other. At the exhibit you can explore these face spaces and create a face by choosing its position in the female face space. And then, before your very eyes the researchers will show you the male face that lies at the same sport in the male face space — the male reflection of your created female face!
In addition to changing genders, the maths of PCA also allows the researchers to transport the facial expressions from one face to another. So if you are intrigued by how your facial expressions would look like on a member of the opposite sex, then visit McOwan and his colleagues at the Royal Society Summer Exhibition in July 2011. You'll never look at yourself, or mathematics, in the same way again!
Further reading
You can read more about this research and the Facing up to faces exhibit in the latest issue of cs4fn.
This article accompanies an exhibit at the Royal Society Summer Science Exhibition 2011 entitled Facing up to faces: perception from brains to robots. It is part of the Maths Inside project, run by the Mathematics Promotion Unit (a collaboration between the London Mathematical Society and the Institute of Mathematics and its Applications) in conjunction with Plus and the Royal Society.

