亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在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 關注
  • 760 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號