In which the author explains how facial recognition works in order to unravel a seventh grade mystery of mistaken identity.

July 19, 2008
This is a heavily edited version of an article I posted some time back. It’s being prepared for publication in Oxford’s Bang! Science magazine. Feel free to comment.

Seventh Grade Blues

the one

When I was in the seventh grade, one of the girls told me I looked like Keannu Reeves.

Was this some awfully cruel, sadistic joke little girls liked to play on unsuspecting boys?

When I was in the seventh grade, one of the girls told me I looked like Keannu Reeves. No, seriously.

I was hanging upside-down on the jungle gym, minding my own business, and she just walked over and blurted it out. Then she giggled like a moron and ran away. Girls can be so mean.

This became the highlight of my school year (my academic career, even), but you see, I was torn. On one hand, how could anyone confuse Keannu (black shades, gothic trench coat, infinite awesomeness) with me (pubescent, angst-ridden, gawky)? Was this all some awfully cruel, sadistic joke little girls liked to play on unsuspecting boys?

But on the other hand, maybe — maybe she was on to something. Maybe somewhere — somehow, behind all that bad acne and ruffled hair, I really did look like Neo. After all, who was I to disagree?

Today, however, I no longer have to wonder because, according to the latest advances in facial recognition, she was right.

Who in the Land is Fairest of All?

MyHeritage is an internet-based company that offers you the chance to see which celebrity you most resemble. Remember how in Snow White, the queen has a magical mirror which provides her with uninhibited flattery? This is the same, but like, tons better.

After a free signup, you upload a large-ish jpeg of your mug, then let the software crank away. Here were my results: Brad Pitt (71%), Keannu Reeves (63%), Luke Perry (63%), Matt Daemon (63%), and Jordana Brewster (60%).

Results

Brad Pitt? Really? Matt Daemon? Really? Who wouldathunk? But y’know, as I gaze into the mirror…well…yes, I see it now. Definitely. We’re practically brothers!

How does it all work? Is this actual science or just deceptive flattery? To understand how facial recognition works, we’re going to have to delve into the mathematics behind the algorithm.

Recognizing Faces

Suppose we were given someone’s picture. How might we go about identifying that person from a large database of faces?

One way we can go about it is by identifying the characteristics of the subject – perhaps the person has small lips, or a pointed chin, or distinct eyes. From here, we then study the database, going from picture to picture, each time isolating the features of the faces and checking for a match.

But while this might work, it’s also a lot of work; algorithms would need to be defined to analyse each desired feature and a large number of faces to mix and match and could potentially take eons to compute.

A more efficient way to proceed would be to examine these faces as a statistical whole rather than as the sum of its parts. This is similar to the difference between identifying a city by its landmarks and identifying the same city by the density of its roads, the clusters and heights of its buildings, its downtown areas and rural areas, and so on.

A Picture is Worth a Thousand Digits

Snap! But what are pictures, really?

Grid

As stored in a computer, a picture is nothing more than a great big grid of dots (or pixels). If the picture is greyscale, each pixel is associated with a number from 0 to 255 representing its brightness, from pitch black (0) to pure white (255).

Now in the abstract theory of Linear Algebra, these grids of pixels are called ‘vectors’. You’ve probably encountered vectors before in Physics class and in fact, these ‘face vectors’ are quite similar.

Like vectors representing force or motion, these new ‘face vectors’ have a `magnitude’ (an overall brightness), as well as a ‘direction’ — the only difference is that they inhabit some higher-dimensional Face Space, rather than the two or three-dimensional physical world we live in.

Coords

Thus, faces found in the database are nothing more than vectors that, like other mathematical quantities, can be added, subtracted, multiplied, and generally manipulated as they roam about in the Face Space.

What’s Your Eigenface?

However, Face Spaces are complicated affairs — they’re high dimensional boxes stuffed with a large number of faces, each face containing thousands of pixels.

It would thus be foolish to try and compare each face pixel by pixel; instead we look to construct a small group of pictures representing the general facial patterns of the database. This small but crucial group is called the Eigenface Basis.

Think of how, when we analyse the motion of a ball flying through the air, we break the motion into its horizontal and vertical components. These horizontal and vertical components provide a fundamental basis for which all motion can be broken down into.

Similarly, once the eigenface basis is found using Linear Algebra, each face in the database can then be expressed using certain percentages of each eigenface. For example, we may say that a picture is composed of 10% of the first eigenface, 25% of the second, 4% of the third, and so on.

Eigenfaces

The beauty of this treatment is that even in a large database, each unique face can be expressed very simply using its eigenface decomposition. We no longer have to express each face using thousands of pixels; now, like a simple recipe in which the eigenfaces are the key ingredients, the entire database can be reconstructed as it was before.

A Problem of Distance

Now imagine each face in the database, represented in terms of its eigenface percentages, akin to coordinates lying in some higher-dimensional plane. Our test subject (which may or may not lie in the database) is then projected onto this plane by expressing it in terms of the eigenface components.

Matching

But now, the problem of recognising the subject becomes as simple as finding the shortest distance (or closest match) between our subject and each face in the database, a problem which is aided enormously by the fact each face is represented by only a handful of eigenface components.

The Future and You

But really, just how accurate are these eigenface algorithms?

In optimal conditions (with good lighting, a representative database, front-facing pictures, etc.), a simple eigenface routine might produce accurate readings of up to 90%.

Unfortunately, real life is never that simple, and in reality, one must contend with other ‘noisy’ factors. Factors like variance in pose (person facing at an angle), obstructions (sunglasses or other people), resolution and lighting, and so on. Despite this, however, the science of facial recognition has steadily improved to the point where today, it is becoming a standard for many military, security, and commercial applications.

Yeah, yeah. But now that you know how facial recognition works, go and try it on yourself.

What celebrity do you look like?