This page is a part of CVprimer.com, a wiki devoted to computer vision. It focuses on low level computer vision, digital image analysis, and applications. It is designed as an online textbook but the exposition is informal. It geared towards software developers, especially beginners, and CS students. The wiki contains mathematics, algorithms, code examples, source code, compiled software, and some discussion. If you have any questions or suggestions, please contact me directly.

# Euler number

Suppose a binary image - of any dimension - is represented by its cell decomposition (see Cell decomposition of images). Then the Euler number, or Euler characteristics, of the image is defined as the alternating sum of the number of cells in each dimension.

For example, in 2D it's

```                        # of vertices - # of edges + # of pixels
```

In 3D it's

```                        # of vertices - # of edges + # of pixels - # of voxels
```

Turns out the Euler number is independent of cell decomposition. It depends only on the topology of the image.

This idea can be traced back to the original Euler formula: for any convex polyhedron,

```# of vertices - # of edges + # of faces = 2
```

Also, the Euler number of a circle (disk) is always 1. Same for ellipse, square, blob etc - regardless of size and shape. The Euler number of the sphere (or any balloon) is 0.

The Euler number is well known even popular. The popularity comes from the fact that this is a topological characteristics of the image (preserved under deformations) and the simplicity of its computation. It can serve as a quick test to verify whether two images are NOT the same topologically.

The meaning of the Euler number itself is however obscure apart from the Euler-Poincaré formula:

```Euler number of a 2D binary image
= # of vertices - # of edges + # of pixels
= # of objects - # of holes
```
```Euler number of a 3D binary image
= # of vertices - # of edges + # of pixels - # of voxels
= # of objects - # of tunnels + # of voids
```

Meanwhile, the meanings of # of objects, # of tunnels, # of voids in the formula are easy to understand. These numbers are not only truly meaningful but clearly very important for image analysis (see for example Cell counting). These 3 (or more) numbers are topological characteristics of the image as well. They are called Betti numbers. The Euler number can't serve as a substitute for the Betti numbers while you can recover the Euler number from the Betti numbers. They aren't as easy to compute though.