Array to RBG values?

14 ビュー (過去 30 日間)
Pavel Inchin
Pavel Inchin 2018 年 7 月 24 日
回答済み: Walter Roberson 2018 年 7 月 24 日
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 Center および File ExchangeBlue についてさらに検索

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by