Create HSV Value from Numeric RGB Intensities

DESCRIPTION:

Computes the HSV value equivalent to a specific RGB triplet such as {255, 0, 0} .

USAGE:

rgb2hsv(r, g=NULL, b=NULL, gamma=1, maxColorValue=255)

REQUIRED ARGUMENTS:

r
Red intensity between 0 and maxColorValue. Can also be a three row matrix of RGB values in the form returned by col2rgb().
g
Green intensity between 0 and maxColorValue.
b
Blue intensity between 0 and maxColorValue.

OPTIONAL ARGUMENTS:

gamma
Gamma correction. Single value.
maxColorValue
Maximum color value. The default is 255, so the RGB values are between 0 and 255. The other commonly used value is 1, so the RGB intensities are between 0 and 1.

VALUE:

Returns a 3 row matrix with rows containing values between 0 and 1 giving the h , s , and v for each color.

SIDE EFFECTS:

None.

SEE ALSO:

, .

EXAMPLES:

# Create colors from HSV values, then convert back to HSV
a <- hsv(h=seq(0.1, 0.9, length=16), s=0.75, v=1)
rgb2hsv(col2rgb(a))