Le jeudi 28 janvier 2016 12:57:39 UTC-8, Matteo a écrit :

Hi Matthias

 

AWESOME!!

This is a great example, thank you, it will come handy pretty soon, if you are going to share it officially, so I'd love to see the blog post about it.

In my current particular case, the problem is that I do not know the colormap of the original img to begin with. Someone from a slack group suggested to convert it to a paletted image format (PNG or GIF) using PIL, then grab the palette shared a solution involving quantization. I asked for their permission to share it in here, I'll keep you posted.


Well, knowing the colormap is hard. In particular in the case of your Jupyter image, it is not a colormap, it is an actual many channel image, as the set of pixel is not a line on the RGB space:
(cf not-cmap attached file)

So "finding" the cmap and reversing it is not possible. 

One possibility would be to do a multidimentional regression on the RGB->luminosity dataset, and to project on this line. Basically "reconstructing" a colormap. 
But will inherently loose data. 

That should not even need scikit image, just scikit-learn. 

X = subset(image())
y = luminosity(subset(image))

Pca.fit(..).inverse_transform(luminosity(image)) 

 I'm not familiar enough with scikit learn to do a non-linear fit.

 

Back on your example of converting a bad colormap to a good one, I was working on adapting a Matlab tool by Peter Kovesi 

http://peterkovesi.com/projects/colourmaps/index.html


My idea would be to make it into a web app called 'rainbowbot' which would automatically detect bad colormaps either form online images or user uploaded images, and then provide them with tools to either equalize the colormaps or replace with a perceptual version with same hue range, or.....

It is in here 

https://github.com/mycarta/rainbowbot

I am open to suggestions, and offers to collaborate.


That was exactly my idea too,  but to do a twitter bot you can mention. 
I think the "detecting" from "remapping" should be separate. 

Also personally I think it would be a nice communication stunt to do at the same time matplotlib 2.0 gets out, to start to "viridize" people pictures on twitter by mentioning a bot. 

-- 
M