Use Matlab color scheme to convert float to RGB

If I have a float, e.g. 0.568 (float guaranteed 0 -> 1 ). Is there a way to convert this to RGB values ​​(in double [1.0, 1.0, 1.0] or int [255 255 255] ) according to the current Matlab color scheme (like normal, hot, hsv, etc.)?

+4
source share
2 answers

You can try the following:

 f = 0.568; % your float cm = colormap % returns the current color map colorID = max(1, sum(f > [0:1/length(cm(:,1)):1])); myColor = cm(colorID, :) % returns your color 

The result for f = 0.568 is

 myColor = 0.8125 1.0000 0.1875 
+5
source

Look for help for a jet.

jet.colors (n) returns an array of n color values ​​covering the range of the color function, jet in this case. Now all you do is scale / display your data in a 1: n range. This is a good way to get / customize color cards. I have been doing this all the time.

+2
source

Source: https://habr.com/ru/post/921262/


All Articles