PetaPixel

Exploring the World of Color Theory with a 3D Modeling Program

LabARGB-ProPhoto_1

From time to time I post plots of color gamuts like the one above. Each time, I get emails asking how I make them, leading me to assume that the world’s thirst for color nerdiness is going unquenched. I’m setting out to fix that in this post.

There are several applications that produce graphics like these on demand including Apple’s ColorSync Utility, ColorThink Pro, and Gamut Vision. These are all terrific applications and they all do a lot more than plot gamuts, but when I make these graphics, I do it from scratch using Blender and its Python scripting interface.

Blender is an open source 3D modeling/rendering application. Because you have to tell it explicitly what to do at every step, working with color geometry in Blender is a really good way to sharpen your understanding of the technical details. And unlike software dedicated specifically to plotting colors, Blender imposes no limitations on your creativity.

The RGB Cube

ColorCube-650px

This is a good exercise to begin with: create a cube at the origin with sides one unit long and subdivide it a few times. Since all the points in the cube will have coordinates ranging from 0.0 to 1.0, you can assign each vertex an RGB color identical to the coordinates of its location and end up with the classic color cube. The color cube has some interesting properties: primary colors (RGB) and their complements (CMY) sit on opposite vertices. The most saturated colors are on the face of the cube with colors desaturating as you move into the cube. The line connecting the white and black points holds all the gray colors.

Relationship between the Color Wheel and the RGB Cube

ColorCube-wheel

If you turn the cube so you are looking straight down on the white corner, you’ll see the vertices of the three primary and three complementary colors arranged on a hexagon in the order of the color wheel. If you have used hue, saturation, and brightness (HSB) to specify colors and wondered why hue is specified in degrees, here’s your answer. From this view you see red at 0º, and working counter-clockwise in 60º increments: yellow (60º), green (120º), cyan (180º), blue (240º), magenta (270º), and back to red (360º). These are the exact angles you’ll see if you set Photoshop’s color palette to HSB.

Comparing Color Gamuts in CIE XYZ Space

Adobe98-Prophoto-XYZ

Comparing color spaces in RGB doesn’t work because all RGB color spaces have the same numeric values ranging from zero to one-hundred percent—you always get the same cube—but these numbers don’t represent the same colors. It’s another way of saying that RGB color is device dependent—a triplet of RGB numbers by itself doesn’t specify a color unless you also have a profile attached to it describing the device or color space those numbers are intended for.

One of the main jobs of a color profile is to provide instructions to the color management system about how to turn a set of RGB numbers into coordinates in an device-independent system like CIE XYZ space. The above graphic uses simple matrices available from Bruce Lindbloom to convert two RGB cubes into XYZ spaces using the ProPhotoRGB profile and the Adobe RGB (1998) profile.

Once in XYZ space it is easy to see that the ProPhoto gamut completely contains the smaller AdobeRGB gamut. You can also see that the white points (the top right vertex in this image) are aligned because I have adapted them to D50. It’s a necessary step when comparing colorspaces with different white points.

Comparing Color Gamuts in CIE Lab Space

ProPhoto-AdobeRGB-Lab

The same two spaces as above, but converted to Lab space. Looking straight down the L axis. This is the same model as the image at the top of the page viewed from a different angle. Lab space is more appropriate for comparing color gamuts because, unlike CIE XYZ, space it attempts to be perceptually uniform.

Adobe RGB Gamut in xyY Space

xyY-ARGB-D50

The thin, red line is where the spectral colors fall in this space. This is a view you don’t often see because it’s not especially useful and most software won’t produce it out of the box. But it is interesting because if you move the camera above the xy plane and point it straight down with an orthographic view (no perspective), the result is a very familiar graphic:

xyY-ortho-top-D65

This is the most common way of quickly showing the gamut of a color space. But as you can see in the image above it, this xy chromaticity graph is a simplification of a three-dimensional solid. This has practical implications—there are colors that from this view look like they are in gamut because they fall within the triangle on the xy plane, but are not. In other words the chromaticity diagram should be used with caution.

Other Strange Things

LAB-tints

Blender places very few limits on your creativity. For instance, you can dismantle a model to expose its internals. The conversion from XYZ to Lab is a non-linear transformation. What starts out as simple triangles in the RGB cube connecting each primary vertex to the black and white points becomes warped in the transition to Lab space—a reflection of the non-linear nature of our color perception that is Lab space attempts to model.

Do Want to Try This Yourself?

First you need a copy Blender and maybe some tutorials. Bruce Lindbloom’s site is a treasure trove of formulas and instructions for converting between color spaces. To get you started here is my Blender file which has a simple Python script showing how to do the transformations between a few color spaces in Blender and how to assign vertex colors with Python in Blender 2.66. It also has the material to make wireframes in Blender’s Cycles renderer, a trick I learned here.


About the author: Mark Meyer is a Anchorage, Alaska-based photographer who’s obsessed with color theory. Visit his website here. This article originally appeared here.


 
  • http://www.facebook.com/ieuan.flowers Ieuan Flowers

    this is all really interesting but i literally have no idea what any of it means. pardon my ignorance but would anyone care to explain what im looking at and its significance within photography?

  • http://www.facebook.com/jonathan.maniago Jonathan Maniago

    You could do a quick search on Google for “color management” and “color space”. Basically, this is relevant for professions which require accurate rendering of colors across different devices (printers, LCD displays, etc.).

    “It’s another way of saying that RGB color is device dependent—a triplet
    of RGB numbers by itself doesn’t specify a color unless you also have a
    profile attached to it describing the device or color space those
    numbers are intended for.”

  • Mark M

    Many mathematical ideas are abstract and difficult to deal with mentally. Often it’s helpful to turn the purely abstract numbers into a geometric representation so we can ‘view’ the math. This is why we graph curves in algebra, make charts in statistics, and plot color spaces.

    Color, at least in it’s current digital embodiment, is almost always expressed as a set of three numbers making it a natural subject for plotting in three dimensions. There are many ways to mathematically describe the same color and plots like these can help ‘see’ what happens when you translate from one system to another. These techniques allow you to treat colorimetry as a type of geometry rather than raw numbers and equations, which for many people makes the concepts easier to grasp.

  • an artist

    …and from a different world:

    in art class, a common test is to be shown a masterpiece whereupon the instructor points to a point and says “make this colour” using only red, blue and yellow. It can be extremely difficult with some tints and tones, watercolour, oils, acrylics or dry pigment pastels.

    So, with a camera sensor and software application, colour is required to be rendered using image raw data and the software’s math data, and it needs to be rendered such that it can be manipulated and communicated to other methods and devices. These various math models of colour mixology do that, some clearly, some complex, a pseudo-digital model of an instructor saying “make this colour” several million times at once.