Imagesc change "background" color
37 次查看(过去 30 天)
显示 更早的评论
Hello guys,
I have a simple question, how can I set "background" color to white? Or how can I set a color of points with a specific value - for example all ones will be white.
Best regards
a = rand(50);
b = zeros(10,50);
c = [b; a; b];
imagesc(c)
colormap jet
![Výstřižek.PNG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/211166/V%C3%BDst%C5%99i%C5%BEek.png)
0 个评论
回答(2 个)
Image Analyst
2019-3-30
Use a different colormap
cmap = jet(256);
% Make lowest one black
cmap(1,:) = 0;
colormap(cmap);
0 个评论
DGM
2023-8-24
If you're using MIMT, this becomes simple. Just construct the image in whole and display it. Don't try to deal with conditionally colormapping different parts of an image.
% inputs
A = rand(50); % a 2D array on any arbitrary scale
padw = [10 0]; % [y x]
padcolor = [0.7 0 1]; % any I/IA/RGB/RGBA color tuple
CT = parula(256); % a colormap
% create pseudocolor image in RGB
outpict = gray2pcolor(A,CT,'cdscale'); % same quantization as imagesc()
% add custom colored border/padding
outpict = addborder(outpict,padw,padcolor);
% display it
image(outpict)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1464477/image.png)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Colormaps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!