问题描述
我是 python 和 matplotlib 的新手,我想可视化/比较以 txt 格式存储为 numpy 数组的 3 个 mfcc 文件。
我有下面的 Octave 代码,我想知道如何使用 python/matplotlib 来完成它。
非常感谢任何帮助。
load /dir/k11.txt
load /dir/t11.txt
load /dir/a11.txt
subplot(1,2,1);imagesc(j11);axis('xy');colormap(jet);colorbar;subplot(1,2);imagesc(t11);axis('xy');colormap(jet);colorbar;
c=[k11(:,end),k11(:,1:end-1)];
figure(1);
Ncep=size(c,2)-1;
a=real(fft([c,zeros(size(c,1),512-NceP*2-1),c(:,end:-1:2)]'));
imagesc(a(1:end/2,:));
axis('xy');
colormap(jet);
c=t11;
figure(2);
Ncep=size(c,:));
axis('xy');
colormap(jet);
c=a11;
figure(3);
Ncep=size(c,:));
axis('xy');
colormap(jet);
解决方法
显然你的例子有外部性,所以我不能直接复制它,但是在 一般这里是一个八度音阶示例及其等效的python示例,使用您需要的图像功能。
在八度中
% Read an image from a url
Url = 'https://raw.githubusercontent.com/utkuozbulak/singular-value-decomposition-on-images/master/data/grayscale_cat.jpg';
A = imread( Url );
imagesc( A ); % Show image in 'colour-scaled' form
axis xy % Reverse the origin of the y-axis
colormap( jet ); % Choose the jet colormap
在 Python3 中
import urllib.request # needed for reading urls
import matplotlib.pyplot as plt # needed for imread/imshow
import matplotlib.colors as cl # needed for colour-scaling
# Read an image from a url
Url = urllib.request.urlopen( 'https://raw.githubusercontent.com/utkuozbulak/singular-value-decomposition-on-images/master/data/grayscale_cat.jpg' )
A = plt.imread( Url,'jpg' )
plt.imshow( A,# Create a pyplot 'image' instance
norm = cl.Normalize(),# Choose colour-scaled form
origin = 'lower',# Reverse the origin of the y-axis
cmap = 'jet' # Choose the jet colormap
)
plt.show()