Wednesday, August 21, 2013

What color is human skin?

When I grew up, there was only one answer to the question "What color is human skin?" At the time I was born, Binney and Smith [1] had one crayon (called "flesh") for skin tone. Then in 1962, the company renamed the "flesh" crayon "peach" [2]. Then there was the Civil Rights Act of 1964. Finally, in 1992, Binney and Smith introduced their Multicultural Crayon set. This set includes six crayons that represent an actual range of skin tones: apricot, burnt sienna, mahogany, peach, sepia, and tan. White and black are included for mixing. Or maybe they were added because of the "eight crayons in a box" box rule. Either way, no one really has pure white or pure  black skin.
Photo egregiously stolen from Dick Blick website

The Humanae Project

I was excited this week when I found out about the Humanae Project. A lady from Brazil by the name of Angelica Dass has taken on the task of collecting images of a zillion people [3] to catch their skin tones. A small area of the image of each face was averaged and Photoshopped in as the background.  
Six of the hundreds of people who have volunteered for the project

How could I resist doing a little math on these images and blogging about it?

Visual look

At the time I looked, there were 420 images. I pulled the RGB values from the background of each of these images and went at it. The first look is a montage of all the colors. My impression? Each little box looks like a skin tone, but it does seem a bit light on the dark - that is - the darker skin tones seem under-represented.

A collection of 420 real skin tones

Here is another look at this data. In the graph below, each dot stands for one person's skin tone. The horizontal position of the dot gives the red value of the color, and the vertical position gives the green value. One thing that the graph shows is that there is a very definite set of colors that qualify as skin tones [4].

Red and green values of all skin tones in the collection

When I look at these graphs, I also see that, for the most part, the collection of skin tone colors form a nice line. Well, a nice crooked line. And maybe the line is kinda fat. Still, this says to me that you could make a pretty decent approximation of all the skin tones by assigning each of the skin tones to a single spot on that crooked, kinda fat line. To put this a different way, if you were to collect the 420 people in a room and ask them to line up in order from darkest skin to lightest skin, they would make a more or less smooth transition

I have done just that in the image below. Each person has a narrow vertical strip, and all the strips are arranged in order according to the average of the red, green, and blue values.

Another collection of 420 skin tones
"Everyone line up in order from darkest to lightest!"

If you stand back and defocus your eyes a bit, this looks smooth. This shows that skin tones form a line. But, if you look closely, many of the individual strips can be seen, contrasting with their neighbors as being perhaps redder or perhaps greener. This shows that the line is kinda fat. People with the same average lightness of skin vary a little bit on the hue of their skin.

This is consistent with a paper that is a lot more rigorous than this blog post [5]. Their conclusion is that one number is enough to characterize around 95% of the information in the spectra of skin. Well, I didn't need none of their sophisticated "principle component analysis" to show the same thing, did I? Show offs.

Motivation for the rest of this blog

I am about to dive into the deep end of the mathogeek pool. Before I do, let me provide some idea of the various applications--to explain why it might be worthwhile to swim in those slide-rule-infested waters.

Application #1 - Suppose someone wanted to generate skin tones of various ethnicity, maybe for a game or to create random avatars. Having a simple parametric equation that describes a wide range of plausible skin tones would be a great way to do that. The word "parametric" in the previous sentence means that you could randomly select a parameter (call it "k") that would be in some range of values (I dunno, maybe from -3 to +3), and the equation would give you an RGB triplet that would be a plausible skin tone.

Application #2 - Suppose someone wanted to find faces in an image. One of several necessary criteria for a pixel to be a face pixel is that the RGB values must belong to the club of plausible skin tones. So, it would be cool to have some sort of equation that describes the set of plausible skin tones, so that any given pixel can be tested for membership in that club.

Application #3 - Suppose someone wanted to characterize someone's skin tone. This characterization might be used to recommend makeup, or to categorize someone as having "winter" coloring. If there were a magic equation with a parameter it would be possible to find the particular value of that parameter which best characterizes the skin for that person. That parameter would be the characterization of that person's skin tone.

These applications all have to do directly with skin tones. I have a few other applications in mind that would use the technique that I describe.

Application #4 - Suppose some math geek (or more likely, a stats geek) needs a way to describe a set of multi-dimensional data--much like one would use mean and standard deviation to describe single-dimensional data. I describe a method below to determine the ellipse (or hyper-ellipse) that describes multi-dimensional data in a statistical way. Since I am not aware of a word for an ellipse or hyper-ellipse that serves as a proxy for a large amount of data, I will invent the word: proxellipse. The proxellipse is an extension of standard deviation to multi-dimensions.  

Application #5 - Suppose some other geek (maybe a scientist of some kind) wanted to display a scatter plot of two-dimensional data. If the scientist had twenty points in that plot, it would give some appearance of the amount of spread. But, if the scientist had two hundred points, the scatter plot would give the impression that the spread of data is far broader. The analysis below is an alternative. By displaying a scatter plot along with the proxellipse, one won't be misled by the crowd effect. The proxellipse would show the boundary in which a certain percent of the data will likely fall (with all the normal assumptions about whether the data is normally distributed).

Statistical look

The graph below is the same data as the red/green plot above, only this time, I am looking at red versus blue values. This perspective shows a bit more crookedness. It looks like there are two separate populations: those with darker skin, and those with lighter skin. It looks like two different lines are needed to describe the different sets. 

Red and blue values of same data, with a discontinuity highlighted

So, there is a crooked line in RGB space that defines skin tones. For the sake of simplicity, I am going to start by looking at the statistics of just the brighter dots (where R > 180, G > 120, and B > 110). This reduced the set from 420 data points to 404. To be clear, I am quite literally discriminating here on the basis of skin color, excluding the darker skin tones. I apologize, but the darker tones belong to a different statistical distribution. 

Now it is my turn to show off some really golly-whiz bang math. This is a green/blue view of the segregated data points, with a red line showing three axes of an ellipse. This ellipse is the proxellipse (with coverage of 3), which is an ellipse that is basically in the same shape, size, and orientation of the data.

Green and blue values of skin tones, with the axes of an ellipse shown in red

