Rendering a float array to 24-bit RGB image (using PIL for example)
问题 x is a numpy.float32 array, with values from -200 to 0 . These are dB (decibel) values. When I do (as recommended here): Image.fromarray(x, mode='F') I get a greyscale or sometimes nearly black image. How to map a float in [-200, 0] to a 24-bit RGB byte array (using a colormap) that can be read with the Python module PIL with Image.fromarray(x, mode='RGB') ? Edit: The required .wav audio file is here, for which we want to plot the spectrogram. Here is some code to test: import scipy, numpy as