Wednesday, October 30, 2013

Tolerances for spot colors

There is a little bit of a hole in the most recent version of the ISO spec for flexo printing[1]. I will explain the hole, discuss my analysis, and provide a patch for this hole, but first a bit of background.

There is a family of standards called ISO 12647, which all cover printing. In particular, they provide some target color values, along with acceptance tolerances around those colors. In almost all case, those tolerances are in terms of ΔE, with the newer revisions of the standards shifting from ΔEab to ΔE00.

Part 6 of this standard is devoted to standards for flexographic printing. Flexo printing is used on such a wide variety of substrates that it is often not possible to nail a particular color. As a result, tolerances based on a ΔE-type color difference are not possible. One has to be content with getting the correct hue.

ISO 12747-6:2012 states target hue angles for C, M, and Y, and provides a ±6o tolerance. Spot colors are also given a tolerance in terms of hue angle, but it’s ±8o. Black, however, does not have a hue angle tolerance. This makes a great deal of sense, since black is neutral. The hue angle is undefined.

Tolerances from ISO 12647-6

But, “black” is not the only black. My Pantone book lists six shades of black. Presumably, the target a* and b* values for these inks are also 0, so the hue angle is undefined. This is the question that led to the realization of the hole in the standard: “how can analysis software decide if the ink name ‘midnight’ or ‘inkwell’ is equivalent to black?”[2]

Worse yet, what if the target for a spot color is not quite exactly neutral, but near neutral? If the chroma[3] of a spot color is small, then a tolerance of 8o might be impossibly tight. For example, in my Pantone book, the ink “Warm gray 5” has an L*a*b* value of {69.61, 2.58, 1.00}. Let’s say the hue of this ink is rotated by 8° to {69.61, 2.70, 1.63} so as to be at the very edge of acceptance in terms of hue. The color difference is a meager 0.38 ΔE00. Holding a printer to a 8° tolerance is pretty tight.

For highly saturated colors, a tolerance of a specified number of degrees around a target hue is perfectly reasonable. But as a color gets closer to a near neutral, it would be preferable to shift over to a ΔE00 tolerance. At what chroma value do you need to shift between a ΔE00 tolerance to a hue angle tolerance?

First naïve approach

I call this the naïve approach, because I am going to make a mistake. It turns out that the mistake is not huge, and it gives some intuitive understanding, so I will leave it in on this first pass. Watch for the mistake.

The figure below shows two colors r1 and r2, in the a*b* plane. Both have a chroma of c, but are separated by 8o. If r1 is the target hue, then r2 is at the edge of the 12647-6 tolerance window.

The arc length between the two colors is fairly trivial to compute. I could use the normal trig stuff, but since the arc is so small, I will just estimate the ΔE (which I a straight-line distance) with the arc length.

Thus, if we assume a tolerance of 1.5 ΔE, the crossover is close to a chroma of 10. Below that point, a hue tolerance is overly restrictive.

Second, not so naïve approach

Did anyone catch the mistake I made? Yes, you in the back? Ahhhh… the old accidentally used ΔEab instead of ΔE00 mistake! The formula for ΔE00 is just a tiny bit more complicated than the formula for ΔEab.[4]  So, I need a slightly less naïve way to look at this problem.

Suppose I picked a color at random, and then rotated it by 8° - that is to say, shifted the hue by 8° without changing L* or the chroma, C*ab. What is the color difference (in ΔE00) between the original color and the hue-shifted color? Then let’s say you computed that for a whole big bunch of colors just to see how it all played out. You would expect that, the larger the chroma, the larger the color difference, right?
Well, I just happened to have a large collection of colors (11,488 of them to be exact) just laying around from a blog of mine on counting colors. Below is a plot of the color difference caused by an 8° hue shift as a function of chroma.
Color difference caused by an 8° hue shift
Is this cool?

To answer the rhetorical question, yes, it is cool. But the data is a bit sparse down there in the lower left-hand corner around 1.5 ΔE00 where we are looking for our answer. This is not a surprise, since my color database only includes colors on a grid with spacing of 5.

