What is the fastest way to load multiple image tiff file in matlab?
The TIFF-specific syntax list for IMREAD says the following for the 'Info'
parameter:
When reading images from a multi-image TIFF file, passing the output of
imfinfo
as the value of the'Info'
argument helpsimread
locate the images in the file more quickly.
Combined with the preallocation of the cell array suggested by Jonas, this should speed things up for you:
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
You may want to preassign the array Movie
(or use R2011a, where growing an array inside a loop is less of an issue)
Movie = cell(no_frame,1);
for i=1:no_frame;
IM=imread('movie.tif',i);
IM=double(IM);
Movie{i}=IM;
end