Modifying the Turbo colormap

Recently, I came across this Wolfram Function Repository entry that implements the Turbo rainbow colormap of Mikhailov. There is a look-up table for the colors here, which can of course be used with Blend[] in Mathematica.

However, there is also a polynomial approximation due to Ruofei Du listed here. I decided to see if this polynomial approximation can be improved, and I managed to come up with one by adding a sixth and seventh order term to the polynomial approximation of the red component, and modifying the polynomial for the blue component. The following routine is the result:

turboApprox[t_?NumericQ] := With[{x = Clip[t, {0, 1}]},
     RGBColor[Fold[(#1 x + #2) &, 0,
                   {-3.88640322, -23.44894394, 141.551844, -240.965669, 
                    172.35660841, -50.24955545, 4.9960608, 0.14434465}], 
              Fold[(#1 x + #2) &, 0,
                   {2.82956604, 4.27729857, -14.18503333, 4.84296658,
                    2.19418839, 0.09140261}], 
              Fold[(#1 x + #2) &, 0,
                   {21.57469569, -72.72155837, 92.00658112, -52.17062334, 
                    11.13054206, 0.17597339}]]]

Here is a comparison of the original 256-color gradient (top) and the polynomial approximation (bottom):

Turbo colormap comparison

Leave a comment