imagesc - change background colour

1 回表示 (過去 30 日間)
Nitin
Nitin 2012 年 11 月 11 日
Hello,
I have a filter of size 150 by 150 When using imagesc to plot the filter, the background is green
minValue = -1.5; maxValue = +1.5;
The RGB index of zeros in the image (green color) is is 0.5,1,0.5
I would like to change all the index '0' in the image to white while leaving the remaining as they are if possible.
size(colormap) : 64 3
I have tried the following:
imagesc(filter)
currentMap = colormap;
newMap = [1 1 1; currentMap];
colormap(newMap)
% The code above applies only to the top row of the filter but instead I would like the remaining index '0' to be 1
The code below changes the background to while but this time both +ve and -ve values of the filter turn purple:
j = colormap;
j(:,1) = [ 1 ];
j(:,3) = [ 1 ];
colormap(j);
imagesc(filter);
Looking forward to your feedback. Thanks a lot for your help.
Ash

採用された回答

bym
bym 2012 年 11 月 11 日
I am not sure exactly what you are asking, but is this close?
x = rand(150)*1.5-3;
imagesc(x)
cmap = colormap;
cmap_mod = cmap;
cmap_mod(any(cmap'==0),:)=1;
colormap(cmap_mod)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOrange についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by