


Monochrome - Monochrome colormap (from white to a given color).
USAGE
m = Monochrome(color,n,<options>)
color optional target color (default = black)
n optional number of rows in output matrix (default = 100)
<options> optional list of property-value pairs (see table below)
=========================================================================
Properties Values
-------------------------------------------------------------------------
'hgamma' gamma-like correction for hue (1 = no correction, default)
=========================================================================

0001 function m = Monochrome(color,n,varargin) 0002 0003 %Monochrome - Monochrome colormap (from white to a given color). 0004 % 0005 % USAGE 0006 % 0007 % m = Monochrome(color,n,<options>) 0008 % 0009 % color optional target color (default = black) 0010 % n optional number of rows in output matrix (default = 100) 0011 % <options> optional list of property-value pairs (see table below) 0012 % 0013 % ========================================================================= 0014 % Properties Values 0015 % ------------------------------------------------------------------------- 0016 % 'hgamma' gamma-like correction for hue (1 = no correction, default) 0017 % ========================================================================= 0018 0019 % Copyright (C) 2009-2018 by Michaƫl Zugaro 0020 % 0021 % This program is free software; you can redistribute it and/or modify 0022 % it under the terms of the GNU General Public License as published by 0023 % the Free Software Foundation; either version 3 of the License, or 0024 % (at your option) any later version. 0025 0026 % Default values 0027 hgamma = 1; 0028 type = 'linear'; 0029 n0 = 100; 0030 color0 = [0 0 0]; 0031 0032 % Optional parameters 0033 if nargin == 0, 0034 % No parameter, use default color and n rows 0035 color = color0; 0036 n = n0; 0037 elseif nargin == 1, 0038 if isdvector(color,'#3','>=0'), 0039 % One parameter = color, use default n rows 0040 n = n0; 0041 elseif isiscalar(color), 0042 % One parameter = n rows, use default color 0043 n = color; 0044 color = color0; 0045 else 0046 % One parameter = neither color nor n rows, error 0047 error('Incorrect parameter (type ''help <a href="matlab:help Monochrome">Monochrome</a>'' for details).'); 0048 end 0049 else 0050 if isdvector(color,'#3','>=0'), 0051 % First parameter is color 0052 if ischar(n), 0053 % Second is an option, use default n rows 0054 varargin = {n,varargin{:}}; 0055 n = n0; 0056 elseif ~isiscalar(n), 0057 % Second is neither n rows nor an option, error 0058 error('Incorrect number of output rows (type ''help <a href="matlab:help Monochrome">Monochrome</a>'' for details).'); 0059 end 0060 elseif isiscalar(color), 0061 % First parameter is n rows, use default color 0062 varargin = {n,varargin{:}}; 0063 n = color; 0064 color = color0; 0065 else 0066 % First parameter is an option, use default color and n rows 0067 varargin = {color,n,varargin{:}}; 0068 n = n0; 0069 color = color0; 0070 end 0071 end 0072 0073 % Check number of parameters 0074 if mod(length(varargin),2) ~= 0, 0075 error('Incorrect number of parameters (type ''help <a href="matlab:help Monochrome">Monochrome</a>'' for details).'); 0076 end 0077 0078 0079 % Parse parameter list 0080 for i = 1:2:length(varargin), 0081 if ~ischar(varargin{i}), 0082 error(['Parameter ' num2str(i+2) ' is not a property (type ''help <a href="matlab:help Monochrome">Monochrome</a>'' for details).']); 0083 end 0084 switch(lower(varargin{i})), 0085 case 'hgamma', 0086 hgamma = varargin{i+1}; 0087 if ~isdscalar(hgamma,'>=0'), 0088 error('Incorrect value for property ''hgamma'' (type ''help <a href="matlab:help Monochrome">Monochrome</a>'' for details).'); 0089 end 0090 otherwise, 0091 error(['Unknown property ''' num2str(varargin{i}) ''' (type ''help <a href="matlab:help Monochrome">Monochrome</a>'' for details).']); 0092 end 0093 end 0094 0095 for i = 1:3, 0096 m(:,i) = linspace(1,color(i),n).^(1/hgamma); 0097 end