Array to RBG values?

6 次查看(过去 30 天)
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

采纳的回答

Walter Roberson
Walter Roberson 2018-7-24
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Blue 的更多信息

产品


版本

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by