2015-10-13 44 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)