R 語言中的 rgb2hsv() 函數用於將顏色從 RGB 空間(紅/綠/藍)轉換為 HSV 空間(色相/飽和度/值)。
用法: rgb2hsv(r, g, b)
參數:
r:‘red’ 值的向量。
g:‘green’ 值的向量,或者當 r 是矩陣時為 NULL。
b:‘blue’ 值的向量,或者當 r 是矩陣時為 NULL。
範例1:
# 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)
輸出:
[, 1] h 0.5641026 s 0.9686275 v 1.0000000
範例2:
# R program to illustrate
# rgb2hsv function
# Calling the rgb2hsv() function
rgb2hsv(60, 120, 180)
輸出:
[, 1] h 0.5833333 s 0.6666667 v 0.7058824
相關用法
- R語言 heat.colors()用法及代碼示例
- R語言 colors()用法及代碼示例
- R語言 colorRampPalette()用法及代碼示例
- R語言 topo.colors()用法及代碼示例
- R語言 cm.colors()用法及代碼示例
- R語言 terrain.colors()用法及代碼示例
- R語言 col2rgb()用法及代碼示例
- R語言 rgb()用法及代碼示例
- R語言 type.convert()用法及代碼示例
- R語言 toupper()用法及代碼示例
- R語言 charToRaw()用法及代碼示例
- R語言 dQuote()用法及代碼示例
- R語言 sQuote()用法及代碼示例
- R語言 strtoi()用法及代碼示例
- R語言 deg2rad()用法及代碼示例
- R語言 rad2deg()用法及代碼示例
- R語言 str_to_title()用法及代碼示例
注:本文由純淨天空篩選整理自Kanchan_Ray大神的英文原創作品 Convert Colors from RGB to HSV in R Programming – rgb2hsv() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。