2015-10-13 40 views
1

我有一个我想要转换为视频的MATLAB图形序列。这些数字组成的2个次要情节,使得每个插曲包含覆盖在它2个不同的地块(红,绿)的imshow,如下所示:在MATLAB中的子图中获取视频图像序列的图像

enter image description here

我如何获得的所有图像数据包含在每个图中,以便下一步我可以使用VideoWriter将图像序列转换为视频?

回答

1

的关键是:

im = frame2im(getframe(h));  

其中H是手柄的曲线或坐标轴 您也可以通过一个可选的参数“矩形”来的getFrame到指定区域进行抓拍。

下面是MathWorks中关于如何在循环中使用getframe来记录帧的示例。欲了解更多信息,请键入doc getframe

Z = peaks; 
surf(Z) 
axis tight manual 
ax = gca; 
ax.NextPlot = 'replaceChildren'; 

loops = 40; 
F(loops) = struct('cdata',[],'colormap',[]); 
for j = 1:loops 
    X = sin(j*pi/10)*Z; 
    surf(X,Z) 
    drawnow 
    F(j) = getframe(gcf); 
end 

% Play back the movie two times. 

fig = figure; 
movie(fig,F,2)