我正在尝试使用 VideoWriter 将大量 tiff 图像转换为 avi 视频。我在使用 for 循环将图像转换为视频时遇到问题。这是我到目前为止的代码:
function tif2avi
clc; close all;
[imagelist,p]=uigetfile('*.tif','MultiSelect','on',...
'Select LIST to plot'); pause(0.5); cd(p);
if ~iscell(imagelist); disp('imagelist not cell'); return; end;
outputVideo = VideoWriter('0424_rat01.avi');
outputVideo.FrameRate = 16;
outputVideo.Quality = 100;
open(outputVideo);
for i=1:numel(imagelist)
img=imread(imagelist(i));
writeVideo(outputVideo,img);
end
谁能帮我吗?我认为问题出在我的 for 循环中。
这是我尝试运行代码时遇到的错误:
Warning: No video frames were written to this file. The file may be invalid.
> In VideoWriter.VideoWriter>VideoWriter.close at 289
In VideoWriter.VideoWriter>VideoWriter.delete at 238
Error using imread>parse_inputs (line 476)
The filename or url argument must be a string.
Error in imread (line 335)
[filename, fmt_s, extraArgs] = parse_inputs(varargin{:});
Error in tif2avi (line 14)
img=imread(imagelist(i));