A colour map to show differences between images

While commenting to a recent blog post by Loren, someone linked to this article at IBM Research. I thought it had some very interesting points, and made me think about the 'zerobased' colour map in DIPimage. It is designed to highlight positive versus negative values, for example when displaying the difference between two images. Using a simple grey value colour map it is difficult to determine what exactly is the zero level.

For example, take the difference between two of the shifted images in the “imser” series (these are part of the image collection that comes with DIPimage):

a = readim('imser1')-readim('imser2');
a = [gaussf(a),-yy(30,256)*50/128]

grey colour map

I’ve added a little ramp to the right. When choosing the ‘zerobased’ colour map you currently get this:

old zerobased colour map

By making positive values red and negative values blue, it is clear which parts are larger in the first or the second image. But values that are close to 0 are difficult to distinguish. Taking an idea from the article I mentioned above, I played with making the 0 value unsaturated but not as dark. The larger the values, the more saturated and the brighter I made them. I wanted to keep positive values red and negative values blue, to match the 'saturation' colour map. But the article uses blue and yellow, so I tried that too. These are the two options:

blue-grey-red colour map

blue-grey-yellow colour map

I think the improvement is huge with respect to the current 'zerobased' colour map. It seems to me that the blue-grey-yellow map is slightly better balanced, but this is a very subjective conclusion. What do you think? Which do you prefer?

5 Responses to “A colour map to show differences between images”

  1. On April 21st, 2009, at 21:36, Charl Botha said:

    Hi Cris,

    You probably don’t remember me, you left the TU as I was more or less beginning there.

    The IBM work by Rogowitz and Treinish is well-known in visualisation. 🙂 Your final blue-yellow colour map looks like a huge improvement and is probably closer to being perceptually linear.

    See for example also the work by Haim Levkowitz at http://www.cs.uml.edu/~haim/ColorCenter/ – you can download a number of perceptually linear colour palettes from there.

    See you,


  2. On May 28th, 2010, at 20:03, Matteo said:

    Hello Chris,

    I just discovered your blog a couple of months ago (it was the stitching of panoramic using watershed, and the maze posts) and am now an avid reader.

    I really enjoyed this post on colormap. I tried to create my own colormaps and got a pretty good match to your first zerobased (the darker one) except I started right away with yellow and blue.
    I did it starting with HSI colorspace and then converting to RGB with a function from the file exchange.

    S=[linspace(255,0,128) linspace(0,255,128)]’;

    But I have a problem when I try to make the 0 values less saturated: I get a jump because my HUE is all pure blue for the negatives and pure yellow for negatives.
    How did you achieve the result? Interpiolating the HUE values. Or did you start with another colorspace?

    Thank you


  3. On May 28th, 2010, at 21:18, Matteo said:

    Hi Cris,

    – I got your name right this time – I got the wrong code snippet copied in my first post. And while I was correctign it I found my solution: I made I decrease in a way similar to S but less so, i.e.


    S=[linspace(255,0,128) linspace(0,255,128)]’;

    I=[linspace(255,75,128) linspace(75,255,128)]’;

    This got me pretty close to your blue and yellow result. next I’m off to try the combined high frequency low frequency luminance/saturation colrbar. Have you tried that?

  4. On May 29th, 2010, at 20:48, Cris Luengo said:

    Matteo, thanks for the compliment!

    I actually created the color map directly in RGB space, making the color go linearly from blue [0,0,1] to grey [0.4,0.4,0.4] to yellow [0.9,0.9,0].

    I did play around with the other color map, but didn’t have data for which it seemed useful at the time.

  5. On May 31st, 2010, at 20:29, Matteo said:

    Hey Cris

    I’ll let you know where I get with the latter. For my work it has applications in reflection seismic map and volume visualization.Cheers


Leave a Reply

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

Note: I moderate all comments. Comments without a clear relation to the text above will not be published.

You can use these HTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">