The idea for this project was inspired by Matt Hall of Agile.
The plan is to eventually build a web app that will:
- download images with maps from the internet, for example from Twitter
- automatically detect the color maps
- flag those with rainbow and other non perceptual colormaps and automatically tweet a warning
- convert the colormap to a more perceptual version and tweet a copy of the new image
This is my envisioned workflow (ideally all automatic, no user input required, and no hard-coded parameters):
- download images with maps from Twitter
- detect the map portion of the image (it will require removal of text, background, and additional elements like colorbar)
- reduce the number of colors in the image
- convert from RGB to HSL and group the reduced colors into 7-8 families, or clusters using H,L pairs
- get the mean values for H,L for each cluster
- sort the mean H, L by H
- check for monotonicity of L as a perceptual test
- post a tweet with a warning ('bad colormap', or similar)
- as optional functionality: convert colormap to a perceptual version and tweet a copy of the new image
See my notebook Evaluate and compare colormaps for a background on perceptual colormaps, and in particular part 4 for an example of the perceptual test.
I started with a quick and dirty Matlab prototype some time ago to try my ideas on sorting and to try the test of monotonicity, which seemed to work: an image of geophysical data with non perceptual colormap
one with perceptual colormap (in the sense of ordered, strictly monotonic lightness)
and the result of sorting H and L by H
The logic for the test, in Matlab, was:
test = (all(diff(L)<0)) | (all(diff(L)<0))
which will translate into:
all(x<y for x, y in pairwise(L))
Now I am implementing the whole workflow in Python. I plan to test different ideas, or points in the workflow in different notebooks, which I will upload as completed, and then combine once I have all the different pieces done