# Images and Statistics

Published May 19, 2022  -  By Marco Garosi

Pixels of an image can be seen as a population on which to calculate statistics: mean, median, variance, standard deviation, quartiles and percentiles. You may think of an image as a collection of values arranged on a grid, each one with its own coordinates $m, n$.

For simplicity, we’ll assume that images are functions with one, single output: the level of gray. Many images are RGB, so you may extend the following concepts and ideas to functions with three outputs. That should be pretty natural in most cases.

We’ll consider an image $I(M, N)$, with $M$ rows and $N$ columns.

You can find an introduction to signals here. This post is part of a series on Image and Signal Processing. If you are looking for Image Processing, you may read the related note.

## Histogram

An histogram is a distribution of the frequencies of grey levels. It is computed as follows:

$\sum_{r = 0}^{L-1} H(r) = M N, 0 \le r \le L-1, L \in \N$

Histogram of an image

$L$ is the number of grey levels available (usually, $256$). $L - 1$ is thus the highest grey level available (usually, $255$).

An histogram can also be seen as a probability distribution:

$p(r) = \frac{H(r)}{M N}, \sum_{r = 0}^{L-1} p(r) = 1$

The histogram does not take into account the spacial distribution of the pixels: this means that totally different images may have the exact, same histogram. And, of course, it also means that you cannot reconstruct an image only with its histogram.

### Contrast

Contrast is the ration or difference between the brightest point and the darkest. An image is said to be:

• overexposed if the histogram is skewed to the right. Note that being bright is a characteristic of the image, while it being overexposed is a characteristic of the acquisition process;
• underexposed, if the histogram is skewed to the left. Note that being dark is a characteristic of the image, while it being underexposed is a characteristic of the acquisition process.
Share on: