Skip to content
UoL CS Notes

Image Histograms

ELEC319 Lectures

Binary Images

  • Simplest type of images
  • Each pixel can either be black or white

The size of the image is:

\[M\times N\text{ bits}\]

where $M$ and $N$ are the rows and columns.

A histogram for a 1 bit image only has two peaks for dark and light.

Grayscale Images

  • Generally 8 bits per pixel
    • This gives 256 levels of brightness.

Colour Images

  • Each channel RGB has 8 bits.
    • This gives 24 bits per pixel.

You can generate histograms for each channel or sum the channels to account for all of them.

Colour Quantisation

You can’t represent an infinite number of colours using 24 bits. As a result the raw colour is quantised to fit in the colour space.

We can use the following algorithms to add dithering to account for quantisation:

  • Uniform
  • Median-cut
  • Octree
  • Popularity
  • Generalised Lloyd

Conversion

Colour Image to Grayscale Conversion

This can be achieved by converting each RGB pixel to greyscale by forming a weighted sum:

\[a_1R+a_2G+a_3B\]

MatLab’s rgb2gray uses $a_1 = 0.2989$, $a_2=0.5870$ and $a_3=0.1140$.

Grayscale to Binary Image Conversion

To convert from grayscale to binary we need a threshold value.

Thresholding is an easy way to:

  • Convert grayscale to binary.
  • Separate foreground from background.

There are two levels of thresholding:

  • Histogram
  • Multi-level Thresholding