File Exchange Pick of the Week

December 9th, 2011

A Vivid Colormap

Jiro's pick this week is Vivid Colormap by Joseph Kirk.

Good uses of colors can help convey ideas effectively. It can help you accentuate certain concepts. Or you may need to use a gradient color that translates well when printed in gray scale. Joseph's entry really caught my attention. As the name suggests, it produces quite a vivid colormap. The idea is ingenious; he creates a gradient within each color, and that produces an accent at each level.

Let's see how it works. We'll first create a blue and red diverging color map, which gradually changes from blue to red with white in the center. We'll use the peaks function as the sample image.

% Create 13-level blue/red diverging color map:
level = 13; n = ceil(level/2);
cmap1 = [linspace(1, 1, n); linspace(0, 1, n); linspace(0, 1, n)]';
cmap2 = [linspace(1, 0, n); linspace(1, 0, n); linspace(1, 1, n)]';
cmap = [cmap1; cmap2(2:end, :)];

imagesc(peaks(500));
colormap(vivid(cmap)); caxis([-8 8]);
colorbar

Notice how vivid it looks! vivid also has additional options to change the level of gradients.

Less vivid:

colormap(vivid(cmap, [.4, .6]));

More vivid:

colormap(vivid(cmap, [0, 1]));

You can also get the regular colormap behavior:

colormap(vivid(cmap, [.5 .5]));

More on Colormaps

As I was writing this post, I learned quite a bit about colormaps. MATLAB has a set of standard colormaps described here. There are a few File Exchange entries that create additional colormaps, such as cbrewer, othercolor, and Color Palette Tables. There are also colormaps that would look nice when printed on a grayscale printer - Lab color scale and colorGray.

I also found a couple of entries that would have helped me with creating the blue/red diverging colormap - bluewhitered and makeColorMap.

Comments

Check out all the File Exchange entries on colormaps! If you have your favorite colormap, let us know here or try Joseph's vivid and leave a comment for him.


Get the MATLAB code

Published with MATLAB® 7.13

5 Responses to “A Vivid Colormap”

  1. Oliver Woodford replied on :

    Another file exchange contribution with some handy colormaps (includung some vivid ones, and ones that look fine when printed in grayscale) is SC:
    http://www.mathworks.com/matlabcentral/fileexchange/16233
    It also avoids discretizing the image into a fixed number of colors, and makes it easy to save the resulting image to an image file. Run it with no inputs for a demo.

  2. Jiro Doke replied on :

    @Oliver,
    That’s a great one! I knew I was going to miss some good ones when I was looking through all the different entries on colormaps. Thanks for pointing it out. I like the extensive demo you have with explanations!

  3. Aurélien replied on :

    My favorite is lutbar from us:
    http://www.mathworks.fr/matlabcentral/fileexchange/9137

    POW in January 8th, 2010

    Aurélien

  4. Jonas replied on :

    My favorite is the somewhat cryptically named pmkmp (http://www.mathworks.com/matlabcentral/fileexchange/28982), which returns a colormap that looks pretty but doesn’t pretend the image is segmented into a few classes.

  5. Matteo replied on :

    Hi Jiro

    Comments: Great post. I love this colormap.
    A similar one (not divergent, here is an example: http://www.searchanddiscovery.com/documents/2007/07071blumentritt/images/03.htm) is used quite a bit in oil industry to map surface of structures interpreted from seismic data.
    That one is very useful partucluarly when trying to display at once many surfaces that are offset by significan change in elevation. Each surface would then get a hue and the saturation would map the elevation change within the particular structure.

    Favorites:
    When it comes to perceptually improved colormaps, I can’t but like these two I created:
    http://www.mathworks.com/matlabcentral/fileexchange/28982-perceptually-improved-colormaps
    http://www.mathworks.com/matlabcentral/fileexchange/33040-mkpj-perceptually-improved-jet-colormap

    There are also two entries by Matthias Geissbuehler:
    http://www.mathworks.com/matlabcentral/fileexchange/31761-colormap-fire-optimized-for-print
    http://www.mathworks.com/matlabcentral/fileexchange/31762-colormap-isolum-optimized-for-print-color-vision-deficiency


MathWorks

Brett & Jiro share their favorite user-contributed submissions from the File Exchange.

These postings are the author's and don't necessarily represent the opinions of MathWorks.