# MATLAB Controlling color saturation points on an image3

Posted by Doug Hull,

In this MATLAB video we show how you can manipulate the clim property of an axis to determine the points that an image will saturate the colormap. This is often a better choice than making a strange colormap to get the same effect.

Roy replied on : 1 of 3
I have a related question. I have used the function you wrote "makeColorMap" to make a colormap that goes smoothly from red to white to blue. Now suppose I want to make sure that red shades are for negative numbers, blue shades are for positive numbers and any zero contours would be white. Is there a simple way to anchor white to the zero level?
dhull replied on : 2 of 3
@Roy, You can set the clim as specified in the movie. Make those limits such that the white value of colormap happens to fall on zero. So it is slightly indirect, takes a little bit of math, but should not be difficult. Especially if it is a symmetric colormap, just choose the clims to be equidistant from zero. Doug
Matteo replied on : 3 of 3
Roy, If the colorbar is not symmetric you could calculate the difference between the signed most negative and most positive values in your data and use both the numerical result and its sign to assign the limits of saturation automatically. this should anchor it to zero. Something like the below "pseudocode":
if D maxpos+maxneg >0 % abs(maxpos) > abs (maxneg)
clim=[maxneg (maxpos-D)]
elseif
D = maxpos+maxneg <0
clim=[(maxneg-D) (maxpos)]
end



This site uses Akismet to reduce spam. Learn how your comment data is processed.