ColToHsv transforms colors from R color into HSV space (hue/saturation/value).

ColToHsv(col, alpha = FALSE)

Arguments

col

vector of any of the three kind of R colors, i.e., either a color name (an element of colors()), a hexadecimal string of the form "#rrggbb" or "#rrggbbaa", or an integer i meaning palette()[i]. Non-string values are coerced to integer.

alpha

logical value indicating whether alpha channel (opacity) values should be returned.

Details

Converts a color first into RGB an from there into HSV space by means of the functions rgb2hsv and col2rgb.

Value (brightness) gives the amount of light in the color. Hue describes the dominant wavelength. Saturation is the amount of Hue mixed into the color.

An HSV colorspace is relative to an RGB colorspace, which in R is sRGB, which has an implicit gamma correction.

Value

A matrix with a column for each color. The three rows of the matrix indicate hue, saturation and value and are named "h", "s", and "v" accordingly.

Author

Andri Signorell <andri@signorell.net>

See also

Examples

ColToHsv("peachpuff")
#>         [,1]
#> h 0.07857143
#> s 0.27450980
#> v 1.00000000
ColToHsv(c(blu = "royalblue", reddish = "tomato")) # names kept
#>         blu    reddish
#> h 0.6250000 0.02536232
#> s 0.7111111 0.72156863
#> v 0.8823529 1.00000000

ColToHsv(1:8)
#>   [,1]      [,2]      [,3]      [,4]      [,5]      [,6]      [,7]      [,8]
#> h    0 0.9714286 0.3100775 0.5671769 0.5026455 0.8479381 0.1331878 0.0000000
#> s    0 0.6278027 0.6201923 0.8521739 0.8253275 0.9463415 0.9346939 0.0000000
#> v    0 0.8745098 0.8156863 0.9019608 0.8980392 0.8039216 0.9607843 0.6196078