Make gradation color map from two color C = cmap_grad(chigh,clow,Nlevel) returns colormap matrix cmap_grad(chigh,clow,Nlevel) set colormap --- Input chigh : color corresponding to max value clow : color corresponding to min value Nlevel : number of levels in colormap --- Output C : colormap matrix ([R G B] matix) : [Nlevel x 3] Masa-aki Sato 2008-8-1 Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function C = cmap_grad(chigh,clow,Nlevel) 0002 % Make gradation color map from two color 0003 % C = cmap_grad(chigh,clow,Nlevel) 0004 % returns colormap matrix 0005 % cmap_grad(chigh,clow,Nlevel) 0006 % set colormap 0007 % --- Input 0008 % chigh : color corresponding to max value 0009 % clow : color corresponding to min value 0010 % Nlevel : number of levels in colormap 0011 % --- Output 0012 % C : colormap matrix ([R G B] matix) : [Nlevel x 3] 0013 % 0014 % Masa-aki Sato 2008-8-1 0015 % 0016 % Copyright (C) 2011, ATR All Rights Reserved. 0017 % License : New BSD License(see VBMEG_LICENSE.txt) 0018 0019 if length(chigh) ~= 3, error('Color must be 3 vector'); end; 0020 if length(clow) ~= 3, error('Color must be 3 vector'); end; 0021 0022 chigh = chigh(:)'; 0023 clow = clow(:)'; 0024 0025 if nargin<3, Nlevel=100; end; 0026 0027 step=1/(Nlevel-1); 0028 0029 % gradation 0030 cgrad = [0:step:1]'; 0031 0032 % difference of two color 0033 cdif = chigh - clow; 0034 0035 % colormap 0036 C = vb_repadd( cgrad * cdif, clow); 0037 0038 if nargout==0 0039 colormap(C); 0040 end