【问题标题】:How to subplot and save movies in MATLAB?如何在 MATLAB 中绘制和保存电影?
【发布时间】:2013-05-11 07:15:14
【问题描述】:

我在 MATLAB 中制作了两部电影,我试图将它们都放在同一个图中,并将结果保存为 AVI 文件。

我了解如何使用subplot() 功能,但由于某种原因它无法正常显示。到目前为止,我的尝试是这样的;

f(count) = im2frame(uint8(newpic));
g(count) = im2frame(uint8(newpic));
subplot(1,2,1),movie(f,10,3); axis off; title('Damaged Image','fontweight','bold');
subplot(1,2,2),movie(g,10,3); axis off; title('Recreated Image','fontweight','bold');
movie2avi(f,'mov.avi','compression','None');
movie2avi(g,'mov.avi','compression','None');

但是生成的图形显示不正确,我实际上不知道如何将该图形保存为 AVI,我只知道如何保存单个文件。

任何帮助将不胜感激,在此先感谢!

【问题讨论】:

    标签: matlab avi movie subplot


    【解决方案1】:

    您可以使用getframe 捕获图形的内容并将其添加到电影中。
    使用getframe的示例代码

    Z = peaks;
    figure('Renderer','zbuffer');
    subplot(1,2,1)
    surf(Z);title('first plot')
    axis tight;
    set(gca,'NextPlot','replaceChildren');
    subplot(1,2,2);
    surf(-Z);title('second plot')
    axis tight;
    set(gca,'NextPlot','replaceChildren');
    for jj = 1:20
        subplot(1,2,1);
        surf(sin(2*pi*jj/20)*Z,Z)
        subplot(1,2,2);
        surf( -sin(2*pi*jj/20)*Z,Z);
        F(jj) = getframe;
    end
    movie2avi(F, 'mymov.avi', 'Compression','none');
    

    【讨论】:

      猜你喜欢
      • 2017-08-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-30
      • 2014-01-27
      • 2012-08-19
      • 1970-01-01
      相关资源
      最近更新 更多