I was very pleased with myself in kindergarten. Playing with the paints I had colors all figured out:

  • Mix red and yellow to get orange.
  • Mix red and blue to get purple.
  • Mix yellow and blue to get green.
  • Mix red, yellow, and black to get brown.

In modern technical parlance this would be called an RYBK system for the primarily colors: Red, Yellow, and Blue; and with a darkness component blacK. I suppose that artists still use this scheme on their palettes but color printers do not. There are two reasons for this:

  1. Red and blue are dark colors. Unless there’s a source of white paint there’s no way to lighten colors to get pink or sky blue.
  2. There’s a difference between paint and printer ink. Paint is opaque and hides the underlying surface. Printer ink is translucent and stains the underlying surface retaining some of its color. Since the underlying surface is nearly always white paper “lightness” comes for free.

Instead of RYBK, color printers use a system called CMYK the properties of which surprised me when I learned about it two decades after my childhood certainty:

  • C is for Cyan, light blue.
  • M is for Magenta, pink.
  • Y is for Yellow.
  • K is for blacK.

To me it still seems wrong that red and blue aren’t primary but:

  • Mix cyan and magenta to get blue.
  • Mix cyan and yellow to get green.
  • Mix magenta and yellow to get red.
  • Mix cyan, magenta, and yellow to get black.

Here’s a visual aid:

So if mixing cyan, magenta, and yellow makes black why do color printers have a separate black ink cartridge? Again there are two reasons:

  1. While CMY black is black in theory, in practice it’s a dark gray.
  2. Most color printers also print a lot of text. Printing it as CMY is nominally three times as expensive as printing it with actual black ink.

Even CMYK has limits. More expensive color printers have cartridges for light cyan and light magenta to better render lighter colors. This is a refill kit for such a printer:

But we’re not supposed to print stuff anymore in this age of modern telecommunications. Keep your eyes on those screens, buddy, and know that they do color completely differently.

The CMYK color printer system is called “subtractive” because mixing ink colors produces a darker result on a white background. Light emitting screens use an “additive” system, complementary to CMYK, called RGB for Red, Green, and Blue where mixing light (as in ray) colors produces a lighter result on a black background:

  • Mix red and green to get yellow.
  • Mix red and blue to get magenta.
  • Mix green and blue to get cyan.
  • Mix red, green, and blue to get white.

Here’s a visual aid. You can see that it’s the complement of the CMYK system:

You can demonstrate this with three flashlights and some red, green, and blue filters.

Most images in common file formats like JPEG, PNG, or BMP are encoded using the RGB system. Usually each color component is assigned a value from zero to 255 to fit in a single byte of information. Color (0,0,0) is black and (255,255,255) is white. Because the CMYK system has four components it has the potential to express a wider variety of colors than RGB. Images prepared with the intention of printing are encoded using CMYK but this is rare. Of the thousands of images on my file server exactly one is encoded as CMYK.

You’ll get some math and you’ll like it!

RGB color components are usually values from zero to 255. CMYK color components are usually values from zero to 1.0. Because the CMYK system has four components it can express colors that can’t be expressed by RGB but all RGB colors can be expressed by CMYK. This is how you do it:

From RGB values R, G, and B; calculate initial values for C, M, and Y as follows:

C = 1 - (R / 255)
M = 1 - (G / 255)
Y = 1 - (B / 255)

The value of K is the smallest of C, M, and Y:

K = min(C,M,Y)

If K is one, meaning the color is pure black, then C, M, and Y are set to zero. Otherwise calculate temporary value T:

T = 1 - K

And calculate final values for C, M, and Y:

C = (C - K) / T
M = (M - K) / T
Y = (Y - K) / T

This is a low-level mathematical conversion that doesn’t add any value to the color encoding. A proper RGB to CMYK conversion would take into account the precise color of the CMYK inks and how different ink densities transfer to the paper.