"Thomas Lumley" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > The convertColor function in R 2.1.0 provides colorspace conversion, > including "hex".
> #ff0080 isn't a number, it's a colour (or perhaps a color). If it were > converted to numeric form it would be a vector of three numbers, and which > three numbers would depend on the coordinate system used for colour space. Colo(u)rs and numbers are interchangeable to me. When you look at a picture, don't you "see" numbers? Maybe you don't see a number here, but I do. #ff0080 is interpreted in some (non-R) contexts as a single number. In many contexts, including HTML, colors are represented as three bytes in hex with this notation and the "#" means "hexadecimal". The RGB color componets can be discerned quite easily: hex FF is decimal 255 (red), hex 00 is decimal 0 (green), hex 80 is decimal 128 (blue). Some programs, e.g., Dreamweaver, allow specification of colors in this hex 3-byte form directly. The "16 million" colors you seen on a "true color" display are from the 256*256*256 (or in hex FF*FF*FF) possible RGB triples. > 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 http://www.efg2.com/Lab/Library/Color/Science.htm). 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. Perhaps R will someday introduce a "pixel" type that would encapsulate the three color components (for color images at least). A matrix of pixels could easily be made into an image. Some color computations such a Maxwell Triangle, or a CIE Chromaticity Chart (sorry the links are currently broken, but the image can be seen on this Chinese translation page) http://bluemoon.myrice.com/efg/color/chromaticity.htm in R is more difficult than it should be because of how R is designed now. Many image processing statistical problems could be tackled directly in R if there were an easier way to manipulate pixels and images. But the hex manipulations I'm advocating could be used for variety of other purposes. E.g, I must periodically deal with a binary data stream of flow cytometery data -- part ASCII, part binary. Reading this stream directly from R would be nice and is almost doable. Working with raw data and understanding exactly what you've got would be facilitated by better conversion capabilities within R. efg ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html