Skip to content

Instantly share code, notes, and snippets.

@Myndex
Last active December 22, 2021 22:31
Show Gist options
  • Save Myndex/db30607d4fe697de9e582544335bbce6 to your computer and use it in GitHub Desktop.
Save Myndex/db30607d4fe697de9e582544335bbce6 to your computer and use it in GitHub Desktop.
This Gist is in answer to the question: "How many colors are in CMYK."

How Many Colors in a Bushel?

This Gist is in answer to the question: "How many colors are in CMYK."

Short Answer

CMYK as a color model does not define a gamut, nor does it define a number of colors.

  • A colorspace defines the gamut volume.
  • Bit depth partially defines number of colors.
    • Output device and/or colorspace may place additional limitations of the "number" of colors.

Therefore, you can not state that a particular color model possesses any particular number of colors without knowing the bit depth and colorspace parameters. For CMYK that means knowing the destination profile or device, even if you want to assume 8bit data.

In other words, you can't just hand-wave away the printing technology as if it wasn't relevant, because it is determinant.

Longer Answer

The answer is that CMYK is a color model, but not a colorspace, and you need to define a colorspace which will then define the gamut size. And gamut size is not related to number of colors.

As for "theoretical number of colors" — you can calculate the number of combinations for a given bit depth, but if you mean the number of different colors you can print, or moreover, the number you can perceive, that's a much more complicated answer.

Gamut Volume and Color Spacing

  • Gamut size and number of colors are not related.
    • You could have a very large gamut but only a few hundred colors.
      • A large gamut at a low bit depth is still "large" but with few total colors.
      • Low bit depth means the steps between each color is larger.
      • This can result in high ∆E and noticeable banding.
      • An example would be to use ProPhoto at 8 bits per channel or less.
        • To be silly, try 2 bits per channel — that's 64 total colors, enough to roughly define the surface of the gamut. And since ProPhoto uses imaginary colors, the total real colors would be even less, and the result would be a very wide-gamut posterization. LOL.
    • You could have billions of colors, but only a tiny gamut size.
      • A small gamut at a high bit depth is still "small" but has many total colors.
      • High bit depth means the steps between each color is smaller.
      • This can reduce ∆E and make the difference between two colors unnoticeable, but at the cost of increased data size.
      • An example would be to use 32 bits per channel integers for a gamma encoded, 0 - 4,294,967,295 range-limited sRGB.
        • That would be something like 7.9x1028 colors, of which over 99.9% would be essentially indistinguishable duplicates.

Let's start with bit depth.

Regardless of the gamut size and print technology, the theoretical number of colors is a function of the number of combinations of values for each of the color components.

In the case of CMYK, if we are talking about 8bit, then:

C = 0-255 (256 values) *
M = 0-255 (256 values) *
Y = 0-255 (256 values) *
K = 0-255 (256 values) = ...

Which is then 4,294,967,296 combinations. Or is it really?

  • If it was one bit per color, then for CMYK that would imply 16 total colors (2x2x2x2).
  • 0%-100% does not define "bit depth".
    • There are 256 "steps" in an 8 bit byte.
    • There have been other integer codings for color, as low as one or two bits per color, and higher than 16 bits per color.
  • number of places after the decimal also does not define bit depth.

Ultimately the OP's question is sort of an x-y question, he's asking about X, but really is asking about Y. His real question seems more like it is "how is color data encoded in a binary form"?

See 'Em. Why? K!

In response to comments that 160,160,160,0 is the same as 0,0,0,160 — while this may be true in theory, it is not in a practical sense. This is in part why K (black) is included in 4 color printing. In fact, there is a printing term "rich black" which is K black with a certain amount of CMY to deepen the black. Black is not even the same black, depending.

What is not mentioned, and needs to be, is that unlike an additive color model such as RGB, you can not add all 4 CMYK colors at full level at once and hope to get a reasonable result. For instance, rich black is not 255,255,255,255. There are limitations to the density of ink applied to the page (if you want a print run that is not going to have significant issues).

So, in CMYK, you can't simply multiply the total number of values per color. And you need to use a look up table (LUT) that models the specific output device (printer) to calculate the number of colors available in that device's gamut. The total gamut size will vary depending on the printing technology and factors including the kind of paper being used.

As such, there is not one, singular, answer to the question as posed.

Reasonable Assumptions

But I can tell you that you can't just use some arbitrary precision to answer this question. The number of bits is defined by the output device itself. Does it take 8 bit data? 10Bit? 16bit? And is it really only a 4 color CMYK? Or is it a 6 or 8 color model? These are the key factors, and you can't dismiss them.

If you ignore the K channel, and then make the assumption that you can use all 0-255 values at the same time for the remaining three, then you'd have at least 16777216 colors. Except again, it's a bit meaningless without the knowledge of the device limitations, LUT, etc.

Without considering the output device, the raw figure of millions of colors is not too useful.

What IS Useful?

While trying to determine the "total number" of colors is not particularly useful, there are useful metrics. For instanced, ∆E is useful, i.e. how accurate is the printing, or can you see the difference between value 128,128,128,0 and 128,129,128,0 ?

Knowing if the gamut of what you see on your display, or in photoshop, is going to print without being clipped or mangled. For instance, portions of a typical CMYK space are not represented (clipped) in sRGB (the space of most monitors.)

You could use ProPhoto, a wide RGB space that covers typical CMYK gamuts. But ProPhoto uses imaginary primaries that can not exist in the real world, so even if you are using 16 bit in ProPhoto RGB, you are not getting 281,474,976,710,656 colors because many of the colors do not even exist in reality. Not to mention that Photoshop only uses 15 bits of 16 bit images, so to start you're already down to 35,184,372,088,832.

So even for ProPhoto, an RGB space, you need to calculate the realizable colors and then search to find the gamut surface before you can determine how many 16 bit values are available as real colors in that space, which is a much simpler space than a typical CMYK space.

TL;DR

You need to define the space first. I.e. this is a non-answer answer. Kinda like a non-denial denial. Don't tell Bob Woodward on me.

—Andy

Andrew Somers
A Guy Obsessed With Color

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment