【发布时间】:2016-09-11 02:06:43
【问题描述】:
我正在尝试将视频文件转换为灰度。当我尝试运行 Matlab 脚本时,我得到一个“无效的视频数据 - 必须是数字或逻辑数据类型”。有人可以帮我解决我做错的事情吗?我也是 matlab 新手。
filename = 'Project1.m4v';
vid = VideoReader(filename);
newVid = VideoWriter('NewVid');
open(newVid);
numFrames = vid.NumberOfFrames;
for frame = 1 : numFrames
% Extract the frame from the movie structure.
thisFrame = read(vid, frame);
%Convert each frame to black and white
gray = rgb2gray(thisFrame);
writeVideo(newVid,gray);
end
close(newVid);
implay(newVid);
【问题讨论】:
标签: matlab