Valcolor

版本 1.0.0.0 (3.0 KB) 作者: Jurgen
Apply color CLR to colormap entry pertaining to value VAL. Either scaled or indexed figure.
500.0 次下载
更新时间 2013/4/29

查看许可证

Extension of zerocolor() for arbitrary color. Greater control over colormaps allows user to increase contrast for particular values.

% valcolor(VAL,CLR)
% Updates current figure's colormap so values VAL get color CLR.
% This includes values mapped to the same color as VAL.
% CLR is either a vector between 0-1, e.g. [.4 .2 .9] or
% a standard MATLAB color string shorthand, e.g. 'r'.
% Based on Clim and CDataMapping value of current axes and image.
%
% valcolor(H,VAL,CLR) uses figure handle H instead of current.
%
% cmap = valcolor(...)
% Returns modified cmap based on figure's colormap.
% Does not apply it to figure. Apply with colormap().
%
% cmap = valcolor(VAL,CLR,oldmap,clims)
% Outputs colored cmap based on input map and clims.
% May supply data instead of clims, gets [min max] to create clims.
% If clims = false, assumes indexed colormap.

Examples:
im1 = imread('moon.tif'); %scaled
figure;imagesc(im1);axis off
colormap(gray(64));
valcolor(0,['b'])
valcolor(50,[1 0 0 ])
valcolor(100,'g')
valcolor(200,[1 1 0 ])
colorbar
%

im2 = load('clown'); %indexed
figure;imshow(im2.X,im2.map);
valcolor(0,[0 1 0]);
valcolor(40,[0 0 0]);
valcolor(60,[0 1 1]);
valcolor(80,['k']);
colorbar

引用格式

Jurgen (2024). Valcolor (https://www.mathworks.com/matlabcentral/fileexchange/41533-valcolor), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2008a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Colormaps 的更多信息
致谢

参考作品: custom colormap, Zerocolor

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.0.0.0