From: lilleyc@cs.man.ac.uk (Chris Lilley)
Newsgroups: comp.graphics
Subject: Re: Color Sample to RGB Conversion
Keywords: color conversion
Date: 17 Nov 92 02:00:30 GMT
Organization: Dept Computer Science, University of Manchester, U.K.

In article <hewitt.721337021@usafa.af.mil> hewitt@usafa.af.mil (W. Joe
Hewitt) writes: 

>     I am looking for a way to generate a color on a workstation that closely 
>matches a given sample from a color plate.  

The simple answer is, mix it by eye. This is also a pretty accurate
answer. However you may want to do this automatically, perhaps for a
large number of colours. So you need a way of spacifying the colour
numerically.

>     I have tried scanning the image (24 bit scanner) with little success.  
>The scanning software only gives percentages of the R,G, & B components.  
>Using a little math I converted each percentage to a value in the range 
>0..255 (24 bit color system) for each RGB component.  

OK so you scanned it in as an RGB image. That will not help solve your
problem, however.

>The problem is that 
>the new color doesn't look very much like the original sample.  

No, it won't. Red, green, and blue are very loose specifications for
colours. They differ between different monitors, and between different
scanners. 

>I know 
>that the monitor can be adjusted to do minor compenstaion, but it still 
>doesn't get close enough to the original sample.

Nope. And the adjustment would need to be non linear in any case -
some colours get closer, others get worse.

>     Is there a better way to accurately reproduce a color sample on a 24 bit 
>workstation?  Is there something I have missed in the conversion?

As you have realised, RGB is not the way to go. You basically have two
options. 

One is inexpensive and slow - mix the colours by eye using a
paint package that lets you mix colours. This may be easier if you use
HLS or HSV rather than RGB, but do whatever you find easier. This
method is OK if you only have a few colours to match, and can give
very accurate results. Be aware, however, that the colours you mix up
will only hold good under the lighting conditions you mixed them under
- flourescent striplight, electric lightbulb, sunny day, overcast day
- and will look wrong under different illumination conditions.
Sometimes just a bit wrong, sometimes markedly wrong.

The other method is automated but might cost a bit - in time odr
money.

You need to use a standard numerical specification for your colours.
These is one by the International Standards Organisation that is
widely used, called CIE XYZ. The difference from RGB is that the CIE
XYZ specification of a colour is an objective quantity that can be
measured and reproduced on a wide variety of equipment. You then need
to display this on your workstation by converting to RGB. This
conversion will be different for each monitor. Details of how to do
this are in various books or if you are stuck mail me for details. You
will need some data from the monitor manufacturer to do the conversion
- the colour of that monitors red, green, blue and white using
standard CIE colour descriptions, and also the gamma (transfer
function) of the monitor which compensates for its nonlinearity.

Given the same data for the scanner, you could continue to use your
existing scanner set up. The conversion would then be:

your scanner RGB --> CIE XYZ --> your monitor RGB

Relevant data should be available from the scanner manufacturer if you
ask persistently ;-)

The other way to get CIE XYZ values is to borrow (or even buy - but
they cost about $6k) an instrument to measure them. These instruments
typically look like a squat gun with some sort of readout like a LCD
(or via a serial port). You put the sample against the muzzle, press
the trigger and the X, Y and Z values are displayed.

>     Please E-mail any responses directly to me since my news feed is several 
>days behind.

Well so is mine!  Anyway perhaps others would like to know the answer
too.


--
Chris Lilley
---------------------------------------------------------------------------
Technical Author, ITTI Computer Graphics and Visualisation Training Project
Computer Graphics Unit, Manchester Computing Centre, Manchester, UK
Internet:   lilley@cgu.mcc.ac.uk        Janet:   lilley@uk.ac.mcc.cgu
Voice:      +44 (0)61 275 6095          Fax:     +44 (0)61 275 6040
---------------------------------------------------------------------------
Newsgroups: comp.graphics