Perceptual rainbow palette – the goodies

Perceptual rainbow palette – Matlab function and ASCII files

In my last post I introduced cubeYF, my custom-made perceptual lightness rainbow palette. As promised there, I am sharing the palette with today’s post. For the Matlab users, cube YF, along with the other palettes I introduced in the series, is part of the Matlab File Exchange submission Perceptually improved colormaps.

For the non-Matlab users, please download the cubeYF here (RGB, 256 samples). You may also be interested in cube1, which has a slightly superior visual hue contrast, due to the addition of a red-like color at the high lightness end but at the cost of a modest deviation from 100% perceptual. I used cube 1 in my Visualization tips for geoscientists series.

Comparison of South America maps using, from left to right: ROYGBIV (from this post) , classic rainbow, cubeYF, and grayscale

Again, there is little doubt in my mind that cubeYF does a superior job compared to the other two rainbow palettes as it is free of artefacts [2] and more similar to grayscale (with the additional benefit of color).

The ROYGBIV and cubeYF map have been included in Marek Kultys’ excellent tutorial Visual Alpha-Beta-Gamma: Rudiments of Visual Design for Data Explorers, recently published on Parsons Journal for information mapping, Volume V, Issue 1.

An online palette testing tool

Both cubeYF and cube1 feature in the colormap evaluation tool by the Data Analysis and Assessment Center at the Engineer Research and Development Center. If you want to quickly evaluate a number of palettes, this is the right tool. The tool has a collection of many palettes, organized by categories, which can be used on 5 different test image, and examined in terms of RGB components and human perception. Below here is an example using cube YF.

Then I wondered: what if I used this to tell me something about a color palette’s mood? The circular histogram of colors reminded me of the Harmonic templates [4] on the hue wheel from this paper And so I created fat colorbars using the three palettes I used in the last post, saved them as images, and run the monitor with them. Here below are the results for Matlab jet, Industry Spectrum, and cubeYF. Looking at these palettes in terms of harmony I would say that jet is not very harmonic (too large a portion of the hue circle; the T template, which is the largest, spans 180 degrees), and that the spectrum is terrible.

CubeYF is also exceeding a bit 180 degrees, but looks very close to a T template rotated by 180 degrees (rotations are allowed). So perhaps I could trim it a bit? But to me it looks a lot nicer and gives me a vibe of really good mood, and reminds me of one of those beautiful central american headdresses, like Moctezuma’s crown.

Notes

[2] Looking at the intensity of the colorbars may help in the assessment: the third and fourth colorbars are very similar and both look perceptually linear, whereas the first and second do not.

[3] Quoted from Richard’s blog post: “… in the middle is a circular histogram of the colours (spectral shades) in the image, and gives an idea of how much of each colour there is. Up the left is a histogram of image brightness (lightness of colour), and up the right is a histogram of colour saturation (vibrancy)”.

[4] Quoted from the paper’s abstract: “Harmonic colors are sets of colors that are aesthetically pleasing in terms of human visual perception. If you are interested in this idea there is a set of slides and a video on the author’s website

A fellow member of the Matlab Users and Integrators group on LinkedIn asked:”..are perfectly balanced (color length equal across spectrum) possible or ideal?”

To which I replied:”If I understand your question correctly, you want to know if it is possible to make color palettes where perceptual distance between samples does varies regularly – in other words where Euclidean distance between data values correspond to Euclidean distance between hues. If that’s the case, the quick answer is yes. If you accept that CIELab color space is a good approximation of human perception, then you all you need is a color palette with linear Lightness like the one in this post:https://mycarta.wordpress.com/2012/12/06/the-rainbow-is-deadlong-live-the-rainbow-part-5-cie-lab-linear-l-rainbow/
To me CIELab is a good starting point. By using it, we certainly get in ballpark. There are however more recent color spaces that are considered even better approximations of human vision.”

Hi, I’m a bit confused by the RGB download of CubeYF. I’m trying to import the color ramp into ArcGIS, which takes RGB values. In the spreadsheet, is column 1 = R, column 2 = G, column 3 = B ? And for the color values in each column, they are decimal values, does this mean 0.443 = 43.3 when entering into RGB? RGB is typically whole number numbers 111,123,233. Really love the CubeYF and would love to use it (crediting you of course!)

Good question. I should clarify it in the post and page. You understand correctly that the three columns are column 1 = R, column 2 = G, column 3 = B. But the values are not in the range 0-255 as some programs require; they are in the range 0-1 as some other programs require. To get from the values in the file to the values you need, just multiply by 255 and round the values to integer.

Hi Matteo,
thanks for your work in this interesting yet sometimes underrated area.

I’m using your colormap to plot spectrograms of audio signals but I have the impression the results are somehow worse than what I was obtaining with the MATLAB ‘hot’ colormap. After reading your article I think they’re worse only in the way that my perception was previously tricked by the ‘hot’ colormap, but in one of your previous posts that very colormap is described as a decent one (much better than ‘jet’, for example), so I can’t understand why my perception seems to be that different 🙂

That’s why I wanted to ask you a question: do you think your colormap is suitable with any kind of dataset, no matter their values?

