LESSON

Histogram of an Image

Transcript

A very useful and concise way of describing the grey levels within an image is using a tool called a histogram.

Here I have a contrived and low resolution image, where the pixel grey values vary between 0, which is black, and 10, which is white.

We can consider the histogramming process as a sorting process. I am going to take the first pixel, which has got a grey scale value of 6, and I am going to drop it into the bin for pixels with a value of 6. And I am going to take the next pixel which has got a value of 10, and I am going to drop it into the bin for pixels of value of 10, and so on. And we repeat this process on and on until we have coloured all of the pixels in the image.

And we have this histogram. At a glance this histogram tells us some very interesting things about the image. If all of the pixels are at the left-hand side of the histogram, this tells us that it is a very dark image. Conversely, if all of the pixels are at the right-hand side of the histogram, this tells us that it is a very bright image.

You have very likely encountered histograms. They are commonly displayed in the viewfinder of a camera. What we are seeing here is the viewfinder of an iPhone camera app and we can see the histogram here on the display. The left-hand side of the histogram corresponds to the dark pixels, and the right-hand side of the histogram corresponds to bright pixels.

If I move the camera from this view to down underneath my desk where it is all very dark, we can see that there are an increasing number of dark pixels in the scene. As I bring the camera up from underneath the desk and point it out the window where it is very bright, we see the distribution of pixels moving more towards the bright end of the histogram.

If I repeat the process, but this time I have the camera set to automatic exposure control, what happens now is that the software within the camera is trying to keep the histogram balanced. It is trying to keep an even mixture of dark pixels and bright pixels, so that the average is somewhere in the middle. And the behaviour this time is quite different, when we look under the desk, we can see the wires and the carpet.

When we look out the window, we can now quite clearly see the world outside.

Code

There is no code in this lesson.

There is a lot of information in an image which we need to summarize somehow. An intensity histogram is one form of summary that provides useful information about how well the exposure of our camera is adjusted.

Professor Peter Corke

Professor of Robotic Vision at QUT and Director of the Australian Centre for Robotic Vision (ACRV). Peter is also a Fellow of the IEEE, a senior Fellow of the Higher Education Academy, and on the editorial board of several robotics research journals.

Skill level

This content assumes an understanding of high school level mathematics; for example, trigonometry, algebra, calculus, physics (optics) and experience with MATLAB command line and programming, for example workspace, variables, arrays, types, functions and classes.