hmeine / qimage2ndarray

qimage2ndarray is a small python extension for quickly converting between QImages and numpy.ndarrays (in both directions).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Applying different color maps to 2d array

vguillet opened this issue · comments

Good afternoon,

I was wondering is it was possible to convert a 2d numpy array to a Pixmap with a colour gradient (similar to numpy's colorbar method) instead of a gray?

Thank you!

This functionality is not available yet, and I am not 100% sure if it should be. The current scope of qimage2ndarray is to be able to convert from ndarrays to QImage and back, with a few helper functions allowing to load/save or scale grayvalues.

I believe the latter is where you're coming from – it may appear as if qimage2ndarray intends to do the mapping from arbitrary values to QImage as well. On the one hand, I could imagine that a simple interface with matplotlib for instance might make sense – if array2qimage would accept a cmap parameter for instance and then make use of a matplotlib colormap function. On the other hand, I hesitate a little, because I wonder if this would be feature creep? Would people then ask to also have non-MPL colormaps included to get rid of the dependency? Would people eventually require even more ways to influence the mapping?

I honestly value your and others' opinions. (And should have picked up the discussion earlier, sorry about the delay.)