Effacer les filtres
Effacer les filtres

Array to RBG values?

6 vues (au cours des 30 derniers jours)
Pavel Inchin
Pavel Inchin le 24 Juil 2018
I have 3 arrays: 1. latitude 2. longitude 3. value at that position
I need to get RGB for every value from array "3" in order to after that represent it as hex color string to put into KMZ.
How can I find RGB triple for every value in array "3" (setting particular colormap). I know that I can get RGB from imagesc, but it is not clear how to work if my data is presented as arrays.
Thanks

Réponse acceptée

Walter Roberson
Walter Roberson le 24 Juil 2018
As you mention imagesc, I will presume that you want the minimum value to map to the first color in the colormap, and the max value to map to the last color in the colormap.
cmap = jet(107); %define colormap and number of entries, max 256
mg = mat2gray(ValueArray);
mgint = im2uint8(mg);
rgb = ind2rgb(mgint, cmap);
hexstr = reshape(cellstr(num2str(reshape(rgb, [], 3), '%02x')), size(rgb,1), size(rgb,2));
The result will be a cell array with the same number of rows and columns as the image, and each entry will be a character vector length 6 of hex digits, in the order R, G, B

Plus de réponses (0)

Catégories

En savoir plus sur Blue dans Help Center et File Exchange

Produits


Version

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by