如何创建灰度视频

时间:2016-10-09 17:49:32

标签: matlab image-processing video-processing

我在Matlab中编写了一个代码,我必须在其中读取彩色视频,从视频中检索帧,然后使用帧执行某些操作,然后再从操作帧中制作视频,我编写了一个简单的代码来转换每个帧到灰度,从而生成灰度视频,它显示以下错误:

  

警告:没有视频帧写入此文件。该文件可能无效。

     

在VideoWriter.VideoWriter> VideoWriter.close at 307

     

在VideoWriter.VideoWriter> VideoWriter.delete at 256

     

在9的getFrames2Image中

以下是我写的代码

a=VideoReader('test.mp4');
images=cell(a.NumberOfFrames,1);
for img=1:a.NumberOfFrames
    b=read(a,img);
    c=rgb2gray(b);
    images{img}=b;
end
outp=VideoWriter('output');
outp.FrameRate=30;
open(outp);
for i=1:length(images)
    frame=im2frame(images{i});
    writeVideo(outp,frame);
end
close(outp);

这里要求的是我的matlab版本的详细信息: Matlab R2013a(8.1.0.604) 64位(win64) 和示例视频的链接 https://drive.google.com/open?id=0B-MZ8myQc4ZKU0E1dURPRUhwd1k

0 个答案:

没有答案
相关问题