gpt4 book ai didi

matlab - 在matlab中创建视频的方法

转载 作者:太空宇宙 更新时间:2023-11-03 19:06:20 24 4
gpt4 key购买 nike

在 Matlab 中创建视频有哪些可能性?我正在搜索,发现主要有 3 个在该领域工作的工具箱,图像处理、图像采集和控制视觉……但是如果没有它们我怎么能做,只是从头开始创建视频?我对各种概述方法很感兴趣,但我无法在互联网上找到任何像样的教程或一致的信息来源。

感谢您的帮助!

最佳答案

以下是在(核心)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')

艾薇儿

(已弃用,改用 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')

IM写入

(技术上不是电影,而是动画 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')

关于matlab - 在matlab中创建视频的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11051307/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com