# Para arriba…

After two weeks in Barcelona I have to say that applying for SoHPC was one of the best decisions I’ve ever made. It’s not only the everlasting warm weather, sand beaches, unique architecture, lots of places to visit, great people (with some exceptions), but also the project itself here at BSC.

## The City

### Espanya

On the first day of our arrival we went to the Espanya square. We are in Spain, right? After getting out of the subway, we immediately noticed the Palau Nacional at top of the Montjuïc, the central hill of Barcelona.

Plaça Espanya

Now, this view alone would be enough, but it turns out there are Barcelona Harley Days, the largest Harley Davidson event in Europe. So the court of Palau Nacional, a palace built in twenties in Spanish renaissance style is filled with thousands of American choppers. I do not want to guess the exact number but if I say at least 2,000, it would be a very conservative guess (official statistics say 15,000 for the whole event). I also bought a Harley Davidson guitar pick to remind me of this fascinating sight.

Harley Days

### La Rambla (The Avenue)

The next day we went to see the centre – La Rambla -the most contrasting place in Barcelona. It is very tourist oriented, has a lot of cheap souvenir shops and people offering you goods of very different nature that you are simply not interested in. I will only say one thing: “be very very careful!”.

### Sant Pere Màrtir

A couple of days later we decided to go to Sant Pere Màrtir (Saint Peter the Martyr), a hill very close to our residence. The trip is a bit more demanding than the St. Arthurs hill, mostly for the temperature and the lack of natural air conditioning (no 20km/h wind). The variety of objects at the top of the hill make it a very interesting historical place:

• a memorial of St. Peter, one of the twelve apostles of Jesus,
• a telegraph tower built in 19th century, and
• a remnant of an anti-aircraft gun built in Spanish civil war in the thirties.

Seeing whole Barcelona at sunset is a story itself, but because we do not have a camera with long exposition nor a tripod, nor any real photographing skills, you have to come see for yourself.

Night View From Sant Pere Màrtir

## The Project

### Machine Learning

How does a human brain recognize faces? How can it make your body play ping pong? How does it make you paint and compose music? We don’t know yet. When we know, the world will change. Until that time, we have to try to solve these problems by a very distant approximation. Machine learning is an area of computer science that connects mathematics and programming and gets inspiration from physics, biology, medicine and other fields.

### Face Recognition and Applications

Bio Surveillance

Our project is a cooperation between the Barcelona Supercomputing Centre and Herta Security, a private company and a leader in facial recognition tools development. Some real commercial applications include surveillance of black-listed people at chosen locations. These are mostly places where there is a high probability of repeating criminality from same individuals such as sport stadiums, shopping malls, airports, etc. Another example of application is creating statistics for marketing purposes: estimating the age and gender and potential expression of interest in chosen content (such as goods at the store or commercials). This is just the beginning of the list.

### A Very Simple Local Binary Pattern algorithm

Machine face recognition starts with finding a suitable representation for the face. The representation must be designed in a way that it is possible to compare two representations accurately and effectively. Special conditions such as emotional expressions, different illumination and different angles of capture make this a difficult problem.

#### Neighborhood

The newest advances in face recognition exploit Local Binary Pattern (LPB) descriptors introduced by Ojala et al.[1]. For every pixel we look at its neighborhood and compare its value with values of pixels in this neighborhood. The simplest neighborhood is the closest eight pixels around it. Comparison has only two outputs: 0 – smaller value, 1 – larger value. We then get 8 numbers from {0, 1} or one binary number consisting of 8 ciphers.

LBP example [2]

#### Histogram

For every pixel we have a number from {1, … , 256}, standing for 256 possible patterns. Therefore we can build a histogram of these values for every image. To find out if two images are similar, we just compare their LBP histograms[3]. How to compare two histograms? The simplest measure is by looking at the histogram intersection: let $G, H$ be histograms of two images created by the above technique and $G_i, H_i$ be the number of values equal to $i$ in these histograms respectively. Then the similarity function called histogram intersection can be defined as

$f(G,H) = \dfrac{\sum_{i = 1}^{256} min(G_i, H_i)}{n}$, where $n$ is the number of pixels.

This similarity function is very intuitive as it only takes what the histograms have in common. In this example we will use a different measure called $\chi^2$ defined as:

$\chi^2(G,H) = \sum_{i = 1}^{256} \dfrac{(G_i - H_i)^2}{G_i + H_i}$.

This technique, although being very locally oriented, works very well. To get better results, some basic improvements include:

• using different kinds of neighborhoods,
• different ways of comparing the histograms,
• splitting images into regions with different weight, etc.

#### Example

LBP histograms

Let’s take four images with faces of three different people and see how this simple scheme works. We compute the LBP histogram for each image and this is the result:

Even by first visual inspection, we can see a pattern here. Now to compare these four LBP histograms let’s compute a distance matrix using the $\chi^2$ similarity function. The resulting distance matrix is visualized instead of showing the numeric results. Darker color means more similar, lighter color means more different.

In this case, the algorithm worked as we would expect it to. However this example is only an illustration of straightforward use of the simplest LBP algorithm. Many improvements to this basic scheme have been proposed and work much better in practice.

LBP histogram distance matrix
(darker = more similar)

[1] Ojala, T., Pietikainen, M., Maenpaa, T., “Multiresolution gray-scale and rotation invariant texture classification with local binary patterns,” Pattern Analysis and Machine Intelligence, IEEE Transactions on , vol.24, no.7, pp.971,987, Jul 2002

[2] http://docs.opencv.org/

[3] Ahonen, Timo, Abdenour Hadid, and Matti Pietikäinen., “Face recognition with local binary patterns.” In Computer Vision-ECCV 2004, pp. 469-481. Springer Berlin Heidelberg, 2004.