f_gsafecmap.m 928 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. %f_gsafecmap.m
  2. function gcmap = f_gsafecmap(nEl)
  3. % This generates a colormap (gcmap) that renders well in grayscale.
  4. % This is a refinement of Carey Rappaport's colormap CMRmap,
  5. %
  6. % http://www.mathworks.com/matlabcentral/fileexchange/2662-cmrmap-m
  7. %
  8. % C. Rappaport, “A color map for effective black-and-white rendering
  9. % of color-scale images�, IEEE Antennas Propagat. Mag., vol. 44, no.
  10. % 3, pp. 94–96, Jun. 2002.
  11. %
  12. %
  13. % Optional Input: nEl - number of elements in colormap
  14. if nargin<1
  15. nEl = 64;
  16. end
  17. CMRmap = [ ...
  18. 0.00,0.00,0.00; ...
  19. 0.15,0.15,0.50; ...
  20. 0.30,0.15,0.75; ...
  21. 0.60,0.20,0.50; ...
  22. 1.00,0.25,0.15; ...
  23. 0.90,0.50,0.00; ...
  24. 0.90,0.75,0.10; ...
  25. 0.90,0.90,0.50; ...
  26. 1.00,1.00,1.00];
  27. x9 = linspace(0,1,9);
  28. xcmap = linspace(0,1,nEl);
  29. % resample to nEl values using splines
  30. for i = 1:3
  31. gcmap(:,i) = interp1(x9,CMRmap(:,i),xcmap,'spline');
  32. end
  33. % maintain bounds
  34. gcmap(gcmap<0)=0;
  35. gcmap(gcmap>1)=1;
  36. end