⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmaps.m

📁 matlab处理图像的一些基本方法。其中有一部分mex程序需要安装编译
💻 M
字号:
function cmaps(command)%CMAPS  Loads, saves and modifies the 30 colormaps.%%	CMAPS(COMMAND)%%	COMMAND is the action to take. It can be:%		- DEFAULT load the default colormaps.%		- LOAD load the colormaps from a file%		- SAVE save the colormaps in a file%		- MODIFY modify the actua colormap via icol.%%		- SPIN Controls for the colormaps spinning%		- PLAY Plays the colormaps%		- STOP Stop the spinning%		- RESET Reset the original colormap%%%       Claudio  May, 9 1995%%% Copyright (c) 1995 by Claudio Rivetti and Mark Young% claudio@alice.uoregon.edu,    mark@alice.uoregon.edu%global Extramap MapSize AlexDir TempDir readpath savepath Uibgcolorglobal speed_ed play_bt stop_bt reset_bt oldnmap Stopglobal map Handlefig B_frameglobal cmap%%%%%%%%%%%%%%%  MODIFY %%%%%%%%%%%%%%%%%%%%%%%%if strcmp(upper(command), 'MODIFY')  figure(Handlefig);  % Position variables---------------------------------------------------  pos=get(B_frame, 'Position');  uiwidth=0.12;  uithick=0.035;  middle=pos(1)+(pos(3)-uiwidth)/2;  %---------------------------------------------------------------------  whendone='';  apply_cbk=[' load ' TempDir 'newmap.tmp;setmap(newmap/255);'];  % Positions of buttons -----------------------------------------------------  apply_bt_pos=[middle, pos(2)+0.5-uithick, uiwidth, uithick];   %---------------------------------------------------------------------------    initbuttons('Modify Colormaps', 'Done', whendone);  apply_bt  = uicontrol(Handlefig, 'Style', 'push',...                'String', 'Apply',...                'Units', 'normalized',...                'Position', apply_bt_pos,...                'HorizontalAlignment', 'center',...                'CallBack', apply_cbk);  [s,pr]=unix('ps');  if isempty(findstr('icol', pr))    fp=fopen([TempDir 'map.tmp'], 'w+');    fprintf(fp, '%d %d %d\n', round(map(1:MapSize,:)*255)');    fclose(fp);    unix(['chmod +w ' TempDir 'map.tmp']);		fp=fopen([TempDir 'newmap.tmp'], 'w+');	fclose(fp);	unix(['chmod +w ' TempDir 'newmap.tmp']);	    com=['!' AlexDir 'icol -n ' int2str(MapSize) ' -a -o ' TempDir 'newmap.tmp -f asciiPlain ' TempDir 'map.tmp &'];    eval(com);  endend  % MODIFY%%%%%%%%%%%%%%%%%%%%%%  LOAD  %%%%%%%%%%%%%%%%%%%%%%%%%%if strcmp(upper(command), 'LOAD')  [name, cpath] = uigetfile([readpath '*.map']);  if ~isempty(name) & name ~= 0        f=watchon;        statusbar('Reading colormaps ...');                command=['load ' cpath name ' -mat'];        eval(command);                watchoff(f);        clearstatusbar;  endend  % LOAD%%%%%%%%%%%%%%%%%%%%%%  SAVE  %%%%%%%%%%%%%%%%%%%%%%%%%%if strcmp(upper(command), 'SAVE')  [name, cpath] = uiputfile([savepath '*.map']);  if ~isempty(name) & name ~= 0        f=watchon;        statusbar('Saving colormaps ...');                        command=['save ' cpath name ' Extramap cmap1 cmap2 cmap3 cmap4 cmap5',...                                    ' cmap6 cmap7 cmap8 cmap9 cmap10',...                                    ' cmap11 cmap12 cmap13 cmap14 cmap15',...                                    ' cmap16 cmap17 cmap18 cmap19 cmap20',...                                    ' cmap21 cmap22 cmap23 cmap24 cmap25',...                                    ' cmap26 cmap27 cmap28 cmap29 cmap30'];        eval(command);                watchoff(f);        clearstatusbar;  endend  % SAVE%%%%%%%%%%%%%%%%%%%%%%  DEFAULT  %%%%%%%%%%%%%%%%%%%%%%%%%%if strcmp(upper(command), 'DEFAULT')  cmap=loadcell('cmap');  if 0,cmap{0},end;end  % DEFAULT if strcmp(upper(command), 'SPIN')	figure(Handlefig);		% Position variables-------------------------------------	pos=get(B_frame, 'Position');	uiwidth=0.12;	uithick=0.035;	middle=pos(1)+(pos(3)-uiwidth)/2;	% Positions of buttons ----------------------------------	txt_pos = [middle-.005 pos(2)+.59 uiwidth+.005 uithick];	ed_pos = [middle pos(2)+.55 uiwidth uithick];	play_pos = [middle pos(2)+0.45 uiwidth, uithick];	stop_pos = [middle pos(2)+0.38 uiwidth, uithick];	reset_pos = [middle pos(2)+0.31 uiwidth, uithick];			%  Callbacks for the buttons  ---------------------------	play_cbk  = 'cmaps(''PLAY'');'; 	stop_cbk  = 'cmaps(''STOP'');';	reset_cbk = 'cmaps(''RESET'');';	whendone  = 'cmaps(''STOP'');';	%--------------------------------------------------------	initbuttons('Play Colormaps', 'Done', whendone);	Stop=0;	oldnmap=getmap;		uicontrol(gcf,'Style','text',...				'String','Speed',...				'Units','normalized',...				'Horiz', 'center',...				'BackgroundColor', Uibgcolor,...				'Position',txt_pos);					speed_ed=uicontrol(gcf,'Style','edit',...				'String', '5',...				'value', 5,...				'Inter', 'yes',...				'Units','normalized',...				'Horiz', 'center',...				'Position',ed_pos,...				'CallBack', 'global speed_ed;editstr2value(speed_ed, 0, 10);');					play_bt = uicontrol(gcf,'Style','push',...                'String', 'Play',...				'Inter', 'yes',...                'Units', 'normalized', ...                'Position', play_pos,...                'CallBack',play_cbk);	stop_bt = uicontrol(gcf,'Style','push',...                'String', 'Stop',...				'Enable', 'off',...				'Inter', 'yes',...                'Units', 'normalized', ...                'Position', stop_pos,...                'CallBack',stop_cbk);					reset_bt = uicontrol(gcf,'Style','push',...                'String', 'Reset',...				'Inter', 'yes',...                'Units', 'normalized', ...                'Position', reset_pos,...                'CallBack', reset_cbk);end  %SPINif strcmp(upper(command), 'PLAY')  set(stop_bt, 'Enable', 'on');  set(play_bt, 'Enable', 'off');  Stop=0;  nmap=getmap;    while 1    oldmap=map;    setmap(map(:, [2 3 1]));	cmaps('PAUSE');	if Stop, break;end    setmap(map(:, [2 3 1]));	cmaps('PAUSE');	if Stop, break;end    setmap(fliplr(map));	cmaps('PAUSE');	if Stop, break;end    setmap(map(:, [2 3 1]));	cmaps('PAUSE');	if Stop, break;end    setmap(map(:, [2 3 1]));	cmaps('PAUSE');	eval(['cmap' num2str(nmap) '=oldmap;']);	if Stop, break;end	nmap=getmap+1;	if nmap > 30, nmap=1;end	setmap(nmap);	cmaps('PAUSE');	clearstatusbar;  end %whileend  %PLAYif strcmp(upper(command), 'PAUSE')  seconds=get(speed_ed, 'value');  seconds=abs(10-seconds);  if seconds==10    statusbar('Hit a key at the command line to continue');    pause;  else    pause(seconds);  endend  %PAUSEif strcmp(upper(command), 'STOP')  Stop=1;  if isobj(stop_bt)    set(stop_bt, 'Enable', 'off');    set(play_bt, 'Enable', 'on');  end  clearstatusbar;end  %STOPif strcmp(upper(command), 'RESET')  cmaps('DEFAULT');  setmap(oldnmap);end  %RESETreturn

⌨️ 快捷键说明

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