2013-05-11 62 views
0

我在MATLAB中制作了两部电影,我试图让它们都在同一个图中,并将结果保存为AVI文件。如何在MATLAB中划分和保存电影?

我明白如何使用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,我只知道如何保存单个文件。

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

回答

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');