How can I make a colo figure from a string array?
显示 更早的评论
I have a string array, where every element is a name of a color.
How can i make a figure of that array that showing the colors not the names of the colors.
I perfer to use the (figure) function which built in matlab, if that is possible
Thanks
回答(1 个)
Walter Roberson
2023-3-2
0 个投票
First you need to scrape a bunch of tables such as https://www.farb-tabelle.de/en/table-of-color.htm and https://cloford.com/resources/colours/500col.htm to build extensive tables that map color names to nominal RGB values. Consider the question of what exactly is the color to be associated with the color name "Red"
Then you need some lexical analysis software to try to find the closest match between the string array entries and the entries available in the color table. Able, for example, to figure out that if the string contained "corn flour" that it corresponds to the table entry for "cornflowerblue" .
Matched name in hand, you look up the stored RGB value and convert it to color components (from Hex or decimal).
Then you create an array in which you write the appropriate RGB values into a block of the array.
After you have done populating the RGB array, image() it to display it.
Note: you will probably want the RGB array to be uint8() datatype specifically.
类别
在 帮助中心 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!