I have a simulation running in MATLAB and I want to make a movie from the frames. There are more than 4000 frames at least 1600x1600 in size. Each frame is a 2D matrix. I can visualize them with pcolor
and make a movie using getframe
. But as the size is huge and the simulation is running overnight, I will run into alot of problems with screen savers, etc. Is there any better way to do this in MATLAB? Solutions with other softwares is also OK.
问问题
2458 次
2 回答
2
就在使用 绘制图片之前pcolor()
,尝试使用创建一个不可见的图形,h = figure('visible', 'off');
并使用addframe(avi_file, h);
它为来自不可见图形的 avi 添加一个框架。更详细的讨论可以在Render MATLAB figure in memory中找到
更新:似乎没有办法getframe()
在无头 Matlab 中使用框架,因此使用选项VideoWriter
和movie2avi
将不起作用。如果有人成功了,请在评论部分纠正我。
于 2013-05-23T15:30:59.137 回答
1
使用@Bee answer中提供的链接和一些修补问题可以像这样解决:
aviobj=VideoWriter(filename);
open(aviobj);
hFig=figure('Visible','Off');
for loop comes here
cla
%All Drawing stuff
img = hardcopy(hFig, '-dzbuffer', '-r0');
writeVideo(aviobj, im2frame(img));
end
close(aviobj)
请注意,它使用的是VideoWriter
而不是弃用的avifile
,addframe
并且它在内存中而不是在磁盘上进行渲染,因此速度相当快。
于 2013-05-24T08:29:55.673 回答