File: generate_colormaps.m

package info (click to toggle)
mccode 3.5.19%2Bds5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,113,256 kB
  • sloc: ansic: 40,697; python: 25,137; yacc: 8,438; sh: 5,405; javascript: 4,596; lex: 1,632; cpp: 742; perl: 296; lisp: 273; makefile: 226; fortran: 132
file content (27 lines) | stat: -rw-r--r-- 848 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
% This Matlab script generates a colormap.txt file for insertion in plotfuncs.py
maps={'jet','autumn','bone','colorcube','cool','copper','flag','gray', ...
      'hot','hsv','lines','parula','pink','prism','spring','summer','winter'};

imagesc
fileID = fopen('colormaps.txt','w');
fprintf(fileID,'    colormaps={\n');
for j=1:length(maps)
    map=maps{j};
    eval(['colormap ' map])
    cmap=colormap;
    cmap=round(255*cmap);
    siz=size(cmap);
    
    fprintf(fileID,'        ''%s''  : np.array([',map);
    
    for k=1:siz(1)
        if k<siz(1)
            fprintf(fileID,'[%3i, %3i, %3i, 255], ',cmap(k,1),cmap(k,2),cmap(k,3));
        else
            fprintf(fileID,'[%3i, %3i, %3i, 255]',cmap(k,1),cmap(k,2),cmap(k,3));
        end
    end
    fprintf(fileID,'], dtype=np.ubyte),\n');
end
fprintf(fileID,'        }\n');
fclose(fileID);