开发者

How to convert MATLAB fixed color to RGB value? [duplicate]

开发者 https://www.devze.com 2023-03-05 14:11 出处:网络
This question already has answers here: 开发者_JS百科 Closed 11 years ago. Possible Duplicate: MATLAB: convert color name to RGB 3 element vector
This question already has answers here: 开发者_JS百科 Closed 11 years ago.

Possible Duplicate:

MATLAB: convert color name to RGB 3 element vector

MATLAB's ColorSpec concept allows a color to be defined either as a RGB 3-tuple or a fixed color string. I could build a function that uses a lookup table based on the data at the above link to convert between these two color definitions but I worry about changes to this table in future releases.

Is there a built-in function which converts from fixed color to RGB value that does something like the following?

>> fixedColor2RGB('r')

ans = 

     [1 0 0]


There is no built-in function to convert between short or long color name strings and their corresponding RGB triplets. However, these fixed color strings have been the standard in MATLAB for as long as I've used it (about 15 years):

How to convert MATLAB fixed color to RGB value? [duplicate]

So I wouldn't worry too much about changes to this in the future. A simple table lookup should do just fine. And even if they did change things (which seems unlikely), such a simple utility could be easily updated.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号