为了账号安全,请及时绑定邮箱和手机立即绑定

在Matlab中创建视频的方法

在Matlab中创建视频的方法

在Matlab中创建视频的可能性是什么?我经过搜索后发现,主要有3个工具箱可用于该领域,包括图像处理,图像采集和视觉控制...但是如果没有它们,我怎么能做,只是从头开始创建视频?我对概述的各种方法感兴趣,但是无法在互联网上找到任何不错的教程或一致的信息来源。
查看完整描述

3 回答

?
www说

TA贡献1775条经验 获得超8个赞

以下是在(核心)MATLAB中创建电影的一些不同方法。


电影2AVI

(已弃用,请改用VIDEOWRITER)


%# figure

figure, set(gcf, 'Color','white')

Z = peaks; surf(Z);  axis tight

set(gca, 'nextplot','replacechildren', 'Visible','off');


%# preallocate

nFrames = 20;

mov(1:nFrames) = struct('cdata',[], 'colormap',[]);


%# create movie

for k=1:nFrames

   surf(sin(2*pi*k/20)*Z, Z)

   mov(k) = getframe(gca);

end

close(gcf)


%# save as AVI file, and open it using system video player

movie2avi(mov, 'myPeaks1.avi', 'compression','None', 'fps',10);

winopen('myPeaks1.avi')

AVIFILE

(已弃用,请改用VIDEOWRITER)


%# figure

figure, set(gcf, 'Color','white')

Z = peaks; surf(Z);  axis tight

set(gca, 'nextplot','replacechildren', 'Visible','off');


%# create AVI object

nFrames = 20;

aviobj = avifile('myPeaks2.avi', 'fps',10);


%# create movie

for k=1:nFrames

   surf(sin(2*pi*k/20)*Z, Z)

   aviobj = addframe(aviobj, getframe(gca));

end

close(gcf)


%# save as AVI file, and open it using system video player

aviobj = close(aviobj);

winopen('myPeaks2.avi')

视频制作人

%# figure

figure, set(gcf, 'Color','white')

Z = peaks; surf(Z);  axis tight

set(gca, 'nextplot','replacechildren', 'Visible','off');


%# create AVI object

nFrames = 20;

vidObj = VideoWriter('myPeaks3.avi');

vidObj.Quality = 100;

vidObj.FrameRate = 10;

open(vidObj);


%# create movie

for k=1:nFrames

   surf(sin(2*pi*k/20)*Z, Z)

   writeVideo(vidObj, getframe(gca));

end

close(gcf)


%# save as AVI file, and open it using system video player

close(vidObj);

winopen('myPeaks3.avi')

写入

(从技术上讲不是电影,而是GIF动画图片)


%# figure

figure, set(gcf, 'Color','white')

Z = peaks; surf(Z);  axis tight

set(gca, 'nextplot','replacechildren', 'Visible','off');


%# preallocate

nFrames = 20;

f = getframe(gca);

[f,map] = rgb2ind(f.cdata, 256, 'nodither');

mov = repmat(f, [1 1 1 nFrames]);


%# create movie

for k=1:nFrames

    surf(sin(2*pi*k/20)*Z, Z)

    f = getframe(gca);

    mov(:,:,1,k) = rgb2ind(f.cdata, map, 'nodither');

end

close(gcf)


%# create GIF and open

imwrite(mov, map, 'myPeaks4.gif', 'DelayTime',0, 'LoopCount',inf)

winopen('myPeaks4.gif')


查看完整回答
反对 回复 2019-11-28
  • 3 回答
  • 0 关注
  • 713 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信