arrayfire / forge

High Performance Visualization
226 stars 48 forks source link

Bad colormaps #122

Closed kryptan closed 7 years ago

kryptan commented 7 years ago

Colormaps are defined in src/backend/cmap.hpp in sRGB colorspace.

  1. Default (gray) colormap is defined by linearly increasing gray values. This linear increase happens in the sRGB colorspace. One should probably use linearly increasing values in a perceptually uniform colorspace so that e.g. 0.8 is perceptually 2x brighter than 0.4. For gray values sRGB is close so it is not a big deal but something better should probably be used.

  2. Spectrum. Its name suggests that it represents spectral colors. However pure spectral colors lie outside of the sRGB colorspace (as can be seen from the CIE chromaticity diagram for sRGB) and thus cannot be displayed on most modern monitors. The best thing we can do here is probably to take some interval, e.g. 400nm - 700nm, so that value 0.0 will correspondent to 400nm, 1.0 to 700nm and calculate sRGB colors closest to the spectral ones on this interval. I have not done this but I think that currently specified colormap is nowhere near it (maybe it is, but it must be verified).

  3. Colors. Comment says "pure colors" without any clarification of what does it mean. This colormap has different flaws. First of all it is not perceptually uniform, there are almost flat areas interleaved with abrupt changes. Also it contains colors of different brightness even though it looks like it was meant not to.

  4. Red. This looks legit.

  5. Mood. This looks legit.

  6. Heat. It is defined only by 64 points and there is no interpolation between them, this results in a very noticeable banding. It is also highly perceptually non-uniform. heat

  7. Blue. There is an abrupt change in this one near 200. blue

I suggest to add colormaps designed for matplotlib and remove of fix others.

It is important to have good colormaps, e.g. when bad colormaps are used in medicine they can lead to misdiagnosis.

pavanky commented 7 years ago

@kryptan

Thanks for providing detailed feedback. If you are willing, can you send a PR to the forge library with the changes ? :)

9prady9 commented 7 years ago

@kryptan & @pavanky Can you please check the changes i made to spectrum color map in the below PR. https://github.com/arrayfire/forge/pull/123

pavanky commented 7 years ago

@9prady9 I have no idea about this :) but please make sure the places you are picking these from are licensed appropriately.

9prady9 commented 7 years ago

@kryptan Any suggestions for improving (0) - Grayscale color map ?

kryptan commented 7 years ago

@9prady9 The page I linked above has a link to a tool for generating good colormaps (see Appendix).