How to Create Custom Colormaps in Digital Micrograph

The default colormap in Digital Micrograph is greyscale, but different applications or communities ofter use other colour look-up tables (CLUT) to highlight certain features or present data more artistically. You can see your colour scale choices in DM by right-clicking on an image and selecting “ImageDisplay…” or by pressing ctrl+D, then selecting ‘Display’ > ‘Color’, you will see something like this:

DM Colormap

You will see a 16×16 array of increasing shades (256 in total) that defines the colormap.The most direct (but most painful) way to create a new colormap is to click on each of these squares and adjust the colour values, when you’re done click ‘Save’. That requires you to make 256 individual, and smoothly graduated, selections and is rather painful.

Instead, we can create the necessary colormap using scripting; in this example by using Matlab.

The first thing to know is that DM just stores the colormaps in a hidden folder in the installation as a 16×16 pixel RGB image. Once you know that it’s just a case of creating the right sort of image and storing it in the right place.

Creating the RGB Colormap

First, we will use Matlab to create the RGB image we need from one of its in built colormaps.

clear all
% Create a dummy figure with no content:
% Create the colormap:
colormap hot(256)
cmap = colormap ;

% Reshap this to an RGB image:
RGB = reshape(cmap,16,16,3) ;
% Transpose to suit DM order:
RGB = permute(RGB,[2 1 3]) ;
% Write this image to disk:

% Close the dummy figure:
close all

This will give you a colour image file on the disk, as a TIFF, which has the correct properties for the next stage.

16x16 RGB

At 16×16 pixels it doesn’t look like much but it’s okay. Next, open this TIFF in Digital Micrograph:

DM Hot Colormap

Now save this as both a *.dm3 file and a *.dm4 file. The names of the files should be the same and will be the name of your new colormap in the menu. Finally, both these files should be copied to a hidden folder in the Gatan installation at:


while replacing **Username** with your own user name. If that folder doesn’t exist you should create it.

DM Hot

Select the new colormap and you’re done!


2 thoughts on “How to Create Custom Colormaps in Digital Micrograph

  1. Bernhard Schaffer

    Nice one!
    Just in case you don´t have Matlab, you can easily create any color map in the scripting language of DM itself. ( And the CLUTS don´t have to be 16×16 they can also be 256×1 )

    The advantage here is, that you can set the CLUT to any image directly in the same script, so you don´t have to store the color scheme locally, if you don´t like.

    You can see one example of creating a CLUT at the DM-script example homage at FELMI:

    And the following is just a script that can be directly run.
    (The color scheme is just bogus here.)

    // Just create the red/green/blue channels as 0..255 value images
    // and combine them into an RGB image
    // Create as 256 x 1 (if you want )
    RGBimage clut1 := RGBImage(“16×16 CLUT”,4,256)
    clut1 = rgb( 256 * icol/iwidth, 256 * sin( icol/iwidth * Pi() * 7 ), 256 * ( iwidth – icol ) / iwidth )

    // or create/reshape it as as 16×16 (if yout want)
    RGBimage clut2 := RGBImage(“16×16 CLUT”,4,16,16)
    clut2[icol%16,icol/16] = clut1


    // Setting a CLUT to the front image
    image front
    if (!GetFrontImage(front)) Throw(“No frontmost image”)
    front.ImageGetImageDisplay(0).ImageDisplaySetInputColorTable( clut1 )

  2. Ta-Kun Chen

    Hi Lewys,

    An alternative easy way to create simple color maps in DM, is to click the first square (upper-left) and drag your mouse to the final square (bottom-right) before you release the left mouse button. After input a color for the first square and the other for the final square, DM will create a linear interpolation in between these two colors.

    But your way provides much more possibilities. However I could not see the hidden folder you mentioned. In the file path I only see “Plugins” and “Prefs” even when I changed the setting to show hidden folders.

Leave a Reply to Ta-Kun Chen Cancel reply

Your email address will not be published. Required fields are marked *