在Matlab中创建视频的方法

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



慕运维8079593
浏览 714回答 3
3回答

www说

以下是在(核心)MATLAB中创建电影的一些不同方法。电影2AVI(已弃用,请改用VIDEOWRITER)%# figurefigure, set(gcf, 'Color','white')Z = peaks; surf(Z);  axis tightset(gca, 'nextplot','replacechildren', 'Visible','off');%# preallocatenFrames = 20;mov(1:nFrames) = struct('cdata',[], 'colormap',[]);%# create moviefor k=1:nFrames   surf(sin(2*pi*k/20)*Z, Z)   mov(k) = getframe(gca);endclose(gcf)%# save as AVI file, and open it using system video playermovie2avi(mov, 'myPeaks1.avi', 'compression','None', 'fps',10);winopen('myPeaks1.avi')AVIFILE(已弃用,请改用VIDEOWRITER)%# figurefigure, set(gcf, 'Color','white')Z = peaks; surf(Z);  axis tightset(gca, 'nextplot','replacechildren', 'Visible','off');%# create AVI objectnFrames = 20;aviobj = avifile('myPeaks2.avi', 'fps',10);%# create moviefor k=1:nFrames   surf(sin(2*pi*k/20)*Z, Z)   aviobj = addframe(aviobj, getframe(gca));endclose(gcf)%# save as AVI file, and open it using system video playeraviobj = close(aviobj);winopen('myPeaks2.avi')视频制作人%# figurefigure, set(gcf, 'Color','white')Z = peaks; surf(Z);  axis tightset(gca, 'nextplot','replacechildren', 'Visible','off');%# create AVI objectnFrames = 20;vidObj = VideoWriter('myPeaks3.avi');vidObj.Quality = 100;vidObj.FrameRate = 10;open(vidObj);%# create moviefor k=1:nFrames   surf(sin(2*pi*k/20)*Z, Z)   writeVideo(vidObj, getframe(gca));endclose(gcf)%# save as AVI file, and open it using system video playerclose(vidObj);winopen('myPeaks3.avi')写入(从技术上讲不是电影,而是GIF动画图片)%# figurefigure, set(gcf, 'Color','white')Z = peaks; surf(Z);  axis tightset(gca, 'nextplot','replacechildren', 'Visible','off');%# preallocatenFrames = 20;f = getframe(gca);[f,map] = rgb2ind(f.cdata, 256, 'nodither');mov = repmat(f, [1 1 1 nFrames]);%# create moviefor k=1:nFrames    surf(sin(2*pi*k/20)*Z, Z)    f = getframe(gca);    mov(:,:,1,k) = rgb2ind(f.cdata, map, 'nodither');endclose(gcf)%# create GIF and openimwrite(mov, map, 'myPeaks4.gif', 'DelayTime',0, 'LoopCount',inf)winopen('myPeaks4.gif')
打开App,查看更多内容
随时随地看视频慕课网APP