The shortest and more generic answer to your last question is no, I don’t think the perceptual colormap I shared are suitable with any kind of dataset. One example: the cube law rainbow (CubeYF) may not work well for divergent data (positive and negative values, where the zero is significant) where positive and negative amplitudes have equal importance. That is because the ramp of the cube law changes on either side of the central sample.

In the specific case of your spectrograms, it would be difficult without looking at some examples. Would you be able to share them?

If you aren’t, here are some thoughts: I would definitely favor a colormap with perceptual lightness profile. you are right that your perception was calibrated on the hot colormap, but I think it may be more complicated than that. The hot colormap has some artifacts but also has Lightness values varying between L=0 and L=100, providing the largest possible contrast. Conversely, the CubeYF has lightness values varying between about L=30 and L=90. The choice was a good compromise between personal taste (I like pastel hues), and the need for a good contrast range. I used figure 8 in The “Which Blair Project: A Quick Visual Method for Evaluating Perceptual Color Maps” (there is a copy of the paper here). The figure shows the effectiveness of a colormap decreases logarithmically with L contrast, so 60% is still good, but is not optimal if what you’re after IS contrast.

Hi Matteo,
thanks for your quick and very informative reply.
I must admit that I hadn’t really gone deep in the construction process of your colormap and thus, I missed some details like the reduced contrast (which in my case is beneficial).

I will produce some figures with some different colormaps (so far I’ve tried MATLAB’s ‘jet’ and ‘hot’ as well as yours and I’ll compare them with the two modified version you suggested) and share them.

Thank you for your work on this, I really like the LinearL Rainbow scale and am finding it useful for visualizing seismic attributes.

I am interested in finding a color scale for seismic data that would have a meaningful lightness profile. It would make sense for this to have a V shape–high lightness for high amplitudes, whether positive or negative, and low lightness for the middle.

We commonly use white-grey-black or red-white-blue. White-grey black at least is linear, but it isn’t the v-profile I think might work best, and it misses out on using color for more detail. Red-white-blue puts the lightest color at zero amplitude–it is useful for seeing more amplitude contrast than white-grey-black, but it also doesn’t fit my v-shaped ideal.

The ideal for me might be something like Petrel’s default color scale, but with black in the middle.

great to hear you find the LinearL useful. I use it with a lot of my attributes, including in Petrel; I particularly like it for impedance.

As for divergent colormaps for amplitude, I am currently working on both v-shaped ones and enhanced gray scales. I am going to either post about them or submit a short note for the CSEG Recorder; I’ll keep readers posted here on the blog in any case.

For now, take a look at Moreland’d divergent colormaps available on his site; although they still have the high lightness values in the middle, they do not have the colour mach band effet of the classic seismic red-white-blue, which in my opinion is what destrys a lot of the low amplitude details.

If you would like black to emphasize the zero crossing, you could add a zero contour on top of the colour display (this is Steve Lynch’s idea, thanks Steve!); if you used a transition to black, the overall display would end up really dark, giving the false impression that small amplitudes dominate (as a thought experiment, try and imagine these images, which have a middle-to-dark gray in the middle, as even darker).
Matteo

Matteo,
Thanks for your response. I see your point that having black in the middle can make image look very dark, although my focus is on seeing continuous high or low amplitudes (with linear L for the middle amplitudes), not on seeing the zero crossings. I’ve been playing with color scales and continue to be amazed how changing them can reveal different patterns in the data–looking forward to seeing the ones you’ve been working on!
Will

your articles about the pitfalls of rainbow colorbars are enlightening. The example of the Giza pyramid and L* plot is very simple and very effective!
When inspecting subsurface models (e.g. velocity) or maps (e.g. elevation map or Bouguer anomaly) the risk of being biased by artifacts due to gradient change in the L* plot is undeniable

What are your thoughts about equalized colorbars, such as in Geosoft ?(https://en.wikipedia.org/wiki/Histogram_equalization) Apart from the evident limitation of being data-dependent, for sure they improve the look and feel of the map.
On the other hand, are they improving at the same time the “truthfulness” of the perception or are making it even worse?

Thanks for the positive feedback; and great question! Although I do know some of the Geosoft colourmaps, I do not have access to the software. I don’t mind the idea of histogram equalization because it definitely increases the overall contrast of the data, without clipping. However, it is a global contrast improvement. So, for a non perceptual colourmap such as the rainbow, this would not change the fact that different portions of it have different gradients. To get the kind of equalization that will render the colourmap more perceptual you’d want to use Peter Kovesi’s equalization (based on Pizer’s method) described in here. Peter has a Matlab function, equalisecolourmap.m, which you can download from here together with a whole bunch of other colour tools. He’s also created a Julia package. If you like Python, I’ve made a very similar tool, which you can find here. Let me know if you end up trying either.

Blogroll

Meta

Go ahead if you want to use my code, modify it, improve it, for non-commercial AND for commercial use. You are also welcome to download and reuse my media files - unless otherwise stated. With both code and images, please give full and clear credit to Matteo Niccoli as the author and mycarta.wordpress.com as the source.
WordPress bloggers are welcome to reblog my posts. For republishing outside of WordPress or any other request, please e-mail me at: matteo@mycarta.ca