Be the first to rate this file! 14 Downloads (last 30 days) File Size: 2.84 KB File ID: #39453
image thumbnail

Adaptive Colormap Function Creates a Colormap Specific to Data

by Tristan Ursell

 

13 Dec 2012 (Updated 12 Feb 2013)

Easily design and fit a colormap to the values in your data!

| Watch this File

File Information
Description

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

Acknowledgements

This file inspired Zerocolor.

Required Products MATLAB
MATLAB release MATLAB 7.14 (R2012a)
Tags for This File  
Everyone's Tags
active, adaptive, blue, color, colorbar, colormap, contrast, custom, data, green, hot, jet, luminosity, map, red, set, specific, stretchlim
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (1)
14 Dec 2012 Tristan Ursell

I'll fix the typos in the description soon.

Updates
25 Jan 2013

updates to the description and instructions.

11 Feb 2013

Significant upgrades to the code, can now handle specifications of all control points, colors, and any resolution, with any input matrix values.

12 Feb 2013

shortened code, fixed a bug

12 Feb 2013

matlab central uploaded the wrong file

Contact us