[vslist] Results of dominant wavelength/excitation purity help request

Jesus Malo Jesus.Malo@uv.es
Wed Nov 17 08:50:00 2004


Our answer to the dominant wavelength problem is much simpler than=20
those I read in the list:

   Please just use coor2lp.m in COLORLAB:=20
   A free easy-to-use and comprehensive color processing toolbox=20
   for Matlab 5.X or higher!.

   You can dowload it from the software icon in:

         http://www.uv.es/vista/vistavalencia  =20

   You can also download a complete user guide for your convenience!

In fact, coor2lp.m applies some of the ideas posted by different people=20
in the list but in a more general way, i.e. in *any* tristimulus space,
not just CIE XYZ!

Here you have a brief description of what COLORLAB is
(visit the web page above for more details):

COLORLAB is a high-performance color computation and visualization toolbox =
to=20
be used in the MATLAB environment. COLORLAB is intended to deal with color =
in=20
general-purpose quantitative colorimetric applications as color image=20
processing and psychophysical experimentation. =20
COLORLAB uses colorimetrically meaningful representations of color and colo=
r=20
images (tristimulus values, chromatic coordinates and luminance, or, domina=
nt=20
wavelength, purity and luminance), in any primaries system. COLORLAB relate=
s=20
these colorimetric representations to the usual device-dependent discrete-
color representation, i.e. it solves the problem of displaying a=20
colorimetrically specified scene in the monitor within the accuracy of the=
=20
VGA. =20

A number of interesting color representations are also provided, as CIE=20
uniform color spaces (as L*a*b* and L*u*v*), opponent color representations=
=20
based on advanced color vision models, and color appearance representations=
=20
(RLab, LLab, SVF and CIECAMs). All these representations are invertible, so=
=20
the result of image processing made in these colorimetrically meaningful=20
representations can always be inverted back to the tristimulus representati=
on=20
at hand, and be displayed. =20
COLORLAB includes useful visualization routines to represent colors in the=
=20
tristimulus space or in the chromatic diagram of any color basis, as well a=
s=20
an advanced vector quantization scheme for color palette design. =20
An extensive color data base is also included, with the CIE 1931 color=20
matching functions, reflectance data of 1250 chips from the Munsell Book of=
=20
Color, McAdam ellipses, normalized spectra of a number of standard CIE=20
illuminants, matrices to change to a number of tristimulus representations,=
=20
and calibration data of an ordinary CRT monitor. =20

This Toolbox was developed by Jes=FAs Malo and M=AA Jos=E9 Luque from the V=
ision=20
Science Group of the Dept.of Optics, at the School of Physics, Universitat =
de=20
Val=E8ncia (Spain). The current educational and research interests of this =
group=20
include different aspects of color science such as color image compression,=
=20
numerical models of human color vision.=20




> The following is a Mathematica routine I wrote some years ago. The=20
> code is no doubt incomprehensible, but the idea is simple. First,=20
> from a table of the spectrum locus defined by {x,y} chromaticity=20
> coordinates vs wavelength, create an interpolating function that=20
> returns {x,y} for an arbitrary wavelength. Then find the angle of the=20
> line between the white point and the point in question. Then, find=20
> the point along the spectrum locus for which the line from the white=20
> point has (nearly) the same angle.
>=20
> The bit at the end generates a plot of the situation. I attach an=20
> example below.
>=20
> The code for Excitation purity follows in a straightforward way.
>=20
> DominantWavelength[xy_, xyw_:{0.33, 0.33},=20
> chromaticity_:CIE1931Chromaticity, plot_:False] :=3D
>      Module[{sign =3D 1, LambdaToxy, x, angle, AngleFromWhite,=20
> PositiveAngle, dw, xyl},
>      LambdaToxy[lambda_] :=3D (#[lambda] &) /@=20
> (WaveTableInterpolation[chromaticity][[{1, 2}]]);
>      AngleFromWhite[xy0_] :=3D ArcTan @@ (xy0 - xyw);
>      PositiveAngle[xy1_] :=3D
>        If[# < 0, # + 2 \[Pi], #, #] &[AngleFromWhite[xy1] -=20
> AngleFromWhite[LambdaToxy[700]]];
>      angle =3D PositiveAngle[xy];
>      If[angle > PositiveAngle[LambdaToxy[400]], (angle =3D angle - Pi;=20
> sign =3D -1)];
>      dw =3D (FindRoot[angle - PositiveAngle[LambdaToxy[lambda]] =3D=3D 0,=
=20
> {lambda, 500, 400,700}][[1, 2]]) ;
>          If[plot, xyl =3D LambdaToxy[dw];
>       =09ChromaticityDiagram[NMLabels -> {400, 500, 560, 700}
>         =09, Epilog -> {RGBColor @@ NearestRGB[dw, xyw],
>            =09Line[{xy, xyw}], Line[{xyl, xyw}], PointSize[.04],=20
> GrayLevel[.6],
>            =09Point[xyw], Point[xyl], GrayLevel[0], Point[xy]}]];
>      dw sign   ]
>=20
> ExcitationPurity[xy_, xyw_:{.33,.33}, chromaticity_:CIE1931Chromaticity] =
:=3D
>   If[xy =3D=3D xyw, 0, Divide @@ ((First /@
>     {xy, WaveTableValue[chromaticity,
>     DominantWavelength[xy,xyw,chromaticity]]}) - xyw[[1]])]
>=20
>=20
> Here we evaluate an example, with plot.
>=20
> DominantWavelength[{.3, .5},{.33,.33}, CIE1931Chromaticity,True]
>=20
>=20
> --=20
>=20
> Andrew B. Watson
> MS 262-2
> NASA Ames Research Center
> Moffett Field, CA 94035-1000
> (650) 604-5419=09(650) 604-0255 fax
> andrew.b.watson@nasa.gov=09http://vision.arc.nasa.gov/


--
TAUTOLOGIES OF THE DAY:
Zapatero =3D Kerry, PSOE =3D Democrats,
i.e. not necessarily good either!

********************************
Jesus Malo, PhD in Physics

Associate Prof. at Dept. d'Optica,
Facultat de Fisica, Universitat de Valencia
Dr. Moliner 50, 46100 Burjassot, Valencia,
SPAIN

e-mail: jesus.malo@uv.es
www:    http://www.uv.es/vista/vistavalencia
tel office:   (34) 963 544 717
tel lab:      (34) 963 543 095
fax:          (34) 963 544 715
********************************