imagesc - change background colour

3 views (last 30 days)
Nitin
Nitin on 11 Nov 2012
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

Accepted Answer

bym
bym on 11 Nov 2012
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)

More Answers (0)

Categories

Find more on Images in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!