MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: RGBColor to Hue?

  • To: mathgroup at
  • Subject: [mg31033] RE: [mg31022] RGBColor to Hue?
  • From: "David Park" <djmp at>
  • Date: Fri, 5 Oct 2001 01:22:44 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

I think I can answer my own question.

Basically we identify Red, Green and Blue with the complex numbers which are
the cube roots of 1. We weight these complex numbers by the r, g, b values
in RGBColor[r,g,b] and add. We can then define a hue as the argument of the
resulting complex number. If the sum is zero, then the color doesn't have a
hue. In that case we could generate a GrayLevel or a complete Hue
specification with saturation = 0. But I was only interested in sorting the
RGB colors in Graphics`Colors` by hue so I could group them and then sort by
brightness for a color palette.

Here is a routine for generating a hue, although I don't know if it
corresponds to the Mathematica hues.

hue[RGBColor[r_, g_, b_]] := Module[{h},
   h = {r, g, b} . {1, -(-1)^(1/3), (-1)^(2/3)};
    If[h == 0, Indeterminate, (Arg[h]/Pi + 1)/2]]

hue /@ {Black, Green, Yellow, Red, Magenta, Blue, Cyan}
{Indeterminate, 0.166667, 0.333333, 0.5, 0.666667, 0.833333, 1.}

David Park
djmp at

> From: David Park [mailto:djmp at]
To: mathgroup at
> Dear MathGroup,
> Does anyone know transformation equations that will convert RGBColors to
> Hues? If one looks at the input ColorSelector there seems to be an
> equivalence between them. Yet there seems to be no documented
> function which
> converts from RGBColor to Hue.
> Specifically I would like to obtain a hue and a brightness for
> any RGBColor.
> I am not looking for something picture perfect. Just something roughly
> equivalent for screen display of Mathematica notebooks.
> David Park

  • Prev by Date: Re: RGBColor to Hue?
  • Next by Date: Re: RGBColor to Hue?
  • Previous by thread: Re: RGBColor to Hue?
  • Next by thread: Re: RGBColor to Hue?