I am having some problems saving the image I am displaying as numpy ndarays.
Example:
This code:
librosa.display.specshow(static.T,sr=16000,x_axis='frames',y_axis='mel',hop_length=160,cmap=cm.jet)
plt.title("log mel power spectrum of " + name)
plt.colorbar(format='%+02.0f dB')
plt.tight_layout()
plt.savefig(plot+"/"+name+"_plot_static_conv.png")
plt.show()
Will show an image like this:
But when i store the image into a numpy ndarray, and then tries to plot it, I get something like this..
convert = plt.get_cmap(cm.jet)
numpy_output_static = convert(static.T)
plt.imshow(numpy_output_static)
plt.show()
raw_input("sadas")
Show me an image:
what is going on?.. why cant i store the same image, and view it the same way?
Minimal working example:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
from PIL import Image
import librosa
import librosa.display
from matplotlib import cm
fig = plt.figure(figsize=(12,4))
min = -1.828067
max = 22.70058
data = np.random.uniform(low=min, high=max, size=(474,40))
librosa.display.specshow(data.T,sr=16000,x_axis='frames',y_axis='mel',hop_length=160,cmap=cm.jet)
plt.show()
raw_input("sadas")
convert = plt.get_cmap(cm.jet)
numpy_output_static = convert(data.T)
plt.imshow(numpy_output_static, aspect = 'auto')
plt.show()
raw_input("asds")
First plot being :
Second plot being:
Normalizing the dataset doesn't fix the second image.