How can I make a colo figure from a string array?
Mostrar comentarios más antiguos
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
Respuestas (1)
Walter Roberson
el 2 de Mzo. de 2023
0 votos
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.
Categorías
Más información sobre Characters and Strings en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!