Open In App

Convert Colors from RGB to HSV in R Programming - rgb2hsv() Function

Last Updated : 15 Jul, 2025
Suggest changes
Share
Like Article
Like
Report
rgb2hsv() function in R Language is used to transform colors from RGB space(red / green / blue) into HSV space(hue / saturation / value).
Syntax: rgb2hsv(r, g, b) Parameters: r: vector of ‘red’ values. g: vector of ‘green’ values, or NULL when r is a matrix. b: vector of ‘blue’ values, or NULL when r is a matrix.
Example 1: Python3
# R program to illustrate # rgb2hsv function # Calling the col2rgb() function to # get color in rgb rgb = col2rgb("# 08a0ff") # Calling the rgb2hsv() function to # convert the RGB values in the  # colormap to HSV rgb2hsv(rgb) 
Output:
 [, 1] h 0.5641026 s 0.9686275 v 1.0000000 
Example 2: Python3
# R program to illustrate # rgb2hsv function # Calling the rgb2hsv() function rgb2hsv(60, 120, 180) 
Output:
 [, 1] h 0.5833333 s 0.6666667 v 0.7058824 

Explore