I have an indexed image (2-D, not rgb), and i use imagesc to display the image. This function gives a range from blue to red, which can be set by colormap, and can be viewed by colorbar.
Now, I want to change the background, that is usually 0's or NaN's, to white or black, but that it will not affect or change the range of the colormap/colorbar. I've tried converting all the image to 3-D rgb, but this prevent the option of changing the contrast, or the clims, like in imagesc.
So, there is other way to do that?
EDIT:
@Shai's solution was good, but it caused other problem-
When I have an image with a range of values and the background is NaN's, and I display the image in a specific contrast (by imagesc(img, [-1,1]) for example), I get range of colors between -1 to 1, and i get white in the background (because i put [1 1 1] in the first entry of the colormap), but also all the values under the minimum of contrast (i.e., <-1 in the example) also get the white color instead of the bottom dark blue in the colorbar scale.
Any idea for that...?
Many Thanks.