首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >可视化/比较Matlab/Octave到matplotlib的numpy数组

可视化/比较Matlab/Octave到matplotlib的numpy数组
EN

Stack Overflow用户
提问于 2021-02-25 23:17:17
回答 1查看 78关注 0票数 0

我是python和matplotlib的新手,我想可视化/比较以txt格式存储为numpy数组的3个mfcc文件。

我有下面的Octave代码,我想知道如何使用python/matplotlib来完成它。

任何帮助都是非常感谢的。

代码语言:javascript
复制
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);
EN

回答 1

Stack Overflow用户

发布于 2021-02-26 00:08:54

很明显,你的例子有外部性,所以我不能直接重现它,但一般来说,这里是一个八度的例子,它的等效的python例子使用了你所需要的图像特性。

在Octave中

代码语言:javascript
复制
% 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中

代码语言:javascript
复制
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()
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66371357

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档