This isn't meant to be the end-all be-all thermal colormap; it's just an attempt at improving on the default hot
built into matlab/matplotlib/etc, which has nasty bands at the yellow and red corners. Something based on perceptual color space would probably be even better.
Code is ugly because it's not that great of a colormap so I'm not going to bother cleaning it up. :) Initially it had a radius parameter but I decided 0.5 was the only value that made sense, so the code could be simplified with that.
You can see in the MRI image that the default hot colormap obscures some detail in the cheek(?) region, because saturated red and orange are not so distinguishable from each other, while the smoothed version shows it more clearly.
Built-in thermal-like maps gist_heat
, afmhot
, hot
, and copper
all have some banding/flaws, but ColorBrewer maps OrRd
, YlOrRd
, YlOrBr
, Oranges
are pretty good.