%f_gsafecmap.m function gcmap = f_gsafecmap(nEl) % This generates a colormap (gcmap) that renders well in grayscale. % This is a refinement of Carey Rappaport's colormap CMRmap, % % http://www.mathworks.com/matlabcentral/fileexchange/2662-cmrmap-m % % C. Rappaport, “A color map for effective black-and-white rendering % of color-scale images�, IEEE Antennas Propagat. Mag., vol. 44, no. % 3, pp. 94–96, Jun. 2002. % % % Optional Input: nEl - number of elements in colormap if nargin<1 nEl = 64; end CMRmap = [ ... 0.00,0.00,0.00; ... 0.15,0.15,0.50; ... 0.30,0.15,0.75; ... 0.60,0.20,0.50; ... 1.00,0.25,0.15; ... 0.90,0.50,0.00; ... 0.90,0.75,0.10; ... 0.90,0.90,0.50; ... 1.00,1.00,1.00]; x9 = linspace(0,1,9); xcmap = linspace(0,1,nEl); % resample to nEl values using splines for i = 1:3 gcmap(:,i) = interp1(x9,CMRmap(:,i),xcmap,'spline'); end % maintain bounds gcmap(gcmap<0)=0; gcmap(gcmap>1)=1; end