我有一个多图像 tiff 文件(例如 3000 帧),并且想将每个图像加载到 matlab 中(我现在使用的是 2010a)。但是我发现随着帧索引的增加,读取图像需要更长的时间。以下是我现在使用的代码
for i=1:no_frame;
IM=imread('movie.tif',i);
IM=double(IM);
Movie{i}=IM;
end
Run Code Online (Sandbox Code Playgroud)
有没有其他方法可以更快地做到这一点?
IMREAD 的TIFF特定语法列表对参数进行了如下说明'Info'
:
从多图像 TIFF 文件读取图像时,将 的输出
imfinfo
作为参数值传递'Info'
有助于imread
更快地定位文件中的图像。
结合Jonas 建议的元胞数组的预分配,这应该可以加快速度:
fileName = 'movie.tif';
tiffInfo = imfinfo(fileName); %# Get the TIFF file information
no_frame = numel(tiffInfo); %# Get the number of images in the file
Movie = cell(no_frame,1); %# Preallocate the cell array
for iFrame = 1:no_frame
Movie{iFrame} = double(imread(fileName,'Index',iFrame,'Info',tiffInfo));
end
Run Code Online (Sandbox Code Playgroud)