フィルターのクリア

Why is the output of 'movie2avi' not showing the movie properly?

2 ビュー (過去 30 日間)
Abin Krishnan
Abin Krishnan 2015 年 10 月 24 日
回答済み: Jan 2015 年 10 月 26 日
I'm trying to save a movie as .avi file using the command movie2avi. The code is as follows:
b=0.3;
h=0.5;
m=2;
n=0;
x=linspace(0,b,200);
y=linspace(0,h,200);
[X,Y]=meshgrid(x,y);
F=500;
for i=1:F
p_hat=cos(m*pi*(X-i/F)/b).*cos(n*pi*(Y-i/F)/h);
surf(Y,X,p_hat,'edgecolor','none');
M(i)=getframe(gcf);
end
movie2avi(M,'p(2,0).avi','compression','None');
When I open the file p(2,0), it shows the MATLAB window that was there in the background while the movie was running.
Please help to get rid of the issue.
Thanks
  2 件のコメント
Geoff Hayes
Geoff Hayes 2015 年 10 月 25 日
Abin - are you referring to the MATLAB figure appearing in the background of your movie? As your code is passing the gcf into the getframe function, then you will see the figure (or window as you have called it) in your movie. If you wish to grab just the axes, then do
M(i) = getframe(gca);
But you will still see some of the figure because of the viewing angle of your axes (so the grey background of the figure will be present). If you wish to change the figure background colour to match that of the axes, then just do
set(gcf,'Color','white');
M(i) = getframe(gca);
Abin Krishnan
Abin Krishnan 2015 年 10 月 26 日
What I meant was, when the movie file is played outside MATLAB, it shows a still frame with a portion of the MATLAB window showing the script,command history etc that was in the background when the movie was played when I ran the code. Luckingly, that issue is sorted out. I used the command set(gcf,'renderer','zbuffer'); before the for loop.
Thank You.

サインインしてコメントする。

回答 (1 件)

Jan
Jan 2015 年 10 月 26 日
Try to insert a pause(0.02) before getframe. In some Matlab versions this helped to let the screen update correctly.

カテゴリ

Help Center および File ExchangeAudio and Video Data についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by