matRad function wrapper for getting a colormap We use this wrapper to manually handle the supported colormaps enabling the definition of custom colormaps. call cMap = matRad_getColormap(name,size) list = matRad_getColormap() input name name of the colorbar size optional argument for the size / resolution of the colorbar if no argument is passed, a list (cell array) of the names of all supported colormaps will be returned output This is either the requested colormap, or a list of all available colormaps (see above) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright 2015 the matRad development team. This file is part of the matRad project. It is subject to the license terms in the LICENSE file found in the top-level directory of this distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part of the matRad project, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the LICENSE file. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function output = matRad_getColormap(name,size) 0002 % matRad function wrapper for getting a colormap 0003 % We use this wrapper to manually handle the supported colormaps enabling 0004 % the definition of custom colormaps. 0005 % 0006 % call 0007 % cMap = matRad_getColormap(name,size) 0008 % list = matRad_getColormap() 0009 % input 0010 % name name of the colorbar 0011 % size optional argument for the size / resolution of the colorbar 0012 % 0013 % if no argument is passed, a list (cell array) of the names of all 0014 % supported colormaps will be returned 0015 % 0016 % output 0017 % This is either the requested colormap, or a list of all available 0018 % colormaps (see above) 0019 % 0020 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0021 % 0022 % Copyright 2015 the matRad development team. 0023 % 0024 % This file is part of the matRad project. It is subject to the license 0025 % terms in the LICENSE file found in the top-level directory of this 0026 % distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part 0027 % of the matRad project, including this file, may be copied, modified, 0028 % propagated, or distributed except according to the terms contained in the 0029 % LICENSE file. 0030 % 0031 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0032 0033 if nargin < 2 0034 size = 64; %Default number of colors 0035 end 0036 0037 %If no argument is given, the functinon returns all available colormaps 0038 if nargin == 0 0039 %String cell array of supported colormaps 0040 cMaps{1} = 'bone'; 0041 cMaps{end+1} = 'gray'; 0042 cMaps{end+1} = 'jet'; 0043 cMaps{end+1} = 'parula'; 0044 cMaps{end+1} = 'cool'; 0045 0046 % check for additional colormaps 0047 [folder, ~, ~] = fileparts(mfilename('fullpath')); 0048 listing = dir([folder filesep 'colormaps']); 0049 for i = 1:numel(listing) 0050 if listing(i).bytes > 0 && ~listing(i).isdir && strcmp(listing(i).name(end),'m') 0051 colormapFile = listing(i).name; 0052 cMaps{end+1} = colormapFile(1:end-2); 0053 end 0054 end 0055 output = cMaps; 0056 end 0057 0058 if nargin > 0 0059 try 0060 sFuntion = [name '(' num2str(size,'%d') ')']; 0061 output = evalin('caller',sFuntion); 0062 catch 0063 warning(['Colormap "' name '" not supported by matRad']); 0064 output = jet(size); 0065 end 0066 end