Because viridis, like all good colourmaps, is perceptually linear, it's easy to get the data from it: just use a greyscale version of the image. But you can rip the data from any pseudocolour image if you know (or can guess) the colourmap.
In the rip-data.py
example, here's the approach:
- Read the image and transform the values to the range 0-1.
- Guess the colourmap, in this case it's viridis. Matplotlib conveniently gives us the RGB triples that make up a colourmap.