So, I took a little different approach. For my next plot, I looked at points in color space with a chroma of 10. (This is the estimate we came up with by analyzing ΔEab.) These are all shades of gray, essentially, with a moderate amount of a color cast to them. I looked at how much color difference there was for each of them when they shifted in hue by 8°. The plot below shows this color change as a function of original hue angle.

The color difference caused by an 8° change in hue, as a function of hue angle

We see that the amount of color change oscillates between 1 and 2 ΔE00, so the average must be somewhere around 1.5 ΔE00. The true average is 1.45 ΔE00. Going back to Table 4 from ISO 12647-6, this is really close to the variation tolerance for spot colors.

For an ink with a target chroma of 10, a tolerance of 8° is roughly equivalent to a tolerance of 1.5 ΔE00.[5] Based on that, I have a simple recommendation for spot colors: If the target chroma is less than 10, then the appropriate tolerance is 1.5 ΔE00. For target chroma of 10 or greater, then the hue angle tolerance of 8° should be used.

Just in case someone wants to repeat this analysis for angles other than 8° or color differences other than 1.5 ΔE00, I provide the useful nomograph below. The t-shirt version should be out just in time for Christmas.

Nomograph for determining the crossover chroma
for various combinations of color difference tolerance and hue tolerance

The red line on the nomograph shows the determination of the crossover chroma between tolerances of 1.5 ΔE00 and 8° of hue. The graph shows a crossover at C* = 10.5. Just between friends, let’s call it 10.

[1] I am not blaming any of the diligent folks on TC 130 who reviewed this document. I was one of them!
[2] Thanks to Bruce Bachmann and Mike Sisco for this realization.
[3] I am using the word “chroma” to mean C*ab, which is defined as 

[4] Well, to be fair, the formula for ΔE00 is just a tiny bit more complicated than the formula to get a balanced budget.
[5] One caveat: I have made the assumption that the only change in color is in hue angle.

Wednesday, October 23, 2013

Color Picker Pen

(An update to this blog post can be found at "Scribble Pen".)

As John the Math Guy, people are always asking me stuff. Often the questions are like "When are you gonna get off that darn computer and fix that leaky faucet?" Or "Why are you so ugly?" These, of course, aren't really question at all, but every once in a while I get a real question. Today, the question was "how does this gizmo work?"

The gizmo in question is called the Color Picker Pen, designed by Jinsu Park. Lemme tell you, it's pretty cool.

You start by holding one end of the pen up to an object and clicking the color scan button. A color sensor measures the color of that object. In the picture below, the pen has picked up the green of the leaf, and note that the color display (along the side of the pen) has changed to indicate green.

Grab a color

