Pencil charts for visualising colours

As a result of a discussion with a photographer friend of mine, I’ve been thinking (not for the first time) about visualising the colour palette of images. Consider this sunset, for example (a picture I took in Adelaide 8 years ago):

The photograph is rich in yellow and orange. However, the apparent blue in the sky is actually grey, and the apparent grey of the sea is actually brown. If we postulate a standard set of 35 plausible pencil colours, and map each pixel to the closest-matching pencil colour, we get this (I have done the comparison in RGB space):

Then we can visualise the colour palette of the image by showing the wear on the virtual pencils, if each virtual pencil has been used to colour the corresponding pixels. It can be seen that a lot of orange, brown, and grey was used (click to zoom):

Conversely, this beach scene (photographed in Vanuatu in 2016) is rich in blues:

The warm light greys of the beach don’t quite find an exact match among the pencils, but the other colours match fairly well:

And here is the pencil visualisation (click to zoom):

If, rather than using a standard set of colours, we extract the pencil colours from the image itself (image quantisation), fewer pencils will, of course, be required:

The fit to the original image will be much closer as well:

So this is a trick to remember for another day – pencil visualisations!