Re: [R] hex format

From: Thomas Lumley <>
Date: Fri 08 Apr 2005 - 07:08:21 EST

On Thu, 7 Apr 2005, Earl F. Glynn wrote:
>> For example, R already provides both hsv() and rgb() to create colours
>> from vectors of three numbers, but the correspondence is different in each
>> case.
> Sorry if some consider this off topic:
> HSV as a color space is really only liked by computer scientists. Image
> processing and color engineers rarely if ever use HSV.
> There are MANY other color spaces and computations possible (see "color
> spaces" or "color conversions" or other color topics on this page
> Most of these color
> manipulations in R are not easy because the very first step, converting
> colors, I mean numbers <g>, like #ff0080 to the red, green components is
> hindered because one must reinvent the wheel of hex-to-decimal conversion.

Yes, and convertColor in R-devel does quite a few of these (XYZ tristimulus space; CIE Lab and Luv; sRGB, Apple RGB and roll-your-own RGB based on chromaticities of the primaries; and chromatic adaptation for changing the white point). The "colorspace" package has a more elegant implementation of a somewhat different set of color space computations, and R-devel also has hcl() for specifying colors based on hue, chroma, and luminance (polar coordinates in Luv space).

Basing R graphics on these (and so making them colours rather than just data about colours) requires a further step of considering the characteristics of the output device. This might be as simple as declaring R's output to be sRGB or as complicated as worrying about ICC profiles.

         -thomas mailing list PLEASE do read the posting guide! Received on Fri Apr 08 07:19:21 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:04 EST