So far, this is a cute little gadget. But now the real fun begins. This is a pen, right? The really cool thing is that you can now use the pen to write with whatever color you just scanned. Kind of like the Photoshop eyedropper tool, only it works in the real world rather than in the cyber world within Photoshop. (You know, where all models are a size zero, and don't have pimples or cellulite?)

Draw with that color


But I was asked to explain how it works. The answer is simple. It doesn't. Don't get me wrong. It's a great concept, a cool idea, but, at least as shown in the diagrams, it seriously won't work. And, it was never advertised as a real product. Actually, you can find a lot of websites by googling "color picker pen", and many of them refer to this as a "concept", an idea that has not been turned into a real product. 

Internal organs of the Color Picker Pen

The sensor

The sensor for this pen is plausible. There is a color sensor available from MAZeT that would fit the bill. This is a true XYZ sensor, which means that it is a bit better than an RGB sensor in terms of color fidelity. (An RGB sensor will see some colors distorted.)  The sensor itself is shown above... certainly small enough for the color picker pen. Below the sensor is a prototype board. At the right side of the board, you will see a USB connector, so that gives you an idea of the size of the board. If you remove the USB related components on the board - which would not  be needed - you might be able to fit the board into the end of a fat pen.

MAZeT sensor and prototyping board

Of course, a few things might be missing. If I were designing this, I would likely try to add a white LED because I wouldn't trust ambient light, which can vary in intensity by many orders of magnitude. And especially since the user would generally want to push this thing right up against the leaf, effectively shielding the leaf from any ambient light. But this LED might make the whole thing too large, since it would be necessary to shield the sensor from the LED.

There is still one thing that is bothering me about the sensor, though. Below I show a closeup of the sensor end of the pen. Anything funny about it? Think now. What color is the end? It's a dark gray?!?!?  Why would an optical designer put sunglasses over a color sensor? It's pretty dark. Just taking a wild guess, I would say that it reduces the light to the sensor by a factor of 10. Not a good thing.

Close up of the sensor end of the Color Picker Pen

So far, it sounds like this could perhaps be built, but that it is unlikely that the pictures represent a real design.

The display

The Color Picker Pen offers a nice feedback feature: the pen will light up to tell you what color ink is measured / loaded. Is this feasible?  I borrowed a pen that belongs to my wife to show that, yes, such an animal exists. Those of you who know my wife, I would appreciate if you didn't mention that I borrowed her pen. I told her I was going to be fixing that leaky faucet.

Pen for writing love letters in the dark

This pen has a battery and a blue LED. Clicking the switch on the top will turn the light on or off. This could easily be done with a tricolor LED so that a wide range of colors can be produced along the side of the pen.

The battery in my wife's pen reminded me of something else that is needed. In my palpable excitement over this pen, I forgot all about the need for a battery! I didn't see a place for one, or a way to replace it, but let's just say that could be done. Since there is no evident way to replace a battery, it is sounding more like this is a concept design, and not a real product or prototype.

The other electronics

Of course, maybe there needs to be a microprocessor as well? Ok... I guess we can make some space for that. Maybe it would fit? I dunno.

The inks

Now we come to the fun part. The ink. Once again, I have taken a close up of the internal organs shot. Quite clearly, it shows a red, a green, and a blue ink cartridge. That's where the color scientist in me immediately says "nope, not a real product".

Close up of the ink

Why do I say that? Well.... Lemme ask you a question. What color inks are used in your home printer? Red, green, and blue? Nope. Sorry. They are cyan, magenta, and yellow. Below you see the four printing inks from my home printer. Cyan, magenta, yellow, and black. No red, no green, and no blue.

The inks for my printer

Perhaps I just have a cheap printer, you say? Well, that's true, but let's consider the other end of the spectrum. I put my latest Boston Proper sales flyer on my scanner, and collected this image. Note, especially in the white of her alluring eye, that there are no red, green, or blue dots. The dots are cyan, magenta, and yellow. The printing press that this was printed on cost a little more than my home printer - I dunno the exact figure, but I am putting it around $10 million. They don't use RGB inks. 

The choice of CMY (with the addition of black) over RGB is a fascinating story. I will get around to telling it sometime soon. For the time being, let me say this. If you mix red and green ink, you get a dark and dirty brown, almost black. If you mix red and blue ink, you get a very dark blue, almost black. If you mix green and blue, you get another really dark color. So, mixing RGB inks, you can make red, green, blue, and three lovely shades of black.

Let's change up the inks. If you mix cyan, magenta, and yellow, on the other hand, you can get a whole bunch more colors. Cyan and magenta ink mix to make a purplish blue. Cyan and yellow make green. Magenta and yellow make an orangeish red. If you mix all three inks, you get a dark brown, almost black.

So, my assessment of the Color Picker Pen is that no one ever built one. If they had, they would have realized that red, green, and blue don't make for a very wide collection of colors. They would have then called John the Math guy to help them figure it out and I would have recommended cyan, magenta, and yellow. Since I never received such a call, I have to assume that the Color Picker Pen was never built.

So, why are color cameras RGB? And why is a computer display and a TV RGB? Questions, questions! I will leave them for another blog!