Tristan Ursell
Feb 2013
Adaptive colormap
rgbslide(mat_in,...)
slide_map = rgbslide(...);
This function creates, on the fly, an active / adaptive colormap for the data given by the matrix 'mat_in', and can be used in combination with image generation in a figure. This can be very useful for coloring data according to its absolute value. For instance, if your data ranges from -rand to rand and you want the positive values in that image to be zero=black --> positive number=red, and the negative values to be zero=black --> negative numbers=blue -- the colormap would have to actively adjust itself to the image data -- that is what this function does. Try out the examples.
Another nice thing is that if you use zero_color = [0 0 0]; (i.e. black) then the colormap is guaranteed to be linear luminosity in each direction (unlike most other colormaps, e.g. 'jet').
This function has a number of options:
'zero_val' is the value that will map to the color 'zero_color', the default is 0.
'low_val' is the value to which 'low_color' corresponds, if no value is specified then 'low_val' will be min(mat_in(:)).
'high_val' is the value to which 'high_color' corresponds, if no value is specified then 'high_val' will be max(mat_in(:)).
'zero_color' is a 1 x 3 color vector specifying the color of the value 'zero_val', the default is black (0 0 0).
'low_color' is a 1 x 3 color vector specifying the color of the lowest value in the map, the default is blue (0 0.25 1).
'high_color' is a 1 x 3 color vector specifying the color of the highest value in the map, the default is red (1 0.25 0).
The term 'equal' may be invoked to keep the colormapping around 'zero_val' constrained to equal slope on each side, or no argument will allow the slopes to vary independently so as to maximize the color contrast on either side of 'zero_val'.
'res' sets the resolution of the colormap, such that the output 'slide_map' will be res x 3 in size.
SEE ALSO: colormap, stretchlim
|