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 »

Advertisements

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

Introduction.

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

introduction

(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 »