rgb2hsv {hexbin}R Documentation

Numeric Conversion of RGB to HSV Color Space

Description

Given a 3-row matrix of RGB (Red, Green, Blue) values in [0,1] return a similar matrix of HSV (Hue, Saturation, Value) values.

Usage

rgb2hsv(r, g = NULL, b = NULL, delta = 1)

Arguments

r vector of “red” values in [0,1], or 3-row rgb matrix.
g vector of “green” values, or NULL when r is a matrix.
b vector of “blue” values, or NULL when r is a matrix.
delta a “gamma correction”.

Value

See Also

hsv, rgb, col2rgb.

Examples

256* (rgb3 <- floor(256 * matrix(runif(3*12), 3,12))/256)
(hsv3 <- rgb2hsv(rgb3))
rgbBack <- col2rgb(hsv(h=hsv3[1,], s=hsv3[2,], v=hsv3[3,]))
table(256*rgb3 - rgbBack)# not all 0; I had about half 1's
stopifnot(max(1 - c(256*rgb3) / c(rgbBack)) < 0.01)

[Package Contents]