Re: physical colors and Mathematica colors

• To: mathgroup at smc.vnet.net
• Subject: [mg26405] Re: physical colors and Mathematica colors
• From: Lawrence Walker <lwalker701 at earthlink.net>
• Date: Wed, 20 Dec 2000 00:21:30 -0500 (EST)
• Organization: Morgan State University: COMSARE
• References: <91f7u4\$55k@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Hi Mr. Nichols,

I created a function.  It still needs tweaking though.  Below is an outline of
how I created the SpectrumPlot function.

Plot HUE from 0 to 1 using density plot
Rescale HUE from 0 to about .9 so last color can be violet.
Remap 0->.9 to 7500->3800 Angstroms.
Create a function that will return a value for 'b' in Hue[h,s,b] that the edges
of the sprectra will appear darken.  Colors outside of the visible spectra
should appear dark.
Remap from the non-physical HUE[] generated colors to the corresponding colors
that appear on the emission sprectra using the Interpolation function.  This is
very subjective.

NonvisibilityValue[h_, rolloff_, lev_] :=
(* Return a value for 'b' in Hue[h, s, b] so that the
edges of the sprectra will appear darken *)
Module[{x0}, x0 = rolloff*Log[(1 - lev)/lev];
1 - (1 + E^((h - x0)/rolloff))^(-1) - (1 +
E^(-((-1 + h + x0)/rolloff)))^(-1)];

Plot[NonvisibilityValue[x, .05, .8], {x, 0, 1}, PlotRange -> {0, 1}];

dat = {{3800, 3800}, {4400, 4000}, {5300, 6000}, {5800, 6800}, {7500,
7500}};

(* A remapping from the nonphysical HUE[] generated colors to the corresponding
colors that appear on the emission sprectra using the Interpolation function.
This is very subjective.  To generate a new 'dat' matrix first plot spectrum
with the the entries in the left column the same as the right. *)

ColorMap[x_] = Interpolation[dat, InterpolationOrder -> 1][x];

SpectrumPlot[sat_, bright_, lastColor_, rolloff_, lev_] :=
Module[{lam, h, x0},
DensityPlot[h = (7600 - ColorMap[lam])/3800;
h, {lam, 3800, 7600}, {dum, 0, 1000}, Mesh -> False, Frame -> True,
FrameTicks -> {Automatic, False}, PlotPoints -> {2000, 2},
AspectRatio -> Automatic,
ColorFunction -> (Hue[# lastColor, sat,
bright*NonvisibilityValue[#, rolloff, lev]] &)]];

SpectrumPlot[1, .9, .8, .05, .5];

Another trick might be to scan the actual picture to create a bitmap or gif file
and then import the picture into Mathematica using the Import[] function.  You
should be able to splice the pixels into the corresponding physical colors and
remap them directly to the Angstrom scale.  I just might try this.

Lawrence

PNichols at cornell-iowa.edu wrote:

> Dear Group,
>
> I am working on a package for which I need a function which takes a
> wavelength of light (in nanometers, for example) and returns an RGBColor
> specification.  Has anyone made such a function for Mathematica?
>
> Of course, it is not essential that the result be RGBColor; any other
> standard computer-graphics color model would do the job (HSB, HLS, CMY,
> CMYK, etc.), because the conversions are standard.  It's only the conversion
> between one of these and physical wavelengths which I don't know.
>
> I understand that human color perception is a complicated matter, and so is
> rendering of color on computer display devices.  (The brightness dimension
> is perhaps the most obvious ambiguity.)  It's probably nonsense  to ask for
> a "perfect" correspondence between wavelength and RGB.  But is there a
> "standard" mapping?  Or one that you think is "pretty good"?
>
> I shall be grateful for even the smallest suggestions.
>
> Preston Nichols
> Visiting Assistant Professor of Mathematics
> Cornell College
>

--

------------------------------------------------------------
(\___/)     The fear of the LORD is the beginning of
(o\ /o)     wisdom: a good understanding have all they
/|:.V.:|\    that do his commandments: his praise
\\::::://    endureth for ever.              Psa 111:10
-----`"" ""`------------------------------------------------
Lawrence A. Walker Jr., M.Eng./Ph.D. Candidate
Morgan State University
Clarence M. Mitchell School of Engineering
COMSARE (Center Of Microwave/Satellite And RF Engineering)
Rm: 306-Schafer     Phone: (443)885-1453
------------------------------------------------------------

```

• Prev by Date: Re: Modification to Thread or MapThread
• Next by Date: question
• Previous by thread: Re: physical colors and Mathematica colors
• Next by thread: Question: numerical solution of nonlinear differential equation