Make gradation color map from color list C = cmap_grad(clist,Nlevel,Nrep) returns colormap matrix cmap_grad(clist,Nlevel,Nrep) set colormap --- Input clist : color value list [N x 3] Nlevel : number of levels in one colormap Nrep : number of repetition of basic colormap --- Output C : colormap matrix ([R G B] matix) : [NtotalLevel x 3] Masa-aki Sato 2014-10-30 Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function C = cmap_gradation(clist,Nlevel,Nrep) 0002 % Make gradation color map from color list 0003 % C = cmap_grad(clist,Nlevel,Nrep) 0004 % returns colormap matrix 0005 % cmap_grad(clist,Nlevel,Nrep) 0006 % set colormap 0007 % --- Input 0008 % clist : color value list [N x 3] 0009 % Nlevel : number of levels in one colormap 0010 % Nrep : number of repetition of basic colormap 0011 % --- Output 0012 % C : colormap matrix ([R G B] matix) : [NtotalLevel x 3] 0013 % 0014 % Masa-aki Sato 2014-10-30 0015 % 0016 % Copyright (C) 2011, ATR All Rights Reserved. 0017 % License : New BSD License(see VBMEG_LICENSE.txt) 0018 0019 if size(clist,2) ~= 3, error('Color must be 3 vector'); end; 0020 0021 N = size(clist,1); 0022 0023 if N < 2, error('Color list must larger than 2 colors'); end; 0024 if nargin<2, Nlevel=8; end; 0025 if nargin<3, Nrep = 1; end; 0026 0027 C = []; 0028 0029 for n=1:N-1 0030 Ctmp = cmap_grad(clist(n,:),clist(n+1,:),Nlevel); 0031 if n > 1, Ctmp = Ctmp(2:end,:); end; 0032 C = [C; Ctmp]; 0033 end 0034 0035 C = repmat(C, [Nrep 1]); 0036 0037 if nargout==0 0038 colormap(C); 0039 end