In my post
"Primark and the Spectrum Suckers", I imagined white light passing through a Primark shop and exiting as a spectrum made entirely from grey:
My collage was inspired by the stunningly dreary Primark in the new Westgate shopping centre in Oxford. I'm sure it's obvious that I made the grey "spectrum" by monochromaticising the one in the upper half of the collage, which I'd taken from some free clip-art. But how could I produce a real picture of the colour distribution? I've been looking for tools, and found one recently whose output I'll show. As this is also related to an article I'll post next week about generating colour schemes — including green and purple colour schemes — I've decided to write about colour distributions today.
One standard tool for displaying colour distributions is the two-dimensional colour histogram. Here's one for the Primark photo from the collage. I made it in
Gimp, free image-processing software that I use for editing photos and a host of other things, including retouching cartoons.
Such histograms are easy to produce, but as David Tschumperlé explains in "Visualizing the 3D point cloud of RGB colors"†, they have disadvantages. He displays a photo of the Swedish model Lena Söderberg, and another photo edited so that the green channel has been reflected around the X-axis, and the blue around the Y-axis. The second photo appears to have much more green, but its histogram is exactly the same as the first photo's.
But there are other ways to plot colour distributions, using the idea that because we have three colour components, we can represent them as points in three-dimensional space. Take any pixel, and express it as so much red, so much green, and so much blue. This gives us three numbers, each between 0 and 1. A pixel that's black would be (0,0,0); one that's white would be (1,1,1); and one that's pure red would be (1,0,0). Treat these as a point, and plot it. Repeat for all the pixels. This gives us a cloud of points lying within a cube. To display the distribution of colours, colour each point with its actual colour; to display the number of occurrences, give each point a colour that represents these. These, as David Tschumperlé says, give us more information about the global variety of colour in the image, and the local dispersion of tones around each point.
There are examples for Lena and other images in David's article. Here are some of my own, made using Kai Uwe Barthel's
Color Inspector 3D‡. Each of these shows an image and the corresponding
In the first image, all the pixels are pure red. So strictly speaking, we'd end up with just one point, at the position (1,0,0), the red corner of the distribution cube. Color Inspector 3D has made a small dot rather than a point, probably to make the results easier to see. The second image is all green, so we get its counterpart: a cube with a green dot at (0,1,0), the green corner.
The third and fourth images show what happens for more than one colour, in this case pure red and pure green. We get a red dot and a green dot.
Note that in the third and fourth images, the results are the same regardless of the proportions of red and green. I have a reason for mentioning this, and it's to do with "anti-aliasing". Look at this:
What I did here was to get the colour-distribution cube for a red line. But if it's red, why are there those increasingly white dots leading down to the white corner of the cube? I suspect the reason is that to counteract the relatively low resolution of the line, the drawing program (Gimp, but other programs would do the same) gives pixels at the edge of the line colours intermediate between the line and its background. In this case, various shades of reddish-white. This is called anti-aliasing. You can see this in this zoomed-in portion of the line:
As the distribution plots don't record how many pixels of each colour they see, these few intermediate pixels have as much impact on the display as the pure red ones.
I didn't start today's post with the intent of writing a graphics tutorial. But I noticed these unexpected intermediate colours when analysing example coloured images I'd drawn, and decided I'd better understand where they come from, because they could mislead. I don't know whether similar artefacts could arise in other ways, for example when resizing JPEG files. But I'm fairly sure that some of my images will be affected by the following. Some of my clothing pictures are ones where I've separated the clothing from its background. But it's hard to do so perfectly, so there are minute remnants of background clinging to their borders. This seems likely to bias the distributions, perhaps by giving them tails that shade off towards black.
With that out of the way, let's look at Primark. Here's my original photo:
If the photo seems rather "chewy", it's because the original suffered from motion blur, which I reduced by using Focus Magic. I didn't want to stand around with a tripod, and my camera isn't sensitive enough for a fast point-and-shoot response to indoor lighting.
So what do we have? It's a moderately loose diagonal line, stretching from the black corner to the white corner. There are a few dots of red, green, and blue further out. These, I suspect, come not from the clothes, but from their labels.
† "Visualizing the 3D point cloud of RGB colors", Open Source Graphics, by David Tschumperlé, 24 February 2018.
‡ I used Color Inspector 3D by Kai Uwe Barthel. This is a Java
program, packaged as a JAR file: something rather like a zip file, containing all the program components. On Windows 10, I was able to run it by following Kai's
instructions: download ColorInspector3D.jar from the link, and double click on it. This requires the computer to have Java, which the one I'm using must have got. Once you've started the program, click "File" and then "Open", and select an image. Its colour cube should then appear. I found that the program failed on very big images, and I had to reduce their size.