Re: CNS colors

lilley ([email protected])
Wed, 7 Feb 1996 15:20:36 +0000 (GMT)


Bill Perry wrote:

> Hakon Lie wrote:
> [...]
> > In order to incorporate CNS into CSS we need some sample code for
> > convert to RGB, and to resolve the 'magenta' conflict. Before we go
> > ahead with this, what are people's reactions?
>
> I would throw it into emacs-W3 as soon as I could convert to RGB. I'm
> generally not any good at color theory though, so am not sure where to
> begin. Does chris have any sample code available?

OK *conceptually* the scheme goes like this:

0) CNS name -> an index

This requires parsing the text (according to the BNF in the cited paper)
so that red is expanded to vivid medium red (for example) and then each
of the distinct colours maps to some number.

1) index -> Munsell colour.

This is a widely used system for describing colour, and has been shown to
perform well in usability studies. Each of the CNS colours maps to exactly
one Munsell colour. This is therefore a 600-odd element lookup table.
I need this data, which the paper alludes to but does not contain. I have
mailed one ofthe authors for this information.

2) Munsell -> some CIE colour space

This requires measurement of each Munsell colour chip. This has been done
and I have the data (in CIE xyY) for the entire Munsell system. So once
I get the data for step 1 I can do this step too.

3) (optional) mapping to take account of current white point, ie the Von
Kries transformation or similar. I have the equations for this.

The result of step 2 (or 3) is an objective, measurable colour specification
in CIE XYX for each of the named colours.

4) CIE XYZ -> RGB

This requires details of the particular monitor chromaticities and white
point. Different monitors will end up with different RGB numbers to
produce the same perceived colour. To cope with the (many) systems where
the precise monitor details are not known, I propose to generate a set of
default RGB values for the CCIR 709 primaries, which modern broadcast
systems us for colour balancing as a "typical" monitor. (Hell of a lot
more typical than the NTSC primaries, anyway ;-) )
I have code to do this, and data for some monitors, including the 709 one.

5) gamma correction of RGB values

This essentially boils down to

a) am I on a Mac
b) am I on an SGI
c) am I on something else

to generate a 256 element lookup table that does gamma correction, then
putting each of R G and B through this table. _Note_ that colours
specified in RGB should also be put through this table (at last!
colours that look similar on Macs and PCs). See the CSS draft TR.

In practice, once these steps have been done, for a naive screen-only
browser steps 2 to 5 can be conflated so you convert the colour name to
an index and then look that up in a table of default RGB values then
putting these through the gamma correction table. No actual colour
space conversion code will be required.

Browsers that also offer colour printing will need to have two gamma
tables, because the gamma for screen and print are quite different.

Browsers that are going for improved colour fidelity, either on screen
(converting to a specific monitor type) or in print (eg sending CIE XYZ
data directly to a level 2 PostScript printer) or on systems with a
colour management system, will require access to the CIE values from
step 2 or 3

-- 
Chris Lilley, Technical Author and JISC representative to W3C 
+-------------------------------------------------------------------+
|  Manchester and North Training & Education Centre   ( MAN T&EC )  |
+-------------------------------------------------------------------+
| Computer Graphics Unit,             Email: [email protected] |
| Manchester Computing Centre,        Voice: +44 161 275 6045       |
| Oxford Road, Manchester, UK.          Fax: +44 161 275 6040       |
| M13 9PL                            BioMOO: ChrisL                 |
| Timezone: UTC        URI: http://info.mcc.ac.uk/CGU/staff/lilley/ | 
+-------------------------------------------------------------------+