Now I'll say a bit more about the proxellipse. It's a statistical thing. Essentially, I have extended the idea of standard deviation to three dimensions. The size of this proxellipse is three standard deviation units in each of the directions. Now, I assume that I am not the first to discover the technique, but it would appear that this technique is not well known in the color science community [6]. Or maybe it's just a dumb idea?

Getting back to the kinda fatness of the line. The degree of kinda fatness can now be quantified. To demonstrate that the data points here are very close to being a line, the length of the major axis is 28.8 gray values. The other two minor axes are 5.3 and 3.3 gray values. For those who don't recall, 28.8 is much bigger than 5.3 and 3.3.

An algebraic look

Let's just pretend that someone wanted to come up with an equation that could be used to generate a sequence of reasonable skin tones. I called that Application #1. One approach would be to apply linear regression to any of the graphs above. One might, for example, determine a best fit function for G as a function of R, and another regression would determine the best fit of B as a function of R. In this way, the value of R is a parameter that can be used to determine the other two color coordinates.

This may work, but I have some reservations about this technique. First, such a regression treats R as an independent variable and G as a dependent one. Really, the two should be in the same category. It seems like something must go wrong. (OK, that's just a philosophical argument.) 

Second, the choice of expressing G as a function of R, for example, is a bit problematic due to the relatively steep slope. A small change in R will cause a large change in G. And (the important part) a small change in the random data will cause a large change in the slope that is calculated through regression. That's a bummer.

Third, I have a little known fact about statistics. Garden variety linear regression starts with the assumption that there is no noise in the independent variable. That is to say, it is based on the assumption that we know the R values perfectly, and any deviation from a straight line is strictly because of random variation in G. Now here is my little known fact: If you add random noise to both of the variables in a linear regression, the slope of the regression line will move toward zero. The noise in the independent variable adds a bias.

So... how about another approach? Using my proxellipse analysis, I arrived at the following equations for the RGB values of the skin tones:

     R = 224.3 + 9.6 k
     G = 193.1 + 17.0 k
     B = 177.6 + 21.0 k

When k is allowed to go from -3 to 3, this will provide RGB triplets for reasonable lighter skin tones. The following equations will give reasonable RGB triplets for darker skin tones.

     R = 168.8 + 38.5 k
     G = 122.5 + 32.1 k
     B = 96.7 + 26.3 k

I apologize again... I have created separate but equal equations. <sigh>

Caveats

Science?
As a scientific experiment, this is perhaps not controlled enough to be accepted into a peer reviewed journal. Now, I have every reason to believe that Angela has controlled conditions as best as she can. But, she is using a camera, and cameras are not color measurement devices. As far as I know, she has not provided an image with a Munsell color checker card that would serve to calibrate the colors to real units. There isn't a statement about the type of camera or the settings. In particular, there is no statement of the gamma setting of the camera. (Gamma is a setting that will increase the brightness of midtones in order to give the picture a better appearance. Most cameras have this enabled by default, and it gets in the way of accurate color measurement.)

But these are not my big bugaboo. RGB cameras (at least almost every one on the market today) do not see color the same way we do. The red, green, and blue filters in a camera do not give the camera the same spectral response of the three cones in the eye. I investigated this in my paper Why do Color Transforms Work?

Also, the RGB response differs from camera to camera, so as they say, results may vary.

Ideally, the purist in me would like to see spectral data on everyone's skin, but the purist in me is too darn mired in the details to ever get a blog out. And besides, the images on her website do all look like reasonable skin tone on both of the computer monitors that I routinely use.

Skin blemishes and goniophotometry and umbrophotometry

This analysis is rather simplistic in that it associates one single RGB value with the color of a person's skin. That's just plain silly, for two reasons. First, skin is not uniform in color, especially as one gets older. Second, the color of the skin (and just about anything for that matter) depends on the angles that it is illuminated from and the angle from which it is viewed. If the lighting angle, surface orientation, and the camera are all at the right angle, you can see a very white specular reflection on a surface. This effect is called goniophotometry, the measurement of light as a function of angle.

The third effect is that there are generally shadows on a person's face. Even when illuminated diffusely, there still may be (for example) an area under the nose [7] that is darker because of the shadow. Clearly this effect is accentuated in some people. I have just this moment coined the word "umbrophotometry" to characterize the measure of this effect. "Umbra" means shadow, and is the root of the word "umbrella".

--------------------------------------------
[1] There used to be a company named Binney and Smith. In 2007, the company name was changed to Crayola. Clearly if I talk about stuff they have done after 2007, I should refer to them as Crayola, but how do I refer to the company back before it changed its name? Is it Binney and Smith, or Crayola? And when I want to talk about the guy who won the 1985 Grammy for the Album of the Year, do I refer to him as Prince, the Artist Formerly Known as Prince, or the Artists Formerly Known as the Artist Formerly Known as Prince? [8]

[2] Personally, I don't think that "peach" is quite the right name for that crayon. Maybe I'm wrong, but I think that peaches are more of an orange color than the crayon. I don't have a better suggestion, mind you. I just like to kvetch.

[3] I could have said that she is taking pictures of a brazillion people. Give me credit for not going for that pun!

[4] I am being a bit loose here, since I have only shown the view of R and G. The other views are pretty similar, though.

[5] Sun and Fairchild, Statistical Characterization of Face Spectral Reflectances and Its Application to Human Portraiture Spectral Estimation, Society for Imaging Science and Technology, Volume 46, 2002
http://www.cis.rit.edu/fairchild/PDFs/PAP14.pdf

[6] ASTM 2214 (2002), Standard Practice for Specifying and Verifying the Performance of Color-Measuring Instruments (Section 6.1.1 anticipates my technique. They are discussing a way to evaluate the variability of a collection of color measurements and state:

"Since color is a multidimensional property of a material, repeatability should be reported in terms of the multidimensional standard deviations, derived from the square root of the absolute value of the variance–covariance matrix."

Egg-headed stuff, indeed. If only they knew my method when they wrote that!

[7] George Carlin informed a generation of people that this part of the body is called the philtrum.

[8] This was a trick question. The correct answer is "Lionel Richie". Prince's album Purple Rain was nominated in 1985, but Lionel Richie's Can't Slow Down won the Grammy. 

Wednesday, August 7, 2013

Lousy weather every weekend

It was a Monday after a rainy weekend. Naturally, since I had to go to work, the weather was excellent. I was particularly downcast since the weather had put a damper on the previous weekend as well. I mentioned it at work, and got a surprising response.
Actual photo of me enjoying the lovely weekend weather [1]

I should tell you that this was quite a long time ago, back before Al Gore invented the internet. I was working at the University of Wisconsin Space Science and Engineering Center. You would think that with name like that, we would all be working on something dull like a space telescope, a Mars rover, or a space shuttle porta-potty. But it was far more exciting. We were crunching data from weather satellites.

Getting back to my story about a forlorn math guy complaining about the weather, when I made my comment about two weekends lost to lousy weather, I just happened to be surrounded by meteorologists. I was told that everybody knew that weather was cyclical, and it tends to follow a weekly pattern. If you know the weather on one particular Saturday, then you have a darn good guess at the weather the following Saturday.

I have used this factoid frequently. It always sounds impressive when I tell people what next weekend's weather is going to be like. I should say, it sounds impressive when they believe me. Whether my prediction comes to is actually irrelevant. No one remembers my predictions.

Is the "weekly weather pattern" factoid for real? I put it to the test.

The data  

It isn't hard to find information on the current weather conditions. But yesterday's weather? That's a bit harder to find. And historical data? I found  a place to dig up old weather. [2]

I downloaded four year's worth of weather data from Milwaukee; from July 22, 2009 to July 22, 2013. Why four years? Well... there is a story there. Once upon a time, there was a computer magazine called Byte. It was the magazine for computer geeks. They published an article with a BASIC program for doing a fast Fourier transform. I dug into the code and found it wasn't remotely the FFT (fast Fourier transform) algorithm that Cooley and Tukey made famous. Later, they had an article that looked at sales data that spanned many years of time. They said that a "four year analysis" was used to look for trends. I dropped my subscription. [3]

Mean temperature, Fourier anaylsis

Let's look first at the temperature (see plot below). It is apparent from the sine wave kinda thingie in the plot that I have collected four years' of data, and that the start of the data is kinda mid-summer.
Average daily temperature in Milwaukee over the past four years

That graph is and of itself is pretty cool, but playing with the data? I don't know about other math guys, but the first thing I like to do when I get a new fresh pile of data is to start taking Fourier transforms. It took a bit of massaging of the raw FFT output, but here is a graph showing a section of the frequency data. This graph shows the strength of the periodicity going from a four day period (on the left) to a 10 day period (on the right). There is no discernible peak or bump near the once-per-week mark.

FFT of the mean daily temperature

Correlation

Here is another look at that same data. In this case, instead of doing the whole Fourier bit, I did some correlations. I check to see if the daily temperature on a given day correlated with the daily temperature on the previous day. So... an array of four years of data, 1462 data points. I computed the correlation coefficient between two sub arrays, one going from day 1 to day 1461, and the other going from day 2 to day 1462. Then I computed the same thing, only with a lag of two days, and three days, and so on.  

The graph below shows the results. At the very, very left, the correlation between each day's temperature and that same day's temperature is 1.0. Well, duh. The temperature on a given day looks a heckuva lot like the temperature on that same day. The plot below shows that today's temperature also looks a lot like yesterday's, with a correlation coefficient of close to 0.95. In the middle of the chart we see the correlation of today with one week ago. According to the hoity-toity meteorologists, I should see a big spike there, but no. Using the temperature a week ago to predict today's temperature is good (r = 0.85), but it is no better or worse than using the temperature six days or eight days ago.

Correlation coefficient of temperature as a function of spacing (in days)

So, I would say this myth is pretty well busted. That's the way I like my myths: pretty and well-busted. Temperature does not follow a hebdomadal pattern. That's a pity. It would have explained why a week isn't six days, or (shudder the thought!) eight days.

But wait! What about rain?!?!?

I missed something here, didn't I?  This blog post started out talking about rainy, not temperature. Maybe I should have a look see at the rain data? Luckily, this database contains precipitation data, as well as wind speed and direction, barometric pressure, humidity, ... but all I want is the rain data.

I present below another correlation chart, this one showing the correlation of precipitation. There it is, as plain as the nose on Owen Wilson's face, a spike at lucky seven. There is a correlation (r = 0.1). This is roughly in the range of 99.95% significance range. So. Maybe my meteorologist friends weren't all that dumb after all?

Correlation coefficient of precipitation as a function of spacing (in days)

I should make a comment here about how big the number 0.1 is when it comes to correlation coefficients. Let's just say that Norm decided to make some money on these results. Every night, for four years, he would sit at a bar in Milwaukee, and take bets on whether it would rain the following week. I know, ideal job, right? If Norm follows the advice in this blog, betting that the rain today can predict that of one week from today, I guarantee that he would come out ahead at the end of the four years.

Norm, pondering this money-making scheme

On the other hand, the number 0.1 is very tiny. The predictive strength when r = 0.1 is on the order of 0.005. That's an indication of how much the odds are in Norm's favor. He is pretty sure of making money, but he needs to make a lot of bets to get there.

This may sound like a bad business model, but this is how casinos work. They want to run games where the table is tilted ever so slightly in their favor. Too much of a tilt (too low a chance of the patron winning), and people will walk away. Too little of a tilt, and the casino won't make a buck.

Another comment on the plot above. There is also a peak out at 29 and 31 days. Hmmmm... Maybe this is the effect of the moon?

---------------------------------
[1] If truth be told, although I have sung before, and have been in the rain, but this is actually a picture of Gene Kelly, not me. If more truth be told, Jean Kelly is my sister. Here is my favorite painting of hers.

[2] If truth be told, I didn't find this website on my own. Nate Silver told me about it. If even more truth be told, he didn't actually tell me in person. I read it in one of his books: The Signal and the Noise: Why So Many Predictions Fail — but Some Don't. He and I are good buddies. At least we would be if we ever met. That's my prediction.

[3] I had a house that I was getting ready to sell. The realtor told me that the entry way needed work - first impressions and all that. Updating this would give the whole house a new image. So, I gave it a fresh coat of paint, updated the light fixture, and polished up the handle of the big front door. I guess you could say that I performed image enhancement through a fast foyer transform. Some of you will find this joke incredibly funny.



Wednesday, July 31, 2013

The color of a bunch of dots, Part 4

If you have been wondering for years about TVI bananagrams, you have come to the right blog post. This blog post is the definitive blog post on TVI bananagrams. But if (for some crazy reason) you have not been wondering all your life about TVI bananagrams, then this could still be a watershed moment in your understanding of dot gain and its fuzzy sister, tone value increase.

Cyana bananagram

Dot squish

Pat Noffke and John Seymour presented a paper at TAGA in 2012 entitled A Universal Model for Halftone Reflectance. [1] In the paper, they developed an equation for what they called Dot Area Increase. This is a measure of how much a dot squishes out when it hits the paper. This is similar to what Murray and Davies called dot gain, but there is one novel difference. In both models, dots get bigger when they hit the paper, but in the Noffke-Seymour model, they also get thinner because of the whole law of conservation of ink thing. Because the dots are thinner, the color of the dot is less rich than the solid.

A halftone dot, before and after the steamroller

If there isn't any dot squish for a particular hypothetical printing, then a 30% dot would cover 30% of the area, and the thickness of the dot would be same same as the thickness of the solid ink. This hard dot has no dot area increase. The equation for reflectance in this case is the Murray-Davies equation.

Murray-Davies equation for hard dots

At the other extreme, the dots squish out completely so there is no longer any semblance of the dot structure (think gravure). Perfectly soft dots. Contone - continuous tone. At this extreme, one can use Beer's law to estimate the reflectance of a halftone. You will no doubt recall the equation from my blog on Beer's law
Beer's law equation for continuous tone

I should add here, that the two equations here should be applied on a wavelength by wavelength basis.

I should also 'splain a bit about the "Ain" that is being used as an exponent. Normally in Beer's law, this is where you would put something to do with ink film thickness. So, why did I stick the dot area in that spot? Imagine that you start out with perfect, hard halftone dots that are, I dunno, 30% dot area. Since they are perfect, let's just assume that the ink thickness of the dots is the same as the thickness of the solid.

Now, let's say that these dots get stepped on by an elephant. They are squished out so as to cover the whole area uniformly. How thick is the ink now? If the original dot area is 30%, then the new ink thickness is 30% of that of the solid. So, the exponent of Ain represents the thickness of the fully squished out dots.

Poor defenseless halftone dot, about to become a continuous tone

The dot squish equation

The pure genius of the Noffke-Seymour paper is that they considered what happens in between. In the figure below, the left side shows the starting condition. The halftone dot covers 25% of the area, and has the full thickness of the solid. The right side shows what happens after squishing [3]. The dot now covers 39% of the area, and as a result, is thinner by whatever ratio is necessary to preserve ink volume. I dunno? Maybe the ratio is 25% / 39%? I guess that's about 0.64. [4]

A tale of two halftone dots

Using the halftone dot at the right to illustrate the Noffke-Seymour formula, Beer's law is used to estimate the reflectance of the light blue area covered by ink. A thickness of 0.64 (as compared with the thickness of the solid) is used. Since a wandering photon has a 39% chance of hitting the area covered by ink, this reflectance is multiplied by 39%. This accounts for the light that reflects from the ink. The remaining photons will hit the paper, so (in true Murray-Davies fashion) the reflectance of the paper is multiplied by 61%, and this is added to the first number.

The equation below tells the whole story. "Ain" is the dot area going in. In the example above, this would be 25%.. "Aout" is the final area of coverage after squishing, 39% in the example.
The beautiful Noffke-Seymour equation

Note that at the extreme of no squish, Ain = Aout, the equation simplifies to Murray-Davies. At the other extreme, then Aout = 1, and this equation simplifies to Beer's law. 

In the first big finding, the authors of this paper looked at spectra from a big pile of tone curves, and came to the conclusion that pretty much every printing modality (web offset, stochastic web offset, gravure, newspaper, flexo, and ink jet [5]) all fit conveniently between these two extremes. This is huge. (But that's just my opinion.) Tone value increase for any type of printing can be described in terms of how broadly the dots squish. That's all you need to know.

Finally, the bananagram

I have saved the best for last. The other huge finding is shown below, the invention of the bananagram [6]. The bananagram below is an a*b* plot of all possible tone curves for a given cyan ink [7]. The left edge of the banana is the tone curves generated by assuming that the halftone dots are perfectly hard. The right hand side is a similar curve made with the assumption that the dots are perfectly flattened out.


Cyana bananagram

Now, lemme tell you about the rainbow colored lines. The yellow line, as an example, is all possible a*b* values that a 40% cyan halftone dot could take. Starting with a perfectly hard 40% cyan halftone, as you gradually squish it out, you will see it trace out the curve from one side of the banana to the other.

Wow. The position along that line tells you how hard the dots are. If you know the dot hardness (along with the spectra of the solid and the paper, and the original tone value), you can figger out the color of the halftone.

Foreshadowing the next blog post

I need to eventually tie up at least one loose end. I have been throwing dot gain kind of equations around willy-nilly, or perhaps yuley-niely. We have (so far) the following three equations to explain the color of a halftone: Murray-Davies, Yule-Nielsen [2], and Noffke-Seymour.

Murray-Davies (we all know) is a lump of over-cooked turnips when it comes to accurately predicting or measuring color. Yule-Nielsen, seems to be all the rage. Then these young upstarts come along with yet another formula that is gonna save the world! How can this all be reconciled?

Stay tuned for the thrilling conclusion!

----------------------------------
[1]  I know these guys. One of them seems to be around whenever I stop at the bar for a beer. I guess he must hang out there a lot. Anyway, these two guys do bunches of seriously good stuff. And they're modest, too. Well, at least one of them is.

[2]  If you have been paying careful attention, you will notice that I have reverted back to the more common spelling the the latter gentleman's name. In a previous blog, I cited the original paper from the TAGA Proceedings, along with a scan of the heading for this paper. In the original published paper, the name is spelled "Neilsen", which is contrary to virtually every citation of the name. I ranted and raved about how 11,400 patent citations use the misspelling "Nielsen". As such, I would imagine that these 11,400 patents are potentially invalid. Gary Field did some excellent detective work, and has convinced me that the TAGA paper is a transcription error. The gentleman's name is Waldo J. Nielsen. Assignees of these patents can breathe easier.

[3] I keep talking about squishing, but this might not always be the case. In a web offset press, where there is a lot of pressure between the plate and the blanket and the paper, then squishing is probably a valid term. But in the case of gravure, where the ink has a very low viscosity, maybe it's not so much squishing as it is just spreading out. In newspaper, where the paper does not have a coating, maybe the significant effect has more to do with the ink being wicked into the paper. All of these I have put under the umbrella term "squishing." Whatever you squish under your umbrella is your own business.

[4] How should I know what the ratio is?  Am I called John the Arithmetic Guy??!?!?

[5] No data was harmed in the filming of this experiment.

[6] I expect to see bananagram T-Shirts available on the internet. There will be bananagram support groups for people who have family members sucked into the cult. I expect this will be a topic in the next state of the union address, with plenty of polarized commentary on Fox News and MSNBC.

[7] In three dimensions, this is a surface, sort of like a fly's wing or a sail. In other words, the possible range of colors of a halftone of a given ink can be described by a three dimensional figure that looks like a fly's wing.

Wednesday, July 17, 2013

Ruminations on beer

The word "beer" has occurred in 14 of my blog posts so far. Go figger. As all my friends know, I don't even like beer. And I always tell the truth in my blog posts.

Beer is frequently featured in my posts because of Beer's law. I am probably the first person in history to remark on the connection between August Beer's name and the yellow, foamy liquid. And I am certainly the first person to use actual beer to demonstrate Beer's law.

Beertones

Beer's law is a law about light and color measurement. So, you can imagine my delight when the world finally got serious about measuring the color of beer! The Beertone guide below puts an end to all those arguments in the tavern about whose beer is darker, and allows you to order beer buy RGB value. A simple flip of the deck under properly calibrated lighting can identify the color of each and every beer in the Beertone database.


The legacy of Hugh Beaver

Speaking of bar arguments, Sir Hugh Beaver was a guy very interested in eliminating them. He was on a hunting trip and found himself amidst an argument about whether the golden plover or the grouse was the fastest European bird [1]. He found it devilishly hard to research the question, so he decided to create a book to answer all such questions. What does this have to do with beer? Sir Hugh Beaver was then the director of the Guinness Brewery [2]. Originally, it was just a marketing gimmick. He soon realized that this was a bonafide business in its own right.  

Hugh Beaver of Guinness and Hugh Beaumont of Leave It to Beaver
Two lives inextricably intertwined

Speaking of publications from Guinness, the book of world records was not the first time that the Guinness Brewery became famous for its publications. The so-called "Student's t-test" came out of that little place in 1908 [3]. William Sealy Gosset was researching ways to improve all matters having to do with barley and yeast, and beer production. At the time, he thought his work was of little consequence. Little did he know that his name was to go down in the history of statistics. 

Well, his name didn't quite go down in history, but his pseudonym did. It seems that a previous Guinness employee had spoiled the water. Trade secrets had been published, so Guinness adopted a policy that employees were not allowed to publish anything. Gosset negotiated an agreement with Guinness where they allowed him to publish so long as he published under a pseudonym and did not publish any of their data. The stated author of this landmark paper in statistics (March 1908 volume of Biometrika) was "Student" - hence the famous Student's t test that everyone in Stats 201 promptly forgot after the finale exam. 

The amazing world of Guinness bubbles

Speaking of bar arguments and Guinness, to this day, there has been an ongoing argument about the direction of the flow of bubbles in a freshly poured pint. It appears that bubbles travel downward, rather than upward as one might expect. One enterprising group of scientists at Stanford University headed down to the pub with a high speed camera to test this. Optical illusion, or fact? Their conclusion was that the "...bubbles at the center rise up and create a circulation in the glass.  The circulation causes bubbles at the edge of the glass to be pushed downwards."
OMG! The bubbles really do head for the bottom of the glass!

This is not the last word, by any means. The critical research continues. Last year saw the publishing of a paper at Cornell which literally turned the world of fizzy-ology upside down:

"In this paper, we use simulations and experiments to demonstrate that the flow in a glass of stout beer depends on the shape of the glass. If it narrows downwards (as the traditional stout glass, the pint, does), the flow is directed downwards near the wall and upwards in the interior and sinking bubbles will be observed. If the container widens downwards, the flow is opposite to that described above and only rising bubbles will be seen."
Pint and Anti-pint

Just as an aside, I tried this experiment at home. I could not replicate their results. Every time I turned the pint glass upside-down, all the bubbles headed downward. Along with the stout.

But the two previous explanations lack the big words to give them the level of pretension that the whole topic deserves. This following paper provides adequate levels of pretension. The lead author is from Limerick, Ireland, so she no doubt is an expert on stout. (Guiness is headquartered in Limerick.) Here is what she has to say:

"Our theory involves a physically based regularization of the basic equations of the two-phase flow, using interphasic pressure difference and virtual mass terms, together with bulk or eddy viscosity terms."

I offer the following as an alternative for the abstract: [4] 

There were some researchers from Limerick
Who proved bubbles go down - quite a mean trick.
They modeled two-phase flow 
To explain why it's so
With a pressure difference interphasic.

I am guessing that my own name may not go down in history as the author of the first limer-abstract. It's a shame. But I realize that this limerick won't get much airplay because limericks are supposed to be naughty. [5]

To beer or not to beer?

Speaking of "naughty", what about beer and human mating rituals? 

I have been reading a delightful blog by Christian Rudder. He has the enviable position of being allowed free access to the scads of data from the dating site "OkCupid". They have a database with zillions of questions, answered by zillions of people, and he has been doing correlations to find answers to which of these questions correlate with each other. For example, one would expect that if someone identified themselves as being into Harleys and Metallica, it's likely that they would also be into My Little Pony. His data can answer that. 

But Christian wasn't really looking for My Little Pony fans, he was looking for something more practical. I am guessing that he knew something that I discovered the hard way--the Heisenberg Uncertainty Principle of First Dates: The mere act of asking a woman if she might be willing to smooch on a first date will effect whether she will. Generally speaking, I found that the effect is negative.

So, Christian wanted to know what "safe" question you could ask on a first date to get some indication as to whether you might get lucky. He had the answers to the question "would you consider sleeping with someone on the first date". And he had answers to a zillion other questions. Here is the astounding revelation in his blog post about safe questions for a first date. "Among all our casual topics, whether someone likes the taste of beer is the single best predictor of if he or she has sex on the first date."

Ask her if she likes beer!

Speaking of dating and beer, let's talk about beer goggles. Do "the girls all git purdier at closin' time", as the song says? Amanda Ellison, senior lecturer in the Department of Psychology at Durham University and author of the book "Getting your head around the brain" would like to dispel the rumor of beer goggles. Here is what she has to say about the effect of alcohol:

The area of the brain that makes us want to mate keeps functioning, no matter how much we drink, meaning that people can still assess how visually-appealing others are. ...alcohol switches off the rational and decision making areas of the brain while leaving the areas to do with sexual desire relatively intact, and so this explains beer goggles. 

Before and after that third pint of Guinness

We don't rate people as getting more attractive when we have a few under the belt. We just get better at making bad decisions. And mind you... those decisions often find us getting into trouble with the law. Beer's law.

------------------------------

[1] Apparently the question about whether the African or the European swallow was faster is uncontested, since the bridge keeper at the Bridge of Death is the sole decider of Truth.

[2] This epiphanic moment that marked the nascence of the Guinness Book of World Records was on my birthday, November 10. Beaver was born in Johannesburg in 1890. I visited Johannesburg 120 years later. I once had a copy of the Guinness Book, and I once had a Guinness beer. To the best of my knowledge, neither Hugh nor myself have ever robbed a bank. The coincidences are endless.

[3] Student's t test is not (as you would expect) an annual competition sponsored by some school between Lipton, and Bigelow, and Celestial Seasons. It is a method in statistics that is used to test the validity of experimental results. Suppose I want to find out if having a couple of beers for breakfast will improve the appearance of my hair. I run a number of trials, on some days I have my normal breakfast of two beers, and on other days I abstain. For each day, I count the number of compliments I get on my hair. At the end of the experiment, if I get more compliments on beer days, it might be because the beer really does make my hair look better, or it could just be random. For example, maybe on beer days, I just happened to get served more often by that cute young gal at Starbucks who has a crush on me. Student's t test is a way of gauging the likelihood that the experimental results might just be random chance.

[4] I am following my normal practice of poking fun at things that are too difficult for me to understand. Its a defense mechanism.

[5] (From the Wikipedia entry on limericks) Gershon Legman, who compiled the largest and most scholarly anthology, held that the true limerick as a folk form is always obscene, and cites similar opinions by Arnold Bennett and George Bernard Shaw,[5] describing the clean limerick as a "periodic fad and object of magazine contests, rarely rising above mediocrity." From a folkloric point of view, the form is essentially transgressive; violation of taboo is part of its function.



Wednesday, July 10, 2013

"Is my green the same as yours?", revisited

Last May, I wrote an insightful and compelling blog post about whether we all see colors the same way. In my normal clever way, I called it "Is your green the same as my green?" Just a few days ago, I was given a bunch of really cool data that allows me to take another look at this question.

Background 

First, I need to tell you about Dr. Sophie Wuerger's recent paper, entitled "Colour Constancy Across the Life Span: Evidence for Compensatory Mechanisms". It is obvious that this is a scholarly paper because she spells "color" with a "u".
This technical paper is clearly above my head

Spoiler alert: I am about to give away the ending to her paper. If you don't want me to spoil a great story, then stop reading my blog. Go read her paper. Now.

It is well known that our vision changes as we age. For example, I used to enjoy lite beer. Today? I prefer to curl up with a darker beer. This is obviously due to the fact that the lenses in my eyes have slowly yellowed as I have aged [1]. For those of you are ardent fans of my blog, you already knew about the yellowing of the lens. I talked about that as one of the reasons that I may not see colors quite the same as someone who is still young enough to enjoy lite beer.

Well, Dr. W. completely spoiled that for me! Although the actual stimulus provided to the brain changes with each page of the calendar, Sophie's research shows that the brain corrects for the yellow sunglasses that we don in our old age.

So, in my last informative blog post on the subject, I concluded that the way we see color depends on how old we are. And then here comes along some research -- and research by a person who spells color with a u -- that says that somehow our perception of hue does not change that much as the lens yellows. I quote from the actual paper:

"Our main finding is that colour appearance mechanisms are to large extent unaffected by the known age-related changes in the optical media (yellowing of the lens) whereas the ability to discriminate between small colour differences is compromised with an increase in age."

Wow. Color me flummoxed. A yellowish shade of flummox.

Sophie's Choice
Here is the gist of her experiment. She sat 185 people (aged 18 to 75) in front of a computer monitor and displayed for them a selection of splendid colors [2]. The task before the experimental subjects was to select the color that was either the purest red, green, blue, or yellow in color. For example, a range of colors that were all kinda red in hue would be displayed. All of the colors would have roughly the same brightness and saturation, but would differ in hue. The simple question was phrased like this: "which of the colors has neither a yellowish or bluish shade?"

This test was performed with four color groups: red, green, yellow, and blue. (Yes, Billie, I can see your hand going up. You recognize those colors. I'll get to that later, ok?)  For each of the color groups (hues), there were nine different colors that were investigated.

In a previous blog post about organizing crayons, I introduced a fabulous diagram that helps even the mere novice understand color space. Each of the pages in this diagram represents a different hue. I have shown red, green, and blue, but there are of course a whole bunch of them. Maybe a hundred? Maybe a few hundred?
A fabulous diagram that helps even the mere novice understand color space

Let's just take a look at one of those pages (see blow). This page has all the colors that have a hue of red. Note that I have put nine "X" marks on this page. Those marks show roughly the nine "colors" (combinations of saturation and lightness) that were investigated.

Confused yet?  Let me summarize. There were four hues investigated (red, green, blue, and yellow). For each of these four hues, there were nine different investigations. Ok, so that makes investigations of 36 different colors.

Now, for each of 36 investigations, each of the guinea pigs [3] was asked to select from a zillion and a half different hues to find the one that most exemplified the trustworthy and faithful hue that we have come to know as "red". That was Sophie's Choice.

Here I have another view of the points in color space that were involved in this test. Here, we are looking at color space from above, so that the horizontal axis is the reddishness to greenishness, and the vertical axis is the yellowishness to bluishness. (Yes, Billie, those same four colors came up yet again. Hang on. I'll get to them. Yes, I know that something odd is going on.)
Really cool propeller-gram from the really cool experiment

Now I need to say one more thing about the diagram above. The points in the diagram are not "all the available choices". They are the colors that the experimental subjects actually chose as being red, green, blue, or yellow in hue.

Wow. You know... these results are pretty darn far flung. I'm not liking that. It kinda makes me think that we can't even agree on what red is! No wonder my gorgeous wife and I have trouble agreeing on color names as I reported in my post about spectrophotometric agreement!

But wait just a gol durned minute
The really cool propeller-gram showing the really cool results from a really cool experiment is also a really cool example of a misleading graph. I will zoom in on just one of the red investigations, the one with the highest saturation.
Looking at just one of the investigations

Each of the red dots represents an answer that at least one person (out of the 185) selected. In some cases - the cases where the dots are most far-flung - there was exactly one person so audacious as to say that this represents a true red hue. In the dots that are closer to the center of the line, there are literally zillions of people who chose that answer. The graph does a really lousy job of differentiating the popularity of the various answers [4].

The graph below is a less distorted way of looking at the same data. This is a histogram, showing that there is a pretty tight clustering. The labels are hard to read unless you double click on the image, but about half of the subjects selected a hue angle between 16 and 18 degrees. I am going to call that pretty darn tight, and make the declaration that we all can agree on at least the hue for "red".
Histogram of hue angle for one of the red investigations

What do red, green, yellow, and green mean?
And now for the big moment. Finally. A definition of these four hues!
Note: The uncertainty column was determined by computing the standard deviation of the hue angles, and dividing this by the square root of the number of observations. This is an estimate of how close the average is to the "real" value.

Note: The table above is just the averages for one investigation of each of the four hues. I have not yet looked at all nine. Also, Sophie has provided me with gobs more data. This is only the "dark adapted" data.

Something odd is going on with my Hering
Billie, now to your question. First you noticed that the four hues that Dr. Wuerger chose were red, green, yellow and blue, and that these are the colors of the four chromatic directions in CIELAB space. Very good, Billie. You have been paying attention.

This whole idea of the names for the four directions goes back to a fellow by the name of Ewald Hering. He came up with the idea that we perceive color based on three sets of opponents. Colors are either reddish or greenish. Colors are either yellowish or bluish. Colors are either light or dark. Any color can be defined by where it rates in each of those three attributes.

Noted color scientist Ewald Hering, and noted food of color scientists

Now Billie, you had another question? Yes... you looked at the graph labelled "really cool propeller-gram from a really cool experiment" and started thinking about Hering's theory? What really cool thing did you notice about the graph? OH?

Green is not diametrically opposed to red. To be precise, they are not 180 degrees apart, but about 143.  And blue and yellow are not either. Yellow and blue are about 120 degrees apart.

Hering was wrong? Heresy. Pure blasphemy. I should clarify... The theory is correct qualitatively. But to be quantitatively correct, you need to adjust the meaning of the words. "Pure red" and a certain shade of bluish green (maybe cyan?) are opponents. And "pure yellow" and a certain shade of reddish blue(maybe violet?) are opponents.

This is work in progress. I have just started analyzing the data that Dr. Wuerger has graciously shared with me. But let me tell you one thing... If I ever invent a color space of my own, red is going to lie right on the horizontal axis, and not some silly 16 degrees off.  And I am going to try to get yellow right on the vertical axis. And I am going to try to resolve the issue of what the true opponents of these colors are.

Oh... and my new space is going to be perceptually linear, gosh darn it. None of those ugly deltaE 2000 equations. And I will call the axes JMG.

-John the Math Guy

-----------------------------
[1] My predilection for the darker and more full bodied beers is well known. This is often cited in the technical journals as further proof of the yellowing of the lens. There has also been considerable speculation about whether this penchant for dark and full bodied extends from beer to my taste in women. I decline to comment on this controversy. I think it's just silly.

[2] Think of that. 185 people. In front of one computer monitor. She must have the most awesome huge big screen TV in her neighborhood! I know where I am going to watch the next Academy Awards... Wait... they weren't all in front of the monitor at the same time? Oh.  Ok, so I am still open to invitations to watch the Academy Awards.

[3] I have been assured that no animals were harmed in the filming of this experiment.

[4] This was meant as a didactic warning about interpreting scatter plots when the number of points is way big. Basically, the more data points, the larger the impression of the variation. 

Wednesday, July 3, 2013

The color of a bunch of dots, part 3

In this series of blogs on tone value increase, we have been considering two parallel questions: How to predict the color of a halftone, and what to measure about a halftone in order to do process control. In part 3 of the series - the one you are reading right now - I want to consider the process control issue.

For those who can't take the time to read my entire long blog post today (maybe because they have to tend to their sick chameleon?) I will give a spoiler. The Murray-Davies equation, which we use today to compute TVI, has some issues when we try to extend it past CMYK inks printed on a web offset press with standard (AM) screening measured with a densitometer.

TVI depends on wavelength

The graph below might be a bit of a shocker. Then again, maybe not? I guess it depends. The graph is simple enough. I took the spectra of a solid cyan, a 50% cyan, and a solid. I used the Murray-Davies equation that we all know and love to compute the TVI. Rather than using the red channel of a densitometer, I did the computation separately at each wavelength.

Will the real TVI please stand up?

Maybe it's a shocker that the TVI at 630 nm is a healthy 15.7%, and at 500 nm, it's an anemic 2.6%? I think this very clearly shows that TVI is not a direct measure of the dot size. How could the dots be so much bigger if you look at them through a blue green filter instead of a red filter? It's almost like the tone ramp (0%, 10%, 20%, ... 100%) changes in hue... [1]

This is just an oddity, though, right?  It is like the kitten born with two faces, only this kitten is a halftone patch with two different TVI values. Or rather, a halftone with a whole bunch of different TVI values. Still, so long as you make sure that you have the correct setting on your densitometer, you won't have to worry about all the other faces. And process control will work, right?

But, sometimes you don't have density information, particularly in color management. It seems that a lot of data sets have been collected with only colorimetric data; no spectra and no density data. [2] How can you compute density without the spectral data? Can you compute TVI from the XYZ values?

According to ISO 10128, Appendix A, you can compute magenta and black TVI from the Y value and yellow TVI from the Z. To compute the cyan TVI, you need to do a bit more math, but it's not that bad.  There is a formula. Another brilliant researcher presented a paper at TAGA (2008), where he offered up a more complicated formula that works even more better. Brilliant as this researcher is, he stole this formula from another brilliant guy, Steve Viggiano.

So... this is basically just a confusion, right? There isn't really anything here to upset anyone's sense of inner tranquility, right? Keep reading.

TVI does not uniquely define the color of a halftone

Speaking of standards, the ISO standards for print (the ISO 12647 series) defines colorimetric aim points for the four solids and overprints of those solids. But for halftones?  It specifies TVI aim points. This would lead one to believe that, once you get the solid correct, all you need to do is make sure that you TVI is correct. Then you will have the correct color, right? [3]

And if the TVI is not correct, the standard gives you the impression that it is easily corrected in prepress by applying a plate curve. If your 50% has a TVI of 66%, and it should be a 68%, then all you need do is add 2% in a plate curve, right?

Not so fast, boopie.

The graph below is an a*b* plot (a plot looking at color space from above) of cyan, magenta, and yellow tone ramps, along with various other combinations. The blue lines represent the color of tone scales of conventional screening. The red lines represent stochastic screening. It is apparent that certain single color tone scales (cyan and magenta) have a hue shift of several deltaE between the two types of screening.

Comparison of conventional and stochastic screening [4]

When a plate curve is applied, the color is moved along the appropriate curve in color space. (I call this curve the trajectory.) A plate curve cannot make your halftone jump from one trajectory to another. Maybe everyone knows this already, but it bears saying. You cannot use a plate curve to match color between conventional and stochastic screening.

If other forms of printing were to be included, the hue shift in the midtones would be more dramatic. Gravure and ink let printing are still farther from the graph above of conventional printing. To put this another way, hitting the correct TVI does not guarantee the correct color if there is a difference in printing modality. The solids might be spot on and the TVI might be absolutely correct, but the actual color of the 50% tone will not be correct.

TVI of spot colors

What happens if I want to compute the TVI of a spot color (Pantone or PMS)? I just have to pick the right density filter, right? Short answer: For a minority of inks, let's say a quarter of them, this actually works well. But, TVI really sucks at quantifying some spot colors. For others, it's better - somewhere around "lousy".  These are harsh words, but I have data to back them up.

I looked at a set of tone ramps of 394 spot colors. I computed the TVI for each of the tones using the Murray-Davies formula at the wavelength where the spectrum of the solid had the lowest reflectance. Then I sat back and watched the fireworks. Of the 394 inks, almost all of them (353) had a TVI (at 50%) of greater than what we would call "typical", 18%. A total of 70 of the inks had astronomical TVI values of over 35%. Most press operators I know would call that an extreme case of plugging. But it wasn't  plugging at all. The TVI was horribly large, but the color of the halftone looked just fine. Plenty of contrast in the shadows.

The graph below is the spectra of the tone scale of one of the inks that had a TVI of about 35%. Note that, around 600 nm where the reflectance is the very least, the solid, 90%, 80%, and 70% have nearly identical reflectance values. Anywhere in the red part of the spectrum, this looks like an ink with severe plugging.
The spectra of a tone scale of one blue spot color

But have a look at what happens at 450 nm. In the blue part of the spectrum, there is a very clear separation between the shadow tones. In this region, all appears to be right with the world. Despite what TVI tells us, there is contrast in the shadows. [5]
Conclusions

The use of TVI as a process control device has been proven to work for CMYK inks on a web offset press using conventional screening. But...

a) TVI is dependent on the wavelength chosen. If you are dealing with CMYK inks and conventional screening and web offset printing, then so long as you are careful about selecting the correct filter on the densitometer, this isn't a problem. The only time a problem pops up is when TVI is computed from colorimetric data. 

b) When we switch from conventional web offset printing to something else, particularly when there is a difference in the crispness of the dot, having the same color for the solids and the same value for the TVI does not guarantee that the color of the tones will be the same. 

c) When you look at inks other than CMYK, the TVI value sometimes is a useful parameter for process control, but it often is completely misleading.

In the next installment of this series on TVI, I will explain a slightly different equation than the Murray-Davies equation and the Yule-Neilsen equation. In the final installment, I will look at some practical solutions to the issue of process control for halftones of spot colors.

-------------------------------------
[1] This isn't just a cyan thing. The same issue can be seen with magenta ink, and to a lesser degree, with black and yellow.

[2] Congress is acting swiftly to ban the disposal of unwanted spectral data, or at least trying to act swiftly. Right now, it is stuck in the quagmire of partisanship with Democrats tying the bill to efforts to save the rain-forests in southeast Kansas, and Republicans demanding that magenta density be removed since the word "magenta" does not appear in the Bible.

[3] Astute readers will note the proliferation of the word "right" added to the end of  a sentence for emphasis.   Some readers might assume that this is a technique used to draw attention to things we might assume but which are not correct, right?

[4] The image is from a presentation by Dr. Bestmann to the ISO technical committee 130 in September of 2011.

[5] This is a drastically shortened version of an article that appeared in IDEAlliance Bulletin magazine, spring of 2012 issue: Measuring TVI of a spot color. If you are interested in obtaining your own subscription to this magazine, have a look at the IDEAlliance website.