mmap.m

来自「Matlab 6.0图形图像处理所附带的光盘」· M 代码 · 共 35 行

M
35
字号
function map=mmap(c,m)%MMAP Single Color Colormap.% MMAP(C,M) makes a colormap of length M starting with the% basic colorspec C. The map changes from dark to light.% MMAP(C) is the same length as the current colormap.%% Example: mmap('y') is a yellow colormap%          mmap([.49 1 .83]) is an auqamarine colormap%          mmap('c',20) is a cyan colormap having length 20.%          mmap('c') is the default if C can not be interpreted.%% Apply using: colormap(mmap(c,m))%% D. Hanselman, University of Maine, Orono, ME  04469% 4/17/95% Copyright (c) 1996 by Prentice Hall, Inc.if nargin<=1, m=size(get(gcf,'colormap'),1); endif nargin==0, c=[0 1 1]; endcolors='ymcrgb';rgb=[1 1 0;1 0 1;0 1 1;1 0 0;0 1 0;0 0 1];if isstr(c)  % colorspec is a letter	i=find(c==colors);	if isempty(i), i=3;end	c=rgb(i,:);  % convert it to an rgb vectorendif all(c==0),c=rgb(3,:);end % don't allow a black colormap!c=c./max(c); % normalize valuesn=ceil(1.1*m); % throw out black end of gray colormapmap=gray(ceil(1.1*m)); % generate gray colormap to colorizemap=map(n-m+1:n,:)*diag(c);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?