Matlab:使用avifile,addframe,getframe;生成的avi被扭曲 [英] Matlab: using avifile, addframe, getframe; the generated avi is contorted

查看:299
本文介绍了Matlab:使用avifile,addframe,getframe;生成的avi被扭曲的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在训练一种机器学习算法,并且想要制作一个avi来可视化重量随时间的变化.我把类似的东西放在一起:

I'm training a machine learning algorithm, and wanted to make an avi to visualize the appearance of weights over time. I threw together something similar to:

aviobj = avifile( 'weights.avi' );
for jj = 1:whatever
  % do some training
  imagesc( ... ); % where '...' is stuff to reshape the weight matrix
  aviobj = addframe( aviobj, getframe );
end;
aviobj = close( aviobj );
implay( 'weights.avi' );

问题是,框架最终看起来像这样:

The problem is, the frames end up looking like this:

数字不应该具有该方向.我在matlab中生成的任何avi都会发生这种情况.

The numbers shouldn't have that orientation. This occurs with any avi I generate in matlab.

有什么建议吗?

-布莱恩

推荐答案

最后有时间回到这个问题上.问题出在轴上.使用imageimagesc之类的字符时,它会在底部&图片的左侧.使用getframe时,它仅捕获绘制的图像数据,无黑线.但是,帧本身比图像数据稍大.

Finally had time to get back to this. The problem was due to the axes. When using something like image or imagesc, it tacks on an extra black border line on the bottom & left of the image. When you use getframe, it grabs only the image data plotted, sans the black lines. However, the frame itself is slightly larger than the image data.

以下解决方案:

aviobj = avifile( 'weights.avi' );
fig = figure;
for jj = 1:whatever
  % do some training
  imagesc( ... ); % where '...' is stuff to reshape the weight matrix
  axis off;
  aviobj = addframe( aviobj, getframe( fig ) );
end;
aviobj = close( aviobj );
implay( 'weights.avi' );

设置axis off可以解决该问题.

这篇关于Matlab:使用avifile,addframe,getframe;生成的avi被扭曲的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