[英]Visualise/compare numpy arrays from Matlab/Octave to matplotlib
I'm new to python and matplotlib, and I'd like to visualise / compare 3 mfcc files stored as numpy arrays in txt format. I'm new to python and matplotlib, and I'd like to visualise / compare 3 mfcc files stored as numpy arrays in txt format.
I have the Octave code below, and I'd like to know how it can be done using python/matplotlib.我有下面的 Octave 代码,我想知道如何使用 python/matplotlib 来完成。
Any help is much appreciated.任何帮助深表感谢。
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,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,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=a11;
figure(3);
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);
Obviously your example has externalities so I can't reproduce it directly, but in general here is an octave example and its equivalent python one using the image features you require.显然,您的示例具有外部性,因此我无法直接复制它,但总的来说,这里是一个八度音程示例及其等效的 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
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()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.