【问题标题】:Visualise/compare numpy arrays from Matlab/Octave to matplotlib可视化/比较从 Matlab/Octave 到 matplotlib 的 numpy 数组
【发布时间】:2021-05-27 23:32:09
【问题描述】:

我是 python 和 matplotlib 的新手,我想可视化/比较 3 个以 txt 格式存储为 numpy 数组的 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,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);

【问题讨论】:

    标签: matlab numpy matplotlib signal-processing octave


    【解决方案1】:

    显然您的示例具有外部性,因此我无法直接复制它,但是在 一般这里是一个 octave 示例及其等效的 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()
    

    【讨论】:

    • 这是我可以开始的一点。谢谢
    • @lima0 很高兴。也欢迎使用 Stackoverflow。您可以为好的答案投票,也可以通过单击对勾来“接受”一个(如果您认为这是最“正确”的答案)。如果您认为此答案符合上述任何一项,请相应地投票/接受:)
    猜你喜欢
    • 2014-07-22
    • 2016-03-29
    • 1970-01-01
    • 2012-09-01
    • 1970-01-01
    • 2018-02-14
    • 1970-01-01
    • 2018-12-03
    • 1970-01-01
    相关资源
    最近更新 更多