Mathematica Notes – Coloring functions

Sometimes I wish life were always perfectly straightforward. As I said recently, I have figured out how to change the default sequence of colors for multiple graphs. I thought this would be a very short post… but there are a few additional things I need to cover in order to show that to you.

Since I usually use Mathematica® version 7, let me note that I am using version 8 for this work.

Let me start by showing you where we’re headed. If we make a list of the first five Legendre polynomials and ask Mathematica to plot them all, it chooses a set of five colors, one for each function:

Read the rest of this entry »

Color – RGB and XYZ on my monitor, again

I set out to do something very simple: let Mathematica do the transformations between RGB and XYZ. Since CIELab is defined in terms of XYZ, but my monitor (“Color LCD” on a MacBook) is RGB, I’d like to be able to convert between RGB and CIELab.

Well, I showed us how to convert between RGB and XYZ, in a previous post about the nonlinearity of my monitor.

Recall the purple disk that figured so prominently in that post. It was defined by:

RGB = \{0.5666,0.3877,0.6864\}

and drawn by Mathematica® as:

Read the rest of this entry »

Posted in color. Tags: . 1 Comment »

Color: CIELab and Tristimulus XYZ

Let’s talk about CIELab. I’m not going to provide any background or discussion. This wiki article is an excellent introduction.

And there’s a very nice article about HSB. Furthermore, it includes an example with many more parameters than just hue, saturation, and chroma computed, which is outstanding. It also has a lot more information about HSI versus HSB; the differences seem to be more than I was led to believe from my previous reading.

CIELab is specified as a transformation from XYZ tristimulus coordinates. What motivated this post is that the only inverse transformation I’d seen published – until I read the wiki article – is incomplete. That’s a polite way of saying it doesn’t always work correctly. And that’s a polite way of saying it’s wrong.

In fact, the inverse transformation in the wiki post is perfecty straight-forward, and I’ll show it to you in more detail than they do.
Read the rest of this entry »

Posted in color. Tags: , . 4 Comments »

Color – Using PieChart, and the artists’ color wheel

getting the computer color wheel via pie charts

I found the following example in the Mathematica® (v 7) help file. I thought it had promise.

Read the rest of this entry »

Posted in color. Tags: . 2 Comments »

Color: my MacBook LCD monitor

introduction & setup

I want to play with five colors. Four of them are perfectly straight-forward: red, green, blue, and white. The fifth color, looking purple to me, is close to one of the colors on the Gretag Macbeth color checker; we’ll be seeing this color again in a subsequent post.

I have two software tools which came with my Mac: the DigitalColor Meter and the ColorSync Utility. If you are not on a Mac, perhaps you have, or can get, something similar.

I want to know the relationship between RGB and XYZ on my monitor. First I will establish that the relationship is not linear; then I will show how what it is and how I found it.

Let’s try finding a linear relationship by looking at the relationship between RGB and XYZ for my five chosen colors, but especially for red, green, and blue.

Here is a red disk, defined by RGB = (1,0,0). If you’re new to my blog, the following commands are Mathematica®.

Read the rest of this entry »

Color: from XYZ to spectrum


In this post, I will go from XYZ coordinates to a spectrum.

I have to ask: what would somebody do with this? Especially, what would they do that couldn’t have been done using the XYZ tristimulus values directly? I don’t know – but let’s just solve the problem. I do not yet always have a satisfactory solution, and I will illustrate both satisfactory and unsatisfactory solutions.

Yes, we have done this before – but not as our primary purpose, but rather as part of another computation. It is worthwhile to tackle this specific problem, because there is one subtlety.

In general terms, the solution is simple: the XYZ tri-stimulus values are proportional to the components (with respect to the dual basis) of a (fundamental) spectrum. Find the dual basis, then get the linear combination defined by those components.
Read the rest of this entry »

Color: more on color-primary transformations


(Notation: It has become my custom to use, for example, N’ to denote the transpose of N.)

This post has two purposes.

  1. To show you Giorgianni & Madden’s (see bibliography) version of the calculation I first found in Glassner (see bibliography; and there is a link below).
  2. To show you what happens when we change the white point — only the white point.

I want to show you Giorgianni & Madden’s version of the calculation because they do it slightly differently — they compute a transition matrix. As always, the surest way to avoid misunderstanding is to show you a calculation. You may not know why I did something, but there should be no doubt about what I did.

And I want to show you what happens when we change the white point. I talked about this at the end of the “color primary” post (okay, what I still think of as the “Glassner” post); the link is below.

I can spare you some suspense, but I’m going to do the calculation anyway.

One disadvantage of having Mathematica at my fingertips is that I can compute before I think. (There are advantages to walking around the block every so often, and they’re not just physical; it gives me a chance to think, stuck in circumstances where I cannot compute.)

Let us first review the calculation as Glassner presented it.
Read the rest of this entry »

Posted in color. Tags: . Leave a Comment »

Yet More Books on Color

The following books have been added to the bibliographies page.

“Real World Color Management” by Fraser, Murphy, and Bunting..
“The Reproduction of Colour” by Hunt.
Giorgianni and Madden’s “Digital Color Management: Encoding Solutions”.
Read the rest of this entry »

Color: 12 metameric grays from Wyszecki & Stiles


I want to work a major exercise from Wyszecki & Stiles. Actually, it will be one calculation repeated for 12 gray spectra. Given each spectrum, I will calculate the tristimulus values XYZ. (We first did this, here.)

The key is that these 12 spectra are supposed to be metameric. This exercise is interesting for three reasons:

  1. 10 of the 12 spectra have virtually identical XYZ values;
  2. I am encouraged that those virtually identical answers come from using linear algebra — without numerical integration;
  3. I believe that the other two spectra have typos in them — and I think I found (most of) them!

My starting point is Wyszecki & Stiles, page 784. The table heading says that the 12 spectra on that page are metameric with respect to standard illuminant D65 and the CIE 1931 standard observer.

I will show you that they are indeed metameric under D65. I will also show you that they cease to be metameric under D50.
Read the rest of this entry »

Posted in color. Tags: . 10 Comments »

Color: Color-primary transformation XYZ to RGB

this was titled “Glassner’s transformation XYZ to RGB”


There is a marvelous calculation in Glassner (vol 1, p 103; see my bibliography). Oh, I do not mean to imply that he originated this calculation, merely that I have only ever seen it in his book. And for all I know, he might actually be the originator.

edit: As I said in “Yet More Books on Color“, I found this calculation, done much the way Glassner did but not quite, in Giorgianni & Madden. I decided that I should use a title that did not pretty much credit it to Glassner, despite my disclaimer. end edit.

As he puts it: “Our goal is to find a matrix M which will take a three-element vector representing an XYZ color and transform it to an equivalent RGB vector for some particular monitor.”

The only information given to us will be the chromaticity coordinates x,y for each of the three phosphors, and for the white point.
Read the rest of this entry »