필터 지우기
필터 지우기

Array to RBG values?

조회 수: 6 (최근 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 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