Primark and the Spectrum Suckers II: Visualising Clothing Colours as a 3D Cloud of Points

    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:
    Two pictures in one image. The first is a prism with light going through and forming a spectrum, labelled 'PRISM'. The second is the same prism with an interior photo of the Oxford Westgate Primark shop superimposed. It is labelled 'PRIMARK'. The light coming out is the same spectrum as for the first prism, but grey, not coloured.

    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.
    Photo of Primark shop from the above collage, with a colour histogram superimposed.

    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 distribution cube.
    Colour-distribution cube for a red square. There's a red
dot at the (1,0,0) corner of the cube.
    Colour-distribution cube for a green square. There's a red
dot at the (0,1,0) corner of the cube.
    Colour-distribution cube for a red square next to a green square. There's a
red dot at the (1,0,0) corner of the cube, and a green dot at the
(0,1,0) corner.
    Colour-distribution cube for a red square next to a thin green rectangle. There's a red dot at the (1,0,0) corner of the cube, and a green dot at the
(0,1,0) corner.
    Colour-distribution cube for my logo. There's a spray of green, purple, and pink, fanning out from the (0,0,0) corner.
    Colour-distribution cube for orange sarouel and ice-blue shirt. There are two 'bananas' going from near the black corner to near the white corner. One is blue, the other orange.

    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.

    And the fifth and sixth images show results for two realistic images. One is for my logo, which is from this Oakland velvet waistcoat. The other is for my orange qandrissi and ice-blue shirt.

    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:
    Colour-distribution cube for a red line. There's a red dot at the (1,0,0) corner of the cube, and other dots on a diagonal leading to the white corner, (1,1,1).

    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:
    The red line enlarged. On its edges are paler, reddish-white, pixels. 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:
    The photo used in 'Primark and the Spectrum Suckers'. Interior of the Primark shop in the Westgate Shopping Centre, Oxford. 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.

    And here's the colour distribution:
    Colour-distribution cube for the photo of the Primark shop used in 'Primark and the Spectrum Suckers'. 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.

    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.

    It's rather sad that the labels on the socks are the most colourful thing in the shop.
    Detail from the photo used in 'Primark and the Spectrum Suckers'. The sock rack in the Primark shop in the Westgate Shopping Centre, Oxford.

    Footnotes

    "Visualizing the 3D point cloud of RGB colors", Open Source Graphics, by David Tschumperlé, 24 February 2018.
    http://opensource.graphics/tag/color-distribution/

    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.
    https://imagej.nih.gov/ij/plugins/color-inspector.html

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.