1

For a given val we are able to get the RGB tuple tup via the following method:

import matplotlib as mpl

tup = mpl.cm.viridis(val)

here viridis is the default matplotlib colormap.

How do I do the reverse? I.e. get val from tup?

Tian
  • 870
  • 3
  • 12
  • 24
  • 1
    Can you verify the wording of your question is correct? Your first and last lines seem to be conflicting. "For a given val we are able to get the RGB tuple tup" and "How do I do the reverse? I.e. get tup from val". The second is not the reverse of the first, it is the same. – Hymns For Disco Jan 24 '20 at 08:41
  • oops sorry about that, the first line was wrong, making the change now – Tian Jan 24 '20 at 08:42
  • 1
    Although the question isn't formulated exactly the same, the main point is similar enough, so I posted my answer [here](https://stackoverflow.com/questions/3720840/how-to-reverse-a-color-map-image-to-scalar-values/59897582#59897582) – JohanC Jan 24 '20 at 13:42

0 Answers0