how to fix the frame size?

The problem is that due to the rotation of the graph the size of the axis changes, so you end up with a sequence of frames of different sizes. You can see this if you insert the lines

s = size(mov(k).cdata);
fprintf('%d %d\n', s(2), s(1))

within the loop, directly after you grabbed the frame by

mov(k) = getframe(gca);

The result is

435 344
435 343
435 343
436 342
435 343
435 343
435 343
435 343
435 343
435 343
435 343
435 343
435 343
435 343
435 343
435 343
435 343
435 343
435 343
435 343

Because the first frame has the size 435 x 344, movie2avi expects the following frames to be of the same size – but they're not.

In order to fix this, you might want to set the axis size (& position) explicitly using set(gca, 'Position', [...]). An easier workaround though is to grab the frame not from the axis, but from the figure. That is, instead of mov(k) = getframe(gca); use

mov(k) = getframe(gcf);

The frames then have a uniform size of 560 x 420.

On my machine, the resulting avi has frames upside down. In order to fix this, too, you can additionally insert a line

mov(k).cdata = mov(k).cdata(end :-1: 1, :, :);

after grabbing the frame.




refered from http://stackoverflow.com/questions/18949050/movie2avi-how-to-fix-the-frame-size